Making graphs compact by lossless contraction

This paper proposes a scheme to reduce big graphs to small graphs. It contracts obsolete parts and regular structures into supernodes. The supernodes carry a synopsis \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$S_\mathcal {Q}$$\end{document}SQ for each query class \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {Q}$$\end{document}Q in use, to abstract key features of the contracted parts for answering queries of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {Q}$$\end{document}Q. Moreover, for various types of graphs, we identify regular structures to contract. The contraction scheme provides a compact graph representation and prioritizes up-to-date data. Better still, it is generic and lossless. We show that the same contracted graph is able to support multiple query classes at the same time, no matter whether their queries are label based or not, local or non-local. Moreover, existing algorithms for these queries can be readily adapted to compute exact answers by using the synopses when possible and decontracting the supernodes only when necessary. As a proof of concept, we show how to adapt existing algorithms for subgraph isomorphism, triangle counting, shortest distance, connected component and clique decision to contracted graphs. We also provide a bounded incremental contraction algorithm in response to updates, such that its cost is determined by the size of areas affected by the updates alone, not by the entire graphs. We experimentally verify that on average, the contraction scheme reduces graphs by 71.9% and improves the evaluation of these queries by 1.69, 1.44, 1.47, 2.24 and 1.37 times, respectively.


Introduction
There has been prevalent use of graphs in artificial intelligence, knowledge bases, search, recommendation, business transactions, fraud detection and social network analysis. Graphs in the real world are often big, e.g., transaction graphs in e-commerce companies easily have billions of nodes and trillions of edges. Worse still, graph computations are often costly, e.g., graph pattern matching via subgraph isomorphism is intractable (cf. [42] There has been a host of work on the subject, either by making graphs compact, e.g., graph summarization [67] and compression [12,82], or speeding up query answering by building indices [81]. The prior work often targets a specific class of queries, e.g., query-preserving compression [37] and 2-hop labeling [25] are for reachability queries. In practice, however, multiple applications often run on the same graph at the same time. It is infeasible to switch compression schemes or summaries between different applications. It is also too costly to build indices for each and every query class in use.
Another challenge stems from obsolete data. As a real-life example, consider graphs converted from IT databases at a telecommunication company. The databases were developed in stages over years and have a large schema with hundreds of attributes. About 80% of the attributes were copied from earlier versions and have not been touched for years. No one can tell what these attributes are for, but no one has the gut to drop them in the fear of information loss. As a result, a large bulk of the graphs is obsolete. As another example, there are a large number of zombie accounts in Twitter. As reported by The New York Times, 71% of Lady Gaga's followers are fake or inactive, and it is 58% for Justin Bieber. The obsolete data incur heavy time and space costs and often obscure query answers.
The challenges give rise to several questions. Is it possible to find a compact representation of graphs that is generic and lossless? That is, we want to reduce big graphs to a substantially smaller form. Moreover, using the same representation, we want to compute exact answers to queries of different classes at the same time. In addition, can the representation separate up-to-date data from obsolete components without loss of information? Can we adapt existing evaluation algorithms to the compact form, without the need for redeveloping the algorithms starting from scratch? Furthermore, can we efficiently and incrementally maintain the representation in response to updates to the original graphs?
Contributions and organization. In this paper, we propose a new approach to tackling these challenges, by extending the idea of graph contraction.
(1) A contraction scheme (Sect. 2). We propose a contraction scheme to reduce big graphs into smaller ones. It contracts obsolete components and regular structures into supernodes, and prioritizes up-to-date data. For each query class Q, supernodes carry a synopsis S Q that records key features needed for answering queries of Q. As opposed to conventional graph summarization and compression, the scheme is generic and lossless. A contracted graph retains the same topological structure for all query classes Q, and the same synopses S Q work for all queries in the same class Q. Only S Q may vary for different query classes Q. We identify regular structures to contract in different types of graphs, and develop a (parallel) contraction algorithm.
(2) Proof of concept (Sect. 3). We show that existing query evaluation algorithms can be readily adapted to contracted graphs. In a nutshell, we extend the algorithms to handle supernodes. When answering a query Q in Q, we make use of the synopsis S Q of a supernode if it carries sufficient information for answering Q, and decontract the supernode only when necessary. We pick five different query classes: subgraph isomorphism (SubIso), triangle counting (TriC), shortest distance (Dist), connected component (CC) and clique decision (CD) based on the following dichotomies: • label-based queries (SubIso) versus non-label based ones (TriC, Dist, CC, CD); • local queries (SubIso, TriC, CD) versus non-local ones (Dist, CC); and • various degrees of topological constraints (Dist≺ CC ≺ TriC ≺ CD≺ SubIso).
We show how easy to adapt existing algorithms for these query classes to contracted graphs, without increasing their complexity. Better still, all these queries can be answered without decontraction of topological structures except some supernodes for obsolete parts.
(3) Incremental contraction (Sect. 4). We develop an incremental algorithm for maintaining contracted graphs in response to updates to original graphs. Such updates may change both the topological structures and timestamps (obsolete data). We show that the algorithm is bounded [77], i.e., it takes at most O(|AFF| 2 ) time, where |AFF| is the size of areas affected by updates, not the size of the entire (possibly big) graph. We parallelize the algorithm to scale with large graphs.
(4) Empirical evaluation (Sect. 5). Using 10 real-life graphs, we experimentally verify the following. On average, (a) the contraction scheme reduces graphs by 71.9%, up to 86.0%. (b) Contraction makes SubIso, TriC, Dist, CC and CD 1.69, 1.44, 1.47, 2.24 and 1.37 times faster, respectively. (c) The total space cost of our contraction scheme for the five accounts only for 12.6% of indices for TurboIso [44], HINDEX [75], PLL [4] and RMC [68]. It is 9.0% when kNN [92] also runs on the same graph. The synopses for each take 9.7% of the space. Hence, the scheme is scalable with the number of applications on the same graph. (d) Contracting obsolete data improves the efficiency of conventional queries and temporal queries by 1.64 and 1.78 times on average, respectively. (e) Our (incremental) contraction scheme scales well with graphs, e.g., it takes 33.1s to contract graphs of 1.8B edges and nodes with 20 cores.
We survey related work in Sect. 6 and identify research topics for future work in Sect. 7.

A graph contraction scheme
In this section, we first present the graph contraction scheme (Sect. 2.1). We then identify topological components to contract for different types of real-life graphs (Sect. 2.2). Moreover, we develop a contraction algorithm (Sect. 2.3) and its parallelization (Sect. 2.4). Preliminaries. We start with basic notations.
Graphs. Assume two infinite sets and for labels and timestamps, respectively. We consider undirected graphs G = (V , E, L, T ), where (a) V is a finite set of nodes, (b) E ⊆ V × V is a bag of edges, (c) for each node v ∈ V , L(v) is a label in ; and (d) T is a partial function such that for each node v ∈ V , if T (v) is defined, it is a timestamp in that indicates the time when v or its adjacent edges were last updated.

Queries.
A graph query is a computable function from a graph G to another object, e.g., a Boolean value, a number, a graph, or a relation. For instance, a graph pattern matching query is a graph pattern Q to find the set of subgraphs in G that are isomorphic to pattern Q, denoted by Q(G). A query class Q is a set of queries of the same "type," e.g., all graph pattern queries. We also refer to Q as an application.
In practice, multiple applications run on the same graph G simultaneously.

Contraction scheme
A graph contraction scheme is a triple f C , S, f D , where (1) f C is a contraction function such that given a graph G, G c = f C (G) is a graph deduced from G by contracting certain subgraphs H into supernodes v H ; we refer to H as the subgraph contracted to v H , and G c as the contracted graph of G by f C ; (2) S is a set of synopsis functions such that for each query class Q in use, there exists S Q ∈ S that annotates each supernode v H of G c with a synopsis S Q (v H ); and (3) f D is a decontraction function that restores each supernode v H in G c to its contracted subgraph H . Fig. 1a is a fraction of Twitter network. A node denotes a user (u), a tweet (t), a keyword (k), or a feature of a user such as id (i), name (n), number of followers ( f ) and link to other accounts of the same user in other social networks (l). An edge indicates the following:
In G, subgraphs in dashed rectangles are contracted into supernodes, yielding a contracted graph G c shown in Fig. 1b. Synopses S SubIso for SubIso are shown in Fig. 1d and are elaborated in Sect. 3.1.
Before we formally define functions f C , f D and synopsis S, observe the following.
(1) The contraction scheme is generic. (a) Note that f C , G c and f D are application independent, i.e., they remain the same no matter what query classes Q run on the contracted graphs. (b) While S is application dependent, it is query independent, i.e., all queries Q ∈ Q use the same synopses annotated by S Q .
(2) The contraction scheme is lossless due to synopses S and decontraction function f D . As shown in Sect. 3, an existing algorithm A for a query class Q can be readily adapted to contracted graph and computes exact query answers.
We next give the details of f C , S and f D . We aim to strike a balance between space cost and query evaluation cost. When a graph is over-contracted, i.e., when the subgraphs contracted to supernodes are too large or too small, the decontraction cost goes up although the contracted graph G c may take less space. Moreover, the more detailed synopses are, the less likely decontraction is needed, but the higher space overhead is incurred.
(1) Contraction function. Function f C contracts subgraphs in G into supernodes in G c . To simplify the discussion, we contract the following basic structures.
(a) Obsolete component: a connected subgraph consisting of nodes with timestamps earlier than threshold t 0 .
(b) Topological component: a subgraph with a regular structure, e.g., clique, star, path and butterfly. Different types of graphs have different regular substructures, e.g., cliques are ubiquitous and effective in social networks while paths are only effective in road networks. In Sect. 2.2, we will identify what regular structures H to contract in different types of graphs.
We contract subgraphs with the number of nodes in the range [k l , k u ] to avoid over-contraction (see Sects. 2.3 and 5 for the choices).
Contraction function f C maps each node v in graph G to a supernode in contracted graph G c , which is either a supernode v H if v falls in one of the subgraphs H in (a) or (b), or node v itself otherwise.
In Example 1, function f C maps nodes in each dashed rectangle to its corresponding supernode, e.g., Obsolete components help us prioritize up-to-date data, and topological ones reduce unnecessary checking when answering queries. As shown in Sect. 5, on average the first three regular structures and obsolete components contribute 18.3%, 14.9%, 2.8% and 63.1% to the contraction ratio, and speeds up query answering by 1.61, 1.44, 1.04 and 1.71 times, respectively.
Intuitively, the reverse function f C recovers the contracted nodes and their associated labels, while the decontraction function f D restores the topological structures of the contracted subgraphs.
(3) Synopsis. For each query class Q in use, a synopsis function S Q is in S, to retain features necessary for answering queries in Q. For instance, when Q is the class of graph patterns, at each supernode v H , S Q (v H ) consists of the type of v H and the most distinguished features of f D (v H ), e.g., the central node of a star and the sorted node list of a path. We will give more details about S Q in Sect. 3. As will also be seen there, f C and synopses S Q taken together often suffice to answer queries in Q, without decontraction.
Note that not every synopsis S Q has to reside in memory. We load S Q to memory only if its corresponding application Q is currently in use.
(4) Decontraction. Function f D restores contracted subgraphs. For supernode v H , f D (v H ) restores the edges between the nodes in f C (v H ), i.e., the subgraph induced by That is, the contracted subgraphs and edges are not dropped. They can be restored by f D when necessary. In light of f D , the scheme is guaranteed lossless.
For example, decontraction function f D restores the subgraph in Fig. 1a from supernodes, e.g., f D (v H 3 ) is a star with central node u 10 and leaves u 6 , u 7 , u 8 and u 9 . It also restores edges from superedges, e.g.,

Identifying regular structures
We now identify what regular structures to contract for different types of real-life graphs.
Different types of graphs. We investigated the following 10 different types of graphs: (1) social graphs: Twitter [70] and LiveJournal [94]; (2)  ..} of G together with the support of each g i . Support metrics may vary in different mining models, e.g., GRAMI [33] adopts minimum image based metric [19]. We pick subgraphs whose supports are above a threshold t s .
As an example, we adopt a subgraph miner GRAMI [33] as M. GRAMI discovers all the frequent subgraphs in G that have a support above a predefined threshold, which are then manually inspected. We pick g i 's with at least 4 nodes to avoid over-contraction.
As shown in Fig. 2, we found the following 6 structures in the 10 types of graphs: (a) clique: a fully-connected graph; (b) star: a single central node with neighbors; (c) path: a sequence of connected nodes with no edges between the head and tail (its two endpoints); (d) claw: a special star in which the central node has exactly 3 neighbors, denoted as its leaves; claws are quite frequent and are hence treated separately; (e) diamond: two triangles that share two endpoints; and (f) butterfly: two triangles sharing a single node.
Note that within these structures H , the only edges allowed are those that form H . Moreover, edges are allowed from each node in H to nodes outside of H . The only exception is that for a path, only the two endpoints can connect to other nodes in the graph.

Contraction algorithm
We next present an algorithm to contract a given graph G, denoted as GCon and shown in Fig. 3.
A tricky issue is that the contracted graphs depend on the order on the regular structures contracted. For example, if we contract diamonds first in the Twitter graph G 0 of Fig. 1a, then it contracts {t 2 , k 1 , k 5 , k 3 } as a diamond; after this there are no cliques in G 0 . In contrast, if cliques are contracted first, then {k 1 , k 2 , k 3 , k 4 , k 5 } is extracted. As suggested by M, cliques "dominate" in social graphs and hence should be "preserved" when contracting G 0 .
We adopt a deterministic order to ensure that important structures are contracted earlier and hence preserved. We order the importance of different types of regular structures in a graph G by their supports: the higher the support is, the more important the topology is. We denote by T (G) its ordered set of regular structures to contract in Table 1. Note that T (G) is determined by the type of G, e.g., social graphs, and is learned once offline regardless of individual G.
Given a graph G, algorithm GCon first contracts all obsolete data into components to prioritize up-to-date data. Each obsolete component is a connected subgraph that contains only nodes with timestamps earlier than a threshold t 0 . It is extracted by bounded breadth-first-search (BFS) that stops at non-obsolete nodes. The remaining nodes are then either Putting these together, we present the main driver of algorithm GCon in Fig. 3. Given a graph G, a timestamp threshold t 0 and range [k l , k u ], it constructs functions f C and f D of the contraction scheme. It first contracts nodes with timestamps earlier than t 0 into obsolete components (line 1). It then recalls the list T (G) of topological components to contract based on the type of graph G (line 2). Next, GCon contracts topological components into supernodes following order T (G), and deduces f C and f D accordingly (lines 3-5). Each topological component consists of only uncontracted nodes. More specifically, it does the following.
(1) It extracts a clique by repeatedly selecting an uncontracted node that connects to all selected ones, subject to pre-selected size bounds k l and k u (see below).
(2) It extracts a star by first picking a central node v c , and then repeatedly selecting an un-contracted node as a leaf that is (a) connected to v c and (b) disconnected from all selected leaves, again subject to k l and k u .
(3) For paths, it first extracts intermediate nodes having only two neighbors that are not linked by an edge. It then finds a path consisting of only the intermediate nodes, along with two neighbors of the endpoints.
(4) For diamonds, it first selects an edge (u, v) and then picks x and y that are (a) connected to both u and v, and (b) pairwise disconnected.
(5) For butterflies, it first selects a node v that has a degree at least 4. It then checks whether there exist four neighbors u, x, y, z of node v such that exactly (u, x, v) and (y, z, v) form two triangles.
(6) For claws, it selects nodes with exactly 3 neighbors, and there is no edge between any two neighbors.
As remarked earlier, the remaining nodes that cannot be contracted into any component as above are treated as singleton, i.e., mapped to themselves by f C .

Example 2
Assume that timestamp threshold t 0 for graph G of Fig. 1a is larger than timestamps of nodes i 1 , n 1 , f 1 and l 1 , but is smaller than those of remaining nodes. Algorithm GCon works as follows.
(1) It first triggers bounded BFS, and contracts i 1 , n 1 , f 1 and l 1 into an obsolete component v H 1 in G c . (2) Since G is a social network, it contracts clique, star, diamond, butterfly and path in this order. (3) It builds a clique v H 2 with nodes k 1 , …, k 5 . (4) It picks u 10 and u 5 as central nodes for a star, and makes a star v H 3 consisting of u 6 , u 7 , u 8 , u 9 , u 10 . Nodes u 5 , u 1 , u 3 cannot make a star due to lower bound k l = 4. (5) No diamond exists. (6) It picks u 5 as central node for a butterfly and makes a butterfly v H 4 . (7) It finds k 7 , k 8 and k 9 as candidate intermediate nodes for paths, and contracts them into a path v H 5 with endpoints k 6 and t 1 . (8) Node t 2 is left as a singleton, and is mapped to itself by f C .
Range [k l , k u ]. We contract an (obsolete/topological) component H such that the number of its nodes is in the range [k l , k u ]. The reason is twofold. (1) If H is too small, a contracted graph would have an excessive number of supernodes; this leads to over-contraction with high overhead for possible decontraction and low contraction ratio. Thus, we set a lower bound k l . (2) We set an upper bound k u to avoid overlarge components and excessive superedge decontraction. We experimentally find that the best k l and k u are 4 and 500, respectively.
Diamonds, butterflies and claws have a fixed size with 4, 5 and 4 nodes, respectively, in the range above.

Properties.
Observe the following about the contraction scheme. (1) It is lossless and is able to compute exact query answers. (2) It is generic and supports multiple applications on the same contracted graph at the same time. This is often necessary. For instance, on average 10 classes of queries run on a graph simultaneously in GDB benchmarks [32].
(3) It prioritizes up-to-date data by separating it from obsolete data. (4) It improves performance. (a) As discussed in

Parallel contraction algorithm
We next parallelize algorithm GCon, denoted by PCon, to speed up the contraction process. Note that contraction is conducted once offline, and is then incrementally maintained in response to updates (Sect. 4).
Parallel setting. Assume a master (processor) M 0 and n workers (processors) P 1 , . . . , P n . Graph G is partitioned into n fragments F 1 , . . . , F n by an edge-cut partitioner [17,55], and the fragments are distributed to n workers P 1 , . . . , P n , respectively. We adopt the BSP model [88], which separates iterative computations into supersteps and synchronizes states after each superstep.
Parallel contraction algorithm PCon. As shown in Fig. 4, the idea of PCon is to leverage data-partitioned parallelism. PCon first conducts GCon locally on each fragment in parallel, and then contracts uncontracted "border nodes," i.e., nodes with edges crossing fragments, by building neighbors of at most k u uncontracted nodes, referred to as uncontracted neighbors, which are subgraphs with uncontracted nodes.
More specifically, algorithm PCon works as follows.
(1) All workers run GCon on its local fragment in parallel (line 1), since after all, each fragment F i is a graph itself.
In contrast with single-thread GCon, workers do not contract mirror nodes, i.e., nodes assigned to other fragments with edges linked to the local fragment. Adopting edge-cut partition, each node of G is assigned to a single fragment and is contracted at most once during GCon.
(2) PCon contracts "border nodes" (line 2-3). For each border node v, if v is not contracted, PCon builds it uncontracted neighbors. Such neighbors are identified in parallel, coordinated by master M 0 .
(3) Master M 0 merges overlapped neighbors into one, and distributes disjoint ones to n workers (line [4][5]. In this way, PCon reduces communication cost and speeds up the process when contracting border nodes. (4) Each worker contracts its assigned uncontractedneighbors of border nodes, in parallel (line 6).
One can verify that each node v in G is contracted into at most one supernode v H . The graph G c contracted by PCon may be slightly different from that of GCon since border nodes may be contracted in different orders. One can fix this by repeating steps (1)-(4) for each of topological components following the order T (G). Nonetheless, we experimentally find that the differences are not substantial enough to worth the extra cost. Moreover, the contracted graphs of PCon are ensured compact, i.e., they cannot be contracted further.

Proof of concept
In this section, we show that existing query evaluation algorithms can be readily adapted to the contracted graphs. As a proof of concept, we pick five query classes: (1) graph pattern matching SubIso via subgraph isomorphism (labeled queries with locality); (2) triangle counting TriC (un-labeled queries with locality); (3) shortest distance Dist (un-labeled and non-local queries); (4) connected component CC (unlabeled queries without locality); and (5) clique decision CD (un-labeled queries with locality). Among these, subgraph isomorphism and clique decision are intractable (cf. [42]).
Informally, when answering a query Q ∈ Q, we check whether the synopsis S Q (v H ) at a supernode v H has enough information for Q; it uses S Q (v H ) directly if so; otherwise it decontracts superedges adjacent to v H or restores the subgraph of v H via decontraction function f D . As will be seen shortly, S Q (v H ) often provides enough information to process Q at v H as a whole or safely skip v H . Thus, it suffices to answer queries in the five classes by decontracting superedges, without decontracting any topological components.
The main result of this section is as follows.
Theorem 1 Using linear synopsis functions, (1) for each of SubIso and CD, there are existing algorithms that can be adapted to compute exact answers on contracted graphs G c , which decontract only supernodes of obsolete components and superedges between supernodes, not any topological components; (2) for TriC and Dist, there are existing algorithms that can be adapted to G c and decontract no supernodes, neither topological nor obsolete components; and (3) for CC, there are existing algorithms that can be adapted to G c and decontract neither supernodes (topological and obsolete) nor superedges.
Below we provide a constructive proof for Theorem 1 by adapting existing algorithms of the five query classes to contracted graphs one by one.

Graph pattern matching with contraction
We start with graph pattern matching (SubIso). Preliminaries. We first review basic notations.
We also investigate temporal patterns (Q, t), where Q is a pattern as above and t is a given timestamp.
To simplify the discussion, we consider connected patterns Q. This said, our algorithm can be adapted to disconnected ones. We denote by u, v pattern nodes in pattern Q, and by is an edge in graph G. We denote by Q(G) the set of all matches of pattern Q in graph G.
A match of a temporal pattern (Q, t) in graph G is a match G in Q(G) such that for each node v in G , T (v) > t, i.e., a match of (conventional) pattern Q in which all nodes have timestamps later than t. We denote by Q(G, t) all matches of (Q, t) in G.
The graph pattern matching problem, denoted by SubIso, is to compute, given a pattern Q and a graph G, the set Q(G) of matches. Similarly, the temporal matching problem is to compute Q(G, t) for a given temporal pattern (Q, t) and a graph G, denoted by SubIso t .
Note that (1) patterns Q are labeled, i.e., nodes are matched by labels. Moreover, (2) Q has the locality, i.e., for any match G of Q in G and any nodes v 1 , v 2 in G , v 1 and v 2 are within d Q hops when treating G as undirected.
Here d Q is the diameter of Q, i.e., the maximum shortest distance between any two nodes in Q.
The decision problem of pattern matching is NP-complete (cf. [42]); similarly for temporal matching. A variety of algorithms have been developed for SubIso, notably TurboIso [44] with indices and VF2 [28] without index. Both TurboIso and VF2 can be adapted to contracted graphs as characterized in Theorem 1.
We give a constructive proof for TurboIso, because (1) it is one of the most efficient algorithms for subgraph isomorphism and is followed by other SubIso algorithms e.g., [14,78], and (2) it employs indexing to reduce redundant matches; by adapting TurboIso we show that the indices for SubIso can be inherited by contracted graphs, i.e., contraction and indexing complement each other. The same algorithm works for temporal matching. The proof for VF2 is simpler (not shown).
Below we first present synopses for SubIso (Sect. 3.1.1), which are the same for both VF2 and TurboIso. We then show how to adapt algorithm TurboIso to contracted graphs (Sect. 3.1.2)

Contraction for SubIso
Observe that topological components have regular structures. The idea of synopses is to store the types and key features of regular structures so that we could check pattern matching without decontracting any supernodes of topological components.
The synopsis of a supernode v H for query class SubIso is defined as follows: , the largest timestamp of its nodes.
Node labels are stored in the reverse function f c of the contraction function f c (see Sect. 2.1).
For instance, the synopsis S SubIso (v H ) for each supernode v H in the contracted graph G c of Fig. 1b is given in Fig. 1d. Note that S SubIso only stores the synopses of the regular structures contracted in a graph. Properties. The synopses in S SubIso have two properties. (1) Taken with the reverse function f C of f C , the synopsis of a supernode v H suffices to recover topological component H contracted to v H . For instance, given the central node and leaf nodes, a star can be uniquely determined. As a result, no supernode decontraction is needed for topologi- We remark that the design of synopses needs domain knowledge. This said, (1) users only need to develop synopses for their applications in use, not exhaustively for all possible query classes; and (2) synopsis design is no harder than developing indexing structures.

Subgraph isomorphism
Below we first review algorithm TurboIso [44] and then show how to adapt TurboIso to contracted graphs. TurboIso. As shown in Fig. 5, given a graph G and a pattern Q, TurboIso computes Q(G) as follows. It first rewrites pattern graph Q into a tree Q by performing BFS from a start vertex v s (lines 1-2). Here each vertex in Q is a neighborhood equivalence class (NEC) that contains pattern nodes in Q having identically matching data vertices. Then, for each start vertex x s of each region, TurboIso constructs a candidate region (C R 0 ), i.e., an index that maintains candidates for each NEC vertex in Q , via DFS from x s (lines 3-4). If valid candidates are found, i.e., C R 0 = ∅, TurboIso enumerates all possible matches that map x s to v s following a matching order O (lines 5-6). The matching order O is decided by sorting the leaf NEC vertices based on the number of their candidate vertices. It expands Q(G) with valid matches identified in the process (line 7).
Algorithm SubA c . TurboIso can be easily adapted to contracted graph G c , denoted by SubA c . As shown in Fig. 6, SubA c adopts the same logic as TurboIso except minor adaptations in ExploreCR (line 4) and SGSearch (line 7) to deal with supernodes. To see these, let H be the subgraph contracted to a supernode v H .
(1) ExploreCR. It adds a supernode v H as a candidate for a node u in Q if some node in v H can match u, which is checked by S SubIso (v H ) and f C (v H ). It also prunes C R 0 based on v H .type, e.g., a node u in Q cannot match intermediate nodes on paths if u is in some triangle in Q; and u (2) SGSearch. Checking the existence of an edge (x, y) that matches edge (v x , v y ) ∈ Q is easy with synopses S SubIso and functions f C and f D . Here x (resp. y) denotes a node in supernode  Fig. 1c is to find potential friendship between users based on the retweet and shared keywords in their posted tweets. Nodes u and u both have the same label u. Given Q, SubA c first chooses k as the start node, to which only v H 2 and v H 5 can match. For v H 2 , ExploreCR adds v H 5 and t 2 as candidates for t and t , v H 3 as candidate for u, and v H 3 and v H 4 as candidates for u . Note that for obsolete supernode v H 1 , none of the labels in Q is covered by f C (v H 1 ); hence, v H 1 can be safely skipped. SGSearch finds that t 2 matches t since there exists no edge between v H 3 and v H 5 . Thus, it matches k, t, u, t , u with k 1 , t 2 , u 6 , t 1 , u 4 .

Example 3 Query Q in
Similarly for v H 5 , ExploreCR adds v H 5 and t 2 as candidates for t and t , v H 4 as candidate for u, and v H 3 and v H 4 for u and u . Next, SGSearch finds that u 4 and t 1 match u and t by decontracting superedge (v H 3 , v H 4 ); then, k 9 matches k. However, since k 9 is an intermediate node of path v H 3 , no match for t can be found. Hence, k, t, u, t , u match k 1 , t 2 , u 6 , t 1 , u 4 .
Analyses. One can easily verify that SubA c is correct since it has the same logic as TurboIso except that it incorporates pruning strategies. While they have the same worst-case complexity, SubA c operates on G c , much smaller than G (see Sect. 5); moreover, its ExplorCR saves traversal cost and SGSearch saves validation cost by pruning invalid matches. Temporal pattern matching. Algorithm SubA c can also take a temporal pattern (Q, t) as part of its input, instead of Q. The only major difference is at

Triangle counting with contraction
We next study triangle counting [26,47], which has been used in clustering [91], cycle detection [48] and transitivity [74]. In graph G, a triangle is a clique of three vertices. The triangle counting problem is to find the total number of triangles in G, denoted by TriC.
Similar to SubIso, TriC is local with diameter 1. In contrast, it consists of a single query and is not labeled.
We adapt algorithm TriA of [26] for TriC to contracted graphs, since it is one of the most efficient TriC algorithms [47], and it does not use indexing (as a different example from TurboIso). We show that for TriC, the adapted algorithm needs to decontract no supernodes, neither topological components nor obsolete parts.

Contraction for TriC
Observe that contraction function f C on G is equivalent to node partition of G, such that two nodes are in the same partition if they are contracted into the same supernode. The idea of synopses for TriC is to pre-count triangles with at least two nodes in the same partition, without enumerating them. As will be seen shortly, this allows us to avoid supernode decontraction for both topological and obsolete components.
Consider a triangle (u, v, w) in G that is mapped to G c via f C . We have the following cases.
( ( , when the three nodes of a triangle are contracted into different supernodes, we count such triangles online and it suffices to decontract only superedges, not supernodes. with an extra tag tc, which records the number of triangles pre-calculated as above. More specifically, v H .tc is computed as follows. Below we use u and v to range over nodes in V (H ), I to range over clique neighbors of u, and J to range over common neighbors of u, v. We define t I u , t H and t J u,v as above. In a clique H , there are (1) where u 1 and u |V (H )| are the first and last node on the path; Synopses S TriC also share the properties of S SubIso .

Example 4
In the contracted graph G c of Fig. 1b

Triangle counting
We now adapt algorithm TriA [26] to contracted graphs. The adapted algorithm is referred to as TriA c . Algorithm TriA. Given a graph G, TriA assigns distinct numbers to all the nodes in G. It then enumerates triangles for each edge (u, v) by counting the common neighbors w of u and v such that w < u and w < v. Algorithm TriA c . On a contracted graph G c with superedges decontracted, TriA c works in the same way as TriA except that at a supernode v H (for both topological and obsolete components), it simply accumulates v H .tc without decontraction or enumeration. It only restores superedges when necessary.
Example 5 From synopsis S TriC , TriA c directly finds 14 triangles. In G c , it finds two additional triangles (u 6 , t 2 , k 1 ) and (t 1 , t 2 , k 1 ) by restoring superedges. Thus, it finds 16 triangles in G. No supernodes of either topological or obsolete components are decontracted.
Analyses. One can verify that TriA c is correct since it counts all triangles in G once and only once. It speeds up TriA since it works on a smaller contracted G c . Temporal triangle counting. Algorithm TriA c can be adapted to count triangles with timestamp later than a given time t. It

Shortest distance with contraction
We next study the shortest distance problem. Shortest distance. Consider an undirected weighted graph G = (V , E, L, T , W ) with additional weight W ; for each edge e, W (e) is a positive number for the length of the edge. In a graph G, a path p The shortest distance problem, denoted by Dist, is to compute, given a pair (u, v) of nodes in G, the shortest distance between u and v, denoted by d(u, v) [4,25,31].
As opposed to SubIso, shortest distance queries are unlabeled, i.e., the value of a query answer d(u, v) does not depend on labels. In contrast with SubIso and TriC, Dist is non-local, i.e., there exists no d independent of the input graph G such that d(u, v) < d.
We adapt Dijkstra's algorithm [31] to contracted graphs, denoted by Dijkstra, which is one of the best known algorithms for Dist. Just like TriC, the adapted algorithm for Dist decontracts no supernodes, neither topological components nor obsolete parts.

Contraction for Dist
A path between nodes u and v can be decomposed into (1) edges between supernodes, and (2) edges within a supernode. The idea of synopses for Dist is to pre-compute the shortest distances within supernodes to avoid supernode decontraction, for both topological and obsolete components. Edges between supernodes are recovered by superedge decontraction when necessary.
Suppose that v 1 and v 2 are nodes mapped to supernode 1 , v 2 )) for a path between v 1 and v 2 within v H , based on v H .type: , it records the path itself; • diamond, butterfly and obsolete components: In practice, the number of nodes in most contracted subgraphs is far below the upper bound k u . Indeed, diamonds and butterflies have a constant size, and we find that a clique (resp. star, path and obsolete component) typically contains 6.5 (resp. 7.3, 4.1 and 49.2) nodes. Hence, the size of a synopsis is fairly small. Note that the upper bound k u should be larger than typical sizes of components, since large components exist and may be more powerful for accelerating computations.

Shortest distance
We adapt algorithm Dijkstra [31] to contracted graphs G c , and refer to the adapted algorithm as DisA c . Algorithm Dijkstra. Given a graph G and a pair (u, v) of nodes, Dijkstra finds the shortest distances from u to nodes in G in ascending order, and terminates as soon as d(u, v) is determined. It maintains a set S of nodes whose shortest distances from u are known; it initializes distance estimates d(u) = 0, and d(w) = ∞ for other nodes. At each step, Dijkstra moves a node w from V \ S to S that has minimal d(w), and updates distance estimates of nodes adjacent to w accordingly. Algorithm DisA c . DisA c is the same as Dijkstra except minor changes to updating distance estimates. When moving a node w from V \ S to S, suppose that v H is the supernode to which w is mapped, i.e., f C H (w, w ) for the other endpoint w using v H .dis; in these cases, no supernode (for topological or obsolete components) is decontracted.
) at worst, in the same way as Dijkstra.
Analyses. By induction on the length of shortest paths, one can verify that DisA c is correct. In particular, for each node w in G, when d(w ) is updated by a node w that is mapped to the same supernode, the update is equivalent to a series of Dijkstra updates. Moreover, DisA c works on smaller contracted graphs G c and saves traversal cost inside contracted components without any decontraction, neither topological nor obsolete. Temporal shortest distance. Similar to temporal SubIso and TriC, we study temporal Distqueries (u, v, t), where (u, v) is a pair of nodes as in Dist, and t is a timestamp. It is to compute the shortest length of paths p from u to v such that for each node w on p, T (w) > t.
Algorithm DisA c can be easily adapted to temporal Dist, by skipping nodes v with T (v) ≤ t. In particular, it safely

Connected component with contraction
We next study the connected component problem [29,85]. In a graph G, a connected component is a maximal subgraph of G in which any two nodes are connected to each other via a path. The connected component problem, denoted as CC, is to compute the set of pairs (s, n) for a given graph G, where (s, n) indicates that there are n connected components in G that consist of s nodes.
Given a graph G, CC returns the numbers of connected components of various sizes in G. Similar to Dist, CC is a non-local query, i.e., it has to traverse the entire graph when answering the query. It is also un-labeled, i.e., labels have no impact on its query answer.
We adapt algorithm CCA of [85] for CC to contracted graphs, since it is one of the most efficient CC algorithms. Better still, we show that the adapted algorithm decontracts neither supernodes nor superedges.

Contraction for CC
The synopsis S SubIso for SubIso suffices for us to answer CC queries. Observe that each subgraph H contracted to a supernode v H is connected, no matter whether H is a topological component or an obsolete component. We can regard a supernode v H as a whole when evaluating CC queries, and leverage S SubIso (v H ) and f C to compute the size of connected components. We need neither additional synopses nor any decontraction.

Connected component
We now adapt algorithm CCA [85] to contracted graphs. The adapted algorithm is referred to as CCA c . Algorithm CCA. We first review how CCA works.  Fig. 1b

Clique decision with contraction
We next study a decision problem for clique. A clique in a graph G is a subgraph C in which there are edges between any two nodes; it is a k-clique if the number of nodes in C is k (i.e., |V (C)| = k) . We consider the clique decision problem [20,57], denoted by CD, to find whether there exists a k-clique in G for a given number k. CD is being widely used in community search [76], team formation [59] and anomaly detection [11,65].
Similar to Dist and CC, CD is un-labeled. In contrast with Dist and CC, but similar to SubIso, it is local, i.e., all nodes in a clique are within 1 hop of each other.
The clique decision problem is known NP-complete (cf. [42]). A variety of algorithms have been developed for CD, notable CDA of [57], which we will adapt next.

Contraction for CD
Observe the following. (1) Cliques in G contracted into supernodes in G c can help us find an initial maximum clique (see below). (2) The degree of a node can be used as an upper bound of the maximum clique containing it.
In light of these, we extend synopsis S SubIso (v H ) with tags cs and md. For a subgraph H that is contracted to a supernode v H , the two tags record the maximum clique found in H and the maximum degree of the nodes in H , respectively. Specifically, v H .cs is based on v H .type: • diamond and butterfly: v H .cs = 3; • star, path and claw: v H .cs = 2; and • obsolete component: we find a k-clique in an obsolete component online.
and v H .md is by aggregation: Synopses S CD also share the properties of S SubIso .

Example 9
In the contracted graph G c of Fig. 1b

Clique decision
We adapt CDA [57] to G c , denoted as CDA c . Algorithm CDA. We first review CDA. Given a graph G, algorithm CDA checks the existence of a k-clique in G by branch-and-bound. It branches from each node in G. Denote by C the current clique in the search, and by P the set of common neighbors of the nodes in C. CDA (1) bounds the search from C if |C| + |P| < k, or (2) branches from each node u in P to expand C. More specifically, it iteratively adds a node u from P to C and removes all those nodes in P that are not neighbors of u, enlarging C and shrinking P until P is empty. Note that CDA c initiates the search with the largest clique contracted, by checking the synopses. Hence, cliques play a more important role than the other regular structures for CD.

Example 10
For query with k = 5, by S CD (v H 2 ) of Fig. 1b, CDA c finds a 5-clique and returns true. For query with k = 6, all supernodes except v H 2 are skipped by synopses. Their adjacent superedges are skipped as well. Since v H 2 only contracts a 5-clique, CDA c fails to find a 6-clique and returns false.
Analyses. One can verify that CDA c is correct since it follows the same logic as CDA except that it adopts pruning strategies that are possible because of the use of synopses. While the two algorithms have the same worst-case complexity, CDA c starts with a supernode with a maximum clique and may find a k-clique directly; moreover, it skips a supernode as a whole by synopses, which reduces unnecessary search and validation. Temporal k-clique. Algorithm CDA c can be adapted to find a k-clique with timestamp later than a given time t, by skipping nodes v with T (v) ≤ t. Like SubA c and TriA c , it safely ignores a supernode v H if v H .t ≤ t.

Incremental contraction
We next develop an incremental algorithm to maintain contracted graphs in response to updates G to graphs G. We start with batch update G, which is a sequence of edge insertions and deletions. We formulate the problem (Sect

Incremental contraction problem
Updates to a graph G, denoted by G, consists of (1) node updates, i.e., node insertions and deletions; and (2) edge updates, i.e., edge insertions and deletions.
Given a contraction scheme f C , S, f D , a contracted graph G c = f C (G), and updates G, the incremental contraction problem, denoted as ICP, is to compute (a) changes G c to G c such that G c ⊕ G c = f C (G ⊕ G), i.e., to get the contracted graph of the updated graph G ⊕ G, where G c ⊕ G c applies G c to G c ; (b) the updated synopses of affected supernodes; and (c) functions f C ⊕ f C and ICP studies the maintenance of contracted graphs in response to update G that may both change the topological structures of contracted graph G c , and refresh timestamps of nodes. As a consequence, obsolete nodes may be promoted to be non-obsolete ones if they are touched by G, among other things. Criterion. Following [77], we measure the complexity of incremental algorithms with the size of the affected area, denoted by AFF. Here AFF includes (a) changes G to the input, (b) changes G c to the output, and (c) edges with at least an endpoint in (a) or (b).
An incremental algorithm is said to be bounded [77] if its complexity is determined by |AFF|, not by the size |G| of the entire (possibly big) graph G.
Intuitively, G is typically small in practice. When G is small, so is G c . Hence, when G is small, a bounded incremental algorithm is often far more efficient than a batch algorithm that recomputes G c starting from scratch, since the cost of the latter depends on the size of G, as opposed to |AFF| of the former.
An incremental problem is said to be bounded if there exists a bounded incremental algorithm for it, and it is unbounded otherwise. Challenges. Problem ICP is nontrivial. (1) Topological components are fragile. For instance, when inserting an edge between two leaves of a star H , H is no longer a star, and its nodes may need to be merged into other topological components. (2) Refreshing timestamps by a query Q may make some obsolete nodes "fresh" and force us to reorganize obsolete and topological components. (3) When contracted graph G c is changed, so are their associated synopses and decontraction function. Main result. Despite challenges, we show that bounded incremental contraction is within reach in practice.

Theorem 2 Problem ICP is bounded for SubIso, TriC, Dist, CC and CD, and takes at most O(|AFF| 2 ) time.
We first give a constructive proof of Theorem 2 for edge updates, consisting of two parts: (1) the maintenance of the contracted graph G c and its associated decontraction function f D (Sect. 4.2); and (2) the maintenance of the synopses of affected supernodes (Sect. 4.3). We then give a constructive proof of Theorem 2 for vertex updates (Sect. 4.4), which is simpler.

Incremental contraction algorithm
An incremental algorithm is shown in Fig. 7, denoted by IncCR. It has three steps: preprocessing to initialize affected areas, updating to maintain contracted graph G c , and contracting to process refreshed singleton nodes. To simplify the discussion, we focus on how to update G c in response to G, where G consists of edge insertions and deletions; the handling of f D is similar. (a) Preprocessing. Algorithm IncCR first identifies an initial area affected by edge update G (lines 1-2). It removes "unaffecting" updates from G that have no impact on G c (line 1), i.e., edges in G that are between two supernodes when none of their nodes is an intermediate node of a path. These updates are made to corresponding subgraphs of G that are maintained by f D . It then refreshes timestamps of nodes u touched by edges e = (u, v) in G (line 2). Suppose that node u is mapped by f C to supernode v H with v H .type = obsolete. Then, v H is decomposed into singleton nodes, u is non-obsolete and is mapped to itself by f C . Such singleton nodes are collected in a set V s , as the initial area affected by G. Node v is treated similarly. Note that an unaffecting update would not become "affecting update" later on. All changes in G are applied to graph G in the given order.  = (u, v), IncCR invokes procedure IncCR + (resp. IncCR − ) to update G c when e is to be inserted (resp. deleted) (lines 4-7). Updating G c may make some updates in G unaffecting, which are further removed from G (line 8). Moreover, some nodes may become "singleton" when a topological component is decomposed by the updates, e.g., leaves of a star. It collects such nodes in the set V s .
More specifically, to insert an edge e = (u, v), IncCR + updates G c and adds new singleton nodes to V s . Suppose that u (resp. v) is mapped by f C to supernode v H 1 (resp. v H 2 ) (line 1). IncCR + decomposes v H 1 and v H 2 into the regular structures of topological components (line 2). For instance, if v H 1 = v H 2 , and v H 1 .type =star, u and v make a triangle with the central node; thus, IncCR + decomposes the star into singleton nodes. When v H 1 .type = clique and v H 2 .type = path, supernode v H 2 is divided into two shorter paths. Note that components with less than k l nodes due to updates are decomposed into singleton nodes. All such singleton nodes are added to the set V s (line 3).
(c) Contracting. Finally, algorithm IncCR processes nodes in the set V s (line 10). It (a) merges nodes into neighboring supernodes; or (b) builds new components with these nodes, if possible; otherwise (c) it leaves node v as a singleton, i.e., by letting f C (v) = v.

Example 11
Consider inserting four edges into graph G of Fig. 1a: (1) (n 1 , f 1  The algorithm is (a) bounded [77], since its cost is determined by |AFF| alone, and (b) local [35], i.e., the changes are confined only to affected supernodes and their neighbors in the contracted graph G c .

Maintenance of synopses
We next show that for SubIso, TriC, Dist, CC and CD, (a) the number of supernodes whose synopses are affected is at most O(|AFF|), and (2) More specifically, (1) for edge insertion (n 1 , f 1 ), supernode v H 1 is decomposed into four singletons, for which synopses are defined as n 1 .tc = f 1 .tc = l 1 .tc = i 1 .tc = 0.

Vertex updates
Vertex updates are a dual of edge updates [58], and can be processed accordingly. More specifically, we present incremental algorithm IncCR V in Fig. 8, to deal with vertex updates. Consider node insertions and deletions.
(1) When inserting a new node u, algorithm IncCR V first treats u as a singleton and collects it in set V s (lines 3-4); the node u is then contracted into a topological structure in the contracting step (line 7).
(2) When deleting a node u that is contracted into a supernode v H , there are three cases to consider, elaborated in IncCR − V of Fig. 8: (a) if v H is a clique, v H remains unchanged except that u is removed (lines 2-3); (b) if v H is a claw, a butterfly or an obsolete component, v H is decontracted and all nodes in f C (v H ) except u are treated as singletons and are collected in set V s (lines 4-5); and (c) otherwise, we process u and v H by synopsis and add resulting singleton nodes into V s (lines 6-7). For instance, consider the case when v H contracts a star, (i) if u is the central node v H .c, v H is decontracted in the same way as case (b); and (ii) otherwise, v H remains to be a star, similar to case (a).
Similar to edge updates, contracting singleton nodes of V s into topological components dominates the cost of the process. One can verify that it can be done in at most O(|AFF| 2 ) time. Similarly, synopsis maintenance also takes O(|AFF| 2 ) time. Hence, incremental contraction remains bounded in the presence of vertex updates.

Parallel incremental contraction algorithm
We parallelize incremental algorithm IncCR, to speed up the incremental maintenance process. Parallel setting. Similar to PCon, we use a master M 0 and n workers, A contracted graph G c is edge-partitioned and is distributed to n workers. Each fragment F i consists of a part of the contracted graph G c and its corresponding (partial) decontraction function and synopses. For a crossing superedge (v H 1 , v H 2 ) between two fragments, i.e., when v H 1 and v H 2 are assigned to two distinct fragments, the decontraction function f D (v H 1 , v H 2 ) is maintained in both fragments. Parallel incremental contraction. The parallel incremental algorithm is denoted by IncPC and shown in Fig. 9. To simplify the discussion, we focus on edge updates; node updates are processed similarly. It works under BSP [88]. In a nutshell, it preprocesses crossing (super)edges (line 1). Then, all the workers run IncCR on its local fragment in parallel (line 2). After that, IncPC contracts refreshed singleton nodes V s into supernodes (lines 3-8) along the same lines as algorithm PCon. Here, each fragment has its local set V s and all refreshed singleton nodes in V s can be coordinated and distributed by the master M 0 . Each node v is guaranteed to be contracted into one supernode v H . More specifically, algorithm IncPC works as follows.
(1) IncPC preprocess updated edges e = (u, v) between two fragments (line 1), i.e., when u and v are contracted into supernodes v H 1 and v H 2 , and v H 1 and v H 2 are in two distinct fragments. Such updates are unaffecting as long as neither u nor v is an intermediate node of a path, and these updates are maintained by f D . Otherwise, the supernode of type path may be affected and is decomposed into singleton nodes; such refreshed singleton nodes are collected in a set V s as the initial area affected by G. In the same way as IncCR, we refresh timestamps of obsolete nodes touched by updates.
(2) Each worker locally runs IncCR in parallel (line 2). Refreshed singleton nodes that cannot be contracted into supernodes are collected in V s (line 3).
(3) For each refreshed singleton node v in V s , IncPC build its uncontracted neighbors (of at most k u nodes) in parallel, similar to step (2) in PCon (lines 4-5).
(4) Master M 0 merges overlapped neighbors into one and distributes disjoint ones to n workers (lines 6-7).
One can verify that each node v in G is contracted into one supernode v H (including v itself), and the contracted graph G c cannot be further contracted.

Experimental study
Using ten real-life graphs, we experimentally evaluated (1) the contraction ratio; (2) the speedup of the contraction scheme; (3) the impact of contracting each topological component and obsolete component; (4) the space cost of the contraction scheme compared to existing indexing methods; (5) the efficiency of the (incremental) contraction algorithms; and (6) the parallel scalability of the (incremental) contraction algorithms. Experiment setting. We used the following datasets.
We also generated synthetic graphs with up to 250 M nodes and 2.5 B edges, to test the parallel scalability of the (incremental) contraction algorithms. Updates. We randomly generated edge updates G, controlled by the size | G| and a ratio ρ of edge insertions to deletions. We kept ρ = 1 unless stated otherwise, i.e., the size of G ⊕ G remains stable. In the same manner, we generated vertex updates G.
(2) Graph patterns. We implemented a generator for graph pattern queries controlled by three parameters: the number V Q of pattern nodes, the number E Q of pattern edges, and a set L Q of labels for queries Q.
(3) Implementation. We implemented the following algorithms, all in C++.   [57] for CD. We did not compare with summarization since it does not support any algorithm to compute exact answers for the five applications.
(4) Experimental environment. The experiments were conducted on a single-processor machine powered by Xeon 3.0 GHz with 64GB memory, running Linux. Since GSH and synthetic graphs ran out of 32 GB memory without contraction, we used a machine with 64 GB memory. For parallel (incremental) contraction, we used 4 machines, each with 12 cores powered by Xeon 3.0 GHz, 32GB RAM, and 10Gbps NIC. Each experiment was run 5 times, and the average is reported here. Experimental results. We now report our findings. Exp-1: Effectiveness: Contraction ratio. We first tested the contraction ratio of our contraction scheme, defined as C R = |G c |/|G|. Note that for each query class Q, C R is the same for all queries in Q. Moreover, all applications on G share the same contracted graph G c while incorporating different synopses. In addition, we report the impact of each of the first three topological components and obsolete component for each dataset, in the presence and absence of obsolete data. As remarked in Sect. 2, we limit the nodes of contracted subgraphs within [k l , k u ]. We fixed k l = 4 and varied k u based on the size of each graph. We considered two settings: (a) when obsolete data are taken into account, with threshold t 0 = 50%t m , where t m denotes the maximum timestamp in each dataset; and (b) when we do not separate obsolete data, i.e., when t 0 = 0. The results are reported in Table 2 for all the real-life graphs (in which each column indicates either C R or percentage of contribution to C R with/without obsolete mark). We can see the following.
(1) When t 0 = 50%t m , C R is on average 0.281, i.e., contraction reduces these graphs by 71.9%. When t 0 = 0, i.e., if obsolete data are not considered, C R is 0.435. These show that real-life graphs can be effectively contracted in the presence and absence of obsolete data. Compared with the results of [38], by considering more regular structures, the contraction scheme improves the contraction ratio C R by 2.49% and 6.90% in the presence and absence of obsolete data, respectively.
(2) When obsolete data are present, the average C R is 0.34, 0.264, 0.213 and 0.365 in social networks, Web graphs, collaboration networks and road networks, respectively. When obsolete data are absent, C R is on average 0.488, 0.409, 0.356 and 0.59. The contraction scheme performs the best on collaboration networks in both settings, since such graphs exhibit evident inhomogeneities and community structures.
(3) When obsolete data are absent, on average the first three regular structures contribute 50.2%, 39.4% and 8.0% to CR, respectively. When obsolete mark is taken into account, their contribution is 18.3%, 14.9% and 2.8%, respectively. This is because nodes from these components may be moved to obsolete components.
(4) We also studied the impact of the contraction order on query evaluation. Topological components have different impacts on different types of graphs, e.g., stars, claws and paths are effective in Traffic, and cliques, stars and butterflies work better than the others in collaboration networks. Taking the order of Table 1 as the baseline, we tested the impact of (a) RE, by reversing the order, and (b) EX, by exchanging between different types of graphs, e.g., we use the order for road networks to contract social graphs. On average the CR of RE and EX is decreased by 9.42% and 7.05%, respectively. As shown in Table 3, the average slowdown of RE and EX is (a) 7.24% and 5.58% for SubIso, (b) 5.55% and 5.46% for TriC, (c) 3.89% and 4.30% for Dist, (d) 7.34% and 34.7% for CC, and (e) 2.38% and 19.1% for CD, respectively. These justify that the order of Table 1 is effective for most applications and most types of graphs. There are also exceptions, e.g., reversing the order for Web graphs improves the efficiency of CD. Recall that we contract stars, cliques and butterflies for Web graphs. For CD in particular, however, cliques play a more important role than the other two (Sect. 3.5); hence, contracting cliques first may work better for CD. Exp-2: Effectiveness: query processing. We next evaluated the speedup of query processing introduced by the contraction scheme, measured by query evaluation time over original and contracted graphs. Subgraph isomorphism. Varying the size |V Q | of pattern queries from 4 to 7, we tested VF2, TurboIso and TurboIsoBoosted on GSH and Hollywood as G, DeDense [69] on the compressed graph, and SubA c and VF2 c on the contracted graph G c of G. For each query, we output the first 10 8 matches. As shown in Fig. 10a, b, (1) on average, SubA c on G c is1.69, 1.49 and 18.85 times faster than TurboIso, TurboIsoBoosted and DeDense, respectively; (2) VF2 c beats DeDense by 9.31 times; (3) VF2 c without indices is only 19.1% slower than TurboIso with indices, while TurboIsoBoosted and TurboIso are 10.1 and 8.97 times faster than VF2, respectively; and (4) the speedup is more substantial on collaboration networks, e.g., 2.11 times on Hollywood, because cliques are prevalent in such graphs and are the most effective structure for SubIso due to the high capacity in pruning invalid matches. Triangle counting. As shown in Fig. 10c, the results for TriC are consistent with the results on subgraph isomorphism: (1) TriA c on the contracted G c is on average 1.44 times faster than TriA on their original graphs G. (2) The speedup is more evident in collaboration networks: e.g., TriA c on Hollywood is 1.57 times faster than TriA while it is 1.47, 1.45 and 1.28 times on LiveJournal, Google and Traffic, respectively. TriA spends more than 1000 seconds on GSH (hence not shown). Shortest distance. The results for Dist are consistent with the results on SubIso. As reported in Fig. 10d, DisA c is 1.64 and 1.36 times faster than Dijkstra on GSH and Hollywood, respectively, by reducing search space and employing synopses. PLL could not build indices on GSH within 64G memory, while PLL c successfully builds indices on (smaller) contracted GSH. On average, PLL c spends 94.2μs to evaluate a query on GSH. On other smaller datasets, in contrast, PLL c is 18% slower than PLL due to overhead on supernodes. Connected component. As shown in Fig. 10e over LiveJournal, GSH, Hollywood, and Traffic for social graphs, Web graphs, collaboration networks and road networks, respectively, the results for CC are consistent with the results on SubIso and TriC: (1) algorithm CCA c on contracted graph G c is on average 2.24 times faster than CCA on the original graph G, since CCA c operates on the smaller G c without decontracting supernodes or superedges. (2) The speedup is more evident in collaborations networks: e.g., CCA c on Hollywood is 2.87 times faster than CCA, since the contraction scheme performs the best on such graphs and the time complexity of CCA c is linear in the size of the contracted graph. Clique decision. As also shown in Fig. 10f, (1) algorithm CDA c is 1.32, 1.54, 1.52 and 1.08 times faster than CDA on LiveJournal, Hollywood, GSH and Traffic, respectively, by using synopses to start with an initial maximum clique that may find a k-clique directly. (2) The speedup is less evident in road networks. For road networks, the contraction scheme contracts stars, claws and paths into supernodes; hence, we can only find a 2-clique (an edge) as the initial maximum clique by using synopses, which is trivial and useless.
The results on the other graphs are consistent. Temporal queries. Fixing pattern size |Q| = 4 and varying timestamp t in temporal queries from 30%t m to 70%t m , we tested SubIso t , TriC t , Dist t , CC t and CD t . As shown in Fig. 10g-k   The speedup is larger for temporal queries than for conventional ones since temporal information maintained in synopsis provides additional capacity to skip more supernodes, as expected. (4) It is more substantial for larger t on SubIso t .
The results verify that our contraction scheme (a) is generic and speeds up evaluation for all five applications, and (b) it can be used together with existing algorithms, with indexing (e.g., TurboIso and PLL) or not (e.g., VF2 c and Dijkstra). (c) It is effective by separating up-to-date data from obsolete.
We remark that our contraction scheme aims to make a generic optimization for multiple applications to run on the same graph at the same time. When a new application is considered, adding a specific synopsis suffices for our scheme. In contrast, a separate indexing structure has to be built for indexing approaches. Better still, it is much easier to develop synopses than indices. Moreover, existing indexing structures can be inherited by contracted graphs, to improve performance from contraction in addition to from indexing.  15.9% and 0.7% for CD, respectively. In particular, the impact of each regular structure is mostly consistent with the contraction order. This said, for specific application and graphs, the impact of each regular structure may be slightly different. For CD on Web graphs, the average slowdown in evaluation time by disabling the first structure (star) and the second structure (clique) is 4.1% and 43.5%, respectively, since cliques dominate the effectiveness of the synopses for CD. Impact of obsolete components. We tested the impact of contracting obsolete components on the efficiency of answering conventional queries. Fixing |Q| = 4 and varying x for timestamp threshold such that t 0 = x%t m , Fig. 10i-p reports the results of SubIso, TriC, Dist, CC and CD on LiveJournal, respectively. We find that (1) the speedup is bigger for larger t 0 when t 0 ≤ 70%, i.e., more nodes are contracted into obsolete components; (2) obsolete components speed up SubIso, TriC, Dist, CC and CD by 1.56, 1.53, 1.39, 2.49 and 1.33 times, respectively; and (3) the speedup for SubIso and CD gets smaller when t 0 ≥ 80% due to the overhead of decontracting obsolete components. The results are consistent for Dist, TriC and CC, except that their speedup does not go down when t 0 gets larger since they do not need to decontract obsolete components.
Impact of k l and k u . We also tested the impact of k l and k u on the contraction ratio CR and efficiency. As remarked in Sect. 2.3, diamonds, butterflies and claws have a fixed size, while cliques, stars and paths vary. Fixing k u = 500 (resp. k l = 4) and varying k l (resp. k u ) from 2 to 6 (resp. 20 to 1000), Fig. 10q (resp. Fig. 10r) reports the C R on LiveJournal, Hollywood, GSH and Traffic, respectively. As shown there, CR decreases when k l decreases or k u increases. Similarly, Fig. 10s (resp. Fig. 10t) reports the speedup of SubA c , TriA c , DisA c , CCA c and CDA c on Hollywood. Query evaluation is slowed down when k l ≤ 3 or k u ≥ 500 for all algorithms except CCA c and TriA c due to excessive superedge decontractions or overlarge components. Recall that CCA c decontracts neither supernodes nor superedges, and TriA c precalculates triangles in both topological components and obsolete parts; hence, it prefers large k u . We find that the best k l and k u for the datasets tested are around 4 and 500, respectively.
The results on the other graphs are consistent. Exp-4: Space cost. We next studied the space cost of our contraction scheme compared with indexing cost. We consider six algorithms: SubA c , TriA c , DisA c , CCA c , CDA c and PLL c . The space cost includes the sizes of the contracted graph |G c |, decontraction function | f D | and the sizes of synopses; as shown in Sect. 3, SubA c , TriA c , DisA c , CCA c and CDA c do not need to decontract topological components; thus, we only uploaded f D for obsolete components and superedges into memory. In particular, CCA c requires no decontraction (Theorem 1) and thus incurs no cost for storing f D at all. We compared the space cost with the indices used by TurboIso, HINDEX [75], PLL [4] and RMC [68]. Table 5 shows how the space cost increases when more applications run on Google (i.e., graph G). We find the following. (1) Our contraction scheme takes totally 1.62GB for SubIso, TriC, Dist, CC and CD, much smaller than 12.9GB taken by TurboIso, PLL, HINDEX and RMC. (2) With the contraction scheme, graph G is no longer needed. That is, To inherit the indexing structures of [44] and PLL, we use 1.14GB additional space to build a compact index for PLL c and on average 26MB for SubA c on Google. in addition to synopses S Dist and S SubIso .
To verify the scalability with applications, we further adapted existing algorithms for k-nearest neighbors (kNN) [92]. The total space cost of the scheme for the six applications is 1.75GB, i.e., 18.1% increment for each. It accounts for only 9.0% of the indices for TurboIso, PLL, HINDEX, RMC and Antipole [22] of kNN. Exp-5: Efficiency of (incremental) contraction. We next evaluated the efficiency of contraction algorithm GCon and incremental contraction algorithm IncCR. We also studied the impact of the order and varied rates of updates on incremental IncCR. Efficiency of GCon. We first report the efficiency of GCon. As shown in Fig. 11a-d on LiveJournal, Hollywood, GSH and Traffic, respectively, (1) on average GCon takes 109.7s to contract the graph, without the time of the computation for synopses. (2) It takes on average 4.13s, 21.2s, 18.1s, 0s and 3.38s only to compute the synopses for SubIso, TriC, Dist, CC and CD, respectively; i.e., computing synopses of the five only takes on average 37.3% of the time of GCon. Recall that the synopses for SubIso suffice for us to answer CC queries; hence, it is unnecessary to compute synopses for CC.
Efficiency of IncCR. We tested the efficiency of IncCR, by varying | G| from 5%|G| to 35%|G|. As shown in Fig. 11eh on LiveJournal, Hollywood, GSH and Traffic, respectively, (1) on average IncCR is 2.1 times faster than GCon, up to 6.3 times when | G| = 5%|G|. It takes on average 26.6% time to update the synopses for 5% updates on the five applica-tions. (2) IncCR beats GCon even when | G| is up to 30%|G|. This justifies the need for incremental contraction. (3) IncCR is sensitive to | G|; it takes longer for larger | G|. Impact of update order. We tested the impact of the orders of edge insertions and deletions in G on IncCR. Fixing | G| = 10%, we varied the order of updates by (1) random (RO), (2) insertion-first (IF) and (3) deletion-first (DF). On average we find that RO, IF and DF have a performance difference less than 3.5% on Hollywood. That is, IncCR is stable on batch updates, regardless of the order on the updates. Similarly, we find that RO, IF and DF have a performance difference less than 3.7% on Hollywood for vertex updates. Impact of update rates. We also tested the efficiency of IncCR against real-time updates, measured by the updates coming in 1s intervals, i.e., | G|/s. Varying | G|/s from 0.2%|G|/s to 1%|G|/s, Fig. 11i shows the following on LiveJournal.
(1) On average it takes 0.88s to update contracted graphs, i.e., IncCR is able to efficiently maintain the contracted graphs in real life. (2) The update time is less than 1s even when the updates are up to 0.8%|G|. IncCR can handle 0.8%|G|/s of "burst" updates on graph with 40M nodes and edges.
The results are consistent on the other graphs. Exp-6: Scalability. Finally, we evaluated (1) the scalability of our contraction algorithm GCon with graph size |G|, (2) the parallel scalability of algorithm PCon and IncPC with the number of cores. Scalability on |G|. Varying the size |G| = (|V |, |E|) of synthetic graphs from (50M, 0.5B) to (250M, 2.5B), we tested the scalability of GCon using a single machine. As shown in Fig. 11j, GCon scales well with G. It takes 1325s when graph G has 2.75B nodes and edges. Scalability of PCon and IncPC. Fixing | G| = 10%|G|, we tested the scalability of parallel PCon and IncPC with the number k of cores. As shown in Fig. 11k and l on GSH, (1) PCon scales well with k: it is 10.1 times faster when using k = 20 cores versus k = 1 (single core), and it is 4.3 times faster when k varies from 4 to 20. (2) IncPC is on average 1.9 times faster than PCon. (3) IncPC scales well with k; it is 3.7 times faster when k varies from 4 to 20, across 4 machines.
The results on other graphs are consistent. Summary. We find the following over 10 real-life graphs. On average, (1) the contraction scheme reduces graphs by 71 Fig. 11 Efficiency of (incremental) contraction by 1.64 and 1.78 times on average, respectively. (5) Its total space cost on SubIso, TriC, Dist, CC and CD is only 12.7% of indexing costs of TurboIso, PLL, HINDEX and RMC. The synopses for the five query classes take only 48.3% of the total space of the contraction scheme. Thus, our contraction scheme scales with the number of applications. (6) Algorithms GCon, PCon, IncCR and IncPC scale well with graphs and updates. GCon takes 344s when G has 1.8B edges and nodes, and PCon takes only 33.1s with 20 cores, across 4 machines. IncCR is 4.9 times faster than GCon when | G| is 5%|G|, and is still faster when | G| is up to 30%|G|. (7) PCon and IncPC scale well with the number k of machines. When | G| = 10%|G|, PCon is 4.3 times faster and IncPC is 3.7 times faster when k varies from 4 to 20.

Related work
This paper extends its conference version [38] as follows.
(1) We identify a variety of frequent regular structures in different types of graphs, develop their synopses and contract graphs based on their types (Sect. 2.2). In contrast, [38] adopts an one-size-fit-all solution and contracts only cliques, paths and stars for all types of graphs. . We also extend the algorithms for the three other cases to cope with newly studied topological components (Sects. 3.1-3.3). (5) We extend the study of incremental contraction by presenting vertex updates and parallel incremental maintenance algorithm (Sect. 4). (6) The experimental study is almost entirely new and evaluates the contraction scheme w.r.t. different regular structures to contract as well as its effectiveness on new big graphs and new query classes of Sects. 3.4 and 3.5 (Sect. 5). We discuss the other related work as follows. Contraction. As a traditional graph programming technique [43], node contraction merges nodes, and subgraph contraction replaces connected subgraphs with supernodes. It is used in e.g., single source shortest paths [54], connectivity [43] and spanning tree [41].
In contrast, we extend the conventional contraction with synopses to build a compact representation of graphs as a generic optimization scheme, which is a departure from the programming techniques. Compression. Graph compression has been studied for social network analysis [27], community queries [21], subgraph isomorphism [34,69], graph simulation [37], reachability and shortest distance [50], and GPU-based graph traversal [82]. It often computes query-specific equivalence relations by merging equivalent nodes into a single node or replacing frequent patterns by virtual nodes. Some are query preserving (lossless), e.g., [37,50,69], and can answer certain types of queries on compressed graphs without decompression.
Another category of compression aims to minimize the number of bits required to represent a graph. WebGraph [15] exploits the inner redundancies of Web graphs; [8] proposes an encoding scheme based on node indices assigned by the BFS order; [24] approximates the optimal encoding with MinHash; and [52] removes the hub nodes for an scheme to have better locality.
Our contraction scheme differs from graph compression in the following. (a) It optimizes performance of multiple applications with the same contracted graph. In contrast, many compression schemes are query dependent and require different structures for different query classes. While some methods serve generic queries [8,15,24], they may incur heavy recovering cost. (b) Contraction is lossless, while some compression schemes are lossy, e.g., [34]. (c) For a number of query classes, their existing algorithms can be readily adapted to contracted graphs, while compression often requires to develop new algorithms e.g., [69] demands a decompose-and-join algorithm for subgraph isomorphism. Summarization. Graph summarization aims to produce an abstraction or summary of a large graph by aggregating nodes or subgraphs (see [67] for a survey), classified as follows.
(1) Node aggregation, e.g., GraSS [60] merges node clusters into supernodes labeled with the number of edges within and between the clusters; it is developed for adjacency, degree and centrality queries. SNAP [87] generates an approximate summary of a graph structure by aggregating nodes based on attribute similarity. (2) Edge aggregation, e.g., [73] generates a summary by aggregating edges, with a bounded number of edges different from the original graph. (3) Simplification: instead of aggregating nodes and edges, OntoVis [83] drops low-degree nodes, duplicate paths and unimportant labels. Most summarization methods are lossy, e.g., GraSS and SNAP only retain part of attributes, and OntoVis drops nodes, edges and labels.
Incremental maintenance of summarization has been studied [30,46,84]. It depends on update intervals [84]; shortperiod summarization is space-costly, while long-interval summarization may miss updates. To handle these, [46] aggregates updates into a graph of "frequent" nodes and edges and computes a summary based on all historical updates on entire graph.
Both summarization and contraction schemes aim to provide a generic graph representation to speed up graph analyses. However, contraction differs from summarization in the following. (1) The contraction scheme is lossless and returns exact answers for various classes of queries. In contrast, summarization is typically lossy and supports at best certain aggregate or approximate queries only. (2) Many existing algorithms for query answering can be readily adapted to contracted graphs, while new algorithms often have to be developed on top of graph summaries. (3) For a number of query classes studied, contracted graphs can be incrementally maintained with boundedness and locality, while summarization maintenance requires historical updates and often operates on the entire graph [46]. Indexing. Indices have been studied for, e.g., subgraph isomorphism [13,14,28,44,72], reachability [7,23,50,95] and shortest distance [25,66]. They are query specific, and take space and time to store and maintain.
Our contraction scheme differs from indexing as it supports multiple applications on the same contracted graph, while a separate indexing structure has to be built for each query class. Moreover, it is more efficient to maintain contracted graphs than indices. This said, the contraction scheme can be complemented with indices for further speedup, by building indices on smaller contracted graphs, as demonstrated in Sect. 3.1.

Conclusion
We have proposed a contraction scheme to make big graphs small, as a generic optimization scheme for multiple applications to run on the same graph at the same time. We have shown that the scheme is generic and lossless. Moreover, it prioritizes up-to-date data by separating it from obsolete data. In addition, existing query evaluation algorithms can be readily adapted to compute exact answers, often without decontracting topological components. Our experimental results have verified that the contraction scheme is effective.
A topic for future work is to build a hierarchy of contracted graphs by iteratively contracting regular structures into supernodes, until the one at the top fits into the memory; the objective is to make large graphs small enough to fit into the memory of a single machine, and make it possible to process large graphs under limited resources. Another topic is to study the capacity of a single multi-core machine for big graph analytics, by leveraging both contraction and multi-core parallelism. source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecomm ons.org/licenses/by/4.0/.