An Experimental Analysis of a Compact Graph Representation ∗

An Experimental Analysis of a Compact Graph Representation ∗

An Experimental Analysis of a Compact Graph Representation ∗ Daniel K. Blandford Guy E. Blelloch Ian A. Kash Computer Science Department Carnegie Mellon University Pittsburgh, PA 15213 blandford,blelloch,iak @cs.cmu.edu f g Abstract Many methods have been proposed for compressing In previous work we described a method for compactly various specific classes of graphs. There have been representing graphs with small separators, which makes many results on planar graphs and graphs with constant use of small separators, and presented preliminary ex- genus [32, 15, 13, 18, 14, 21, 8, 6]. These representations perimental results. In this paper we extend the experi- can all store an n-vertex unlabeled planar graph in mental results in several ways, including extensions for O(n) bits, and some allow for O(1)-time neighbor dynamic insertion and deletion of edges, a comparison queries [21, 8, 6]. By unlabeled we mean that the of a variety of coding schemes, and an implementation representation is free to choose an ordering on the vertices (integer labels from 0 to n 1). To represent a of two applications using the representation. − The results show that the representation is quite ef- labeled graph one needs to additionally store the vertex fective for a wide variety of real-world graphs, including labels. Other representations have been developed for graphs from finite-element meshes, circuits, street maps, various other classes of graphs [15, 12, 24, 30]. A router connectivity, and web links. In addition to signif- problem with all these representations is that they can icantly reducing the memory requirements, our imple- only be used for a limited class of graphs. mentation of the representation is faster than standard In previous work we described a compact represen- representations for queries. The byte codes we intro- tation for graphs based on graph separators [5]. For c duce lead to DFT times that are a factor of 2.5 faster unlabeled graphs satisfying an O(n ), c < 1 separa- than our previous results with gamma codes and a fac- tor theorem, the approach uses O(n) bits and supports tor of between 1 and 9 faster than adjacency lists, while neighbor or adjacency queries in O(1)-time per edge. using a factor of between 3 and 6 less space. A property of the representation, however, is that it can be applied to any graph, and the effectiveness of 1 Introduction compression will smoothly degrade with the quality of the separators. For random graphs, which don't have We are interested in representing graphs compactly small separators (in expectation), the space require- while supporting queries and updates efficiently. The ment asymptotically matches the informational theoret- goals is to store large graphs in physical memory for ical lower bound. This smooth transition is important in use with standard algorithms requiring random access. practice since many real-world graphs might not strictly In addition to having applications to computing on large satisfy a separator theorem, but still have good separa- graphs (e.g. the link graph of the web, telephone call tor properties. In fact, since many graphs only come in a graphs, or graphs representing large meshes), the rep- fixed size, it does not even make sense to talk about sep- resentations can be used for medium-size graphs on de- arators theorems, which rely on asymptotic character- vices with limited memory (e.g. map graphs on a hand- istics of separators. As it turns out, most \real world" held device). Furthermore even if the application is not graphs do have small separators (significantly smaller limited by physical memory, the compact representa- than expected from a random graph). This is discussed tions can be faster than standard representations be- in Section 1.1. cause they have better cache characteristics. Our ex- This paper is concerned with the effectiveness of the periments confirm this. separator-based representation in practice. We extend the previous approach to handle dynamic graphs (edge ∗This work was supported in part by the National Science insertions and deletions) and present a more complete Foundation as part of the Aladdin Center (www.aladdin.cmu.edu) set of experiments, including a comparison of different under grants CCR-0086093, CCR-0085982, and CCR-0122581. prefix codes, comparison on two machines with different tices are ordered randomly, then our static representa- cache characteristics, a comparison with several variants tion with byte codes is between 2.2 and 3.5 times faster of the adjacency-list representation, and experimental than adjacency arrays for a DFS (depending on the ma- results of two algorithms using the representation. Our chine). If the vertices are ordered using the separator experiments show that our representations mostly dom- order we use for compression then the byte code is be- inate standard representations in terms of both space tween .95 and 1.3 times faster than adjacency arrays. and query times. Our dynamic representation is slower For dynamic graphs we compare our dynamic rep- than adjacency lists for updates. resentation to optimized implementation of adjacency In Section 2 we review our previous representation lists. The performance of the dynamic separator-based as applied to edge-separators. The representation uses a representation depends on the size of blocks used for separator tree for labeling the vertices of the graph and storing the data. We present results for two settings, uses difference codes to store the adjacency lists. In one optimized for space and the other for time. The Section 3 we describe our implementation, including a representation optimized for space uses 11.6 bits per description of the prefix codes used in this paper. In Sec- edge and the one optimized for time uses 18.8 bits per tion 4 we describe an extension of the separator-based edge (averaged over all graphs). This compares with 76 representation that supports dynamic graphs, i.e., the bits per edge for adjacency lists. insertion and deletion of edges. Our original represen- As with adjacency arrays, the time performance of tation only supported static graphs. The extension in- adjacency lists depends significantly on the ordering volves storing the bits for each representation in fixed- of the vertices. Furthermore for adjacency lists the length blocks and linking blocks together when they performance also depends significantly on the order in overflow. A key property is that the link pointers can which edges are inserted (i.e., whether adjacent edges be kept short (one byte for our experiments). The rep- end up on the same cache line). The runtime of resentation also uses a cache to store recently accessed the separator-based representation does not depend on vertices as uncompressed lists. insertion order. It is hard to summarize the time results In Sections 5 and 6 we report on experiments ana- other than to say that the performance of our time lyzing time and space for both the static and dynamic optimized representation ranges from .9 to 8 times faster graphs. Our comparisons are made over a wide vari- than adjacency lists for a DFS. The .9 is for separator ety of graphs including graphs taken from finite-element ordering, linear insertion, and on the machine with a meshes, VLSI circuits, map graphs, graphs of router large cache-line size. The 8 is for random ordering connectivity, and link graphs of the web. All the graphs and random insertion. The time for insertion on the are sparse. To analyze query times we measure the time separator-based representation is up to 4 times slower for a depth-first search (DFS) over the graph. We picked than adjacency lists. this measure since it requires visiting every edge exactly In Section 7 we describe experimental results ana- once (in each direction) and since it is a common sub- lyzing the performance of two algorithms. The first is routine in many algorithms. a maximum-bipartite-matching algorithm and the sec- For static graphs we compare our static representa- ond is an implementation of the Google page-rank algo- tion to adjacency arrays. An adjacency array stores for rithm. In both algorithms the graph is used many times each vertex an array of pointers to its neighbors. These over so it pays to use a static representation. We com- arrays are concatenated into one large array with each pare our static representation (using nibble codes) with vertex pointing to the beginning of its block. This repre- both adjacency arrays and adjacency lists. For both al- sentation takes about a factor of two less space than ad- gorithms our representation runs about as fast or faster, jacency lists (requiring only one word for each directed and saves a factor of between 3 and 4 in space. edge and each vertex). For our static representation we All experiments run within physical memory so our use four codes for encoding differences: gamma codes, speedup has nothing to do with disk access. snip codes, nibble codes, and byte codes (only gamma codes were reported in our previous paper). The differ- 1.1 Real-world graphs have good separators An ent codes present a tradeoff between time and space. edge-separator is a set of edges that, when removed, Averaged over our test graphs, the static represen- partitions a graph into two almost equal sized parts tation with byte codes uses 12.5 bits per edge, and the (see [23] for various definitions of \almost equal"). snip code uses 9 bits per edge. This compares with 38 Similarly a vertex separator is a set of vertices that bits per edge for adjacency arrays. Due to caching ef- when removed (along with its incident edges) partitions fects the time performance of adjacency arrays depends a graph into two almost equal parts.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    13 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us