Single Pass Spectral Sparsification in Dynamic Streams
Michael Kapralov, Yin Tat Lee, Cameron Musco, Christopher Musco, Aaron Sidford
Introduction
When processing massive graph datasets arising from social networks, web topologies, or interaction graphs, computation may be as limited by space as it is by runtime. To cope with this issue, one might hope to apply techniques from the streaming model of computation, which restricts algorithms to few passes over the input and space polylogarithmic in the input size. Streaming algorithms have been studied extensively in various application domains – see [Mut05] for an overview. However, the model has proven too restrictive for even the simplest graph algorithms. For example, testing - connectivity requires space [HRR99].
In the dynamic semi-streaming model, the graph stream may include both edge insertions and deletions [AGM12a]. This extension captures the fact that large graphs are unlikely to be static. Dynamic semi-streaming algorithms allow us to quickly process general updates in the form of edge insertions and deletions to maintain a small-space representation of the graph from which we can later compute a result. Sometimes the dynamic model is referred to as the insertion-deletion model, in contrast to the more restrictive insertion-only model.
Work on semi-streaming algorithms in both the dynamic and insertion-only settings is extensive. Researchers have tackled connectivity, bipartiteness, minimum spanning trees, maximal matchings, and spanners among other problems [FKM+05, ELMS11, Elk11, AGM12a, AGM12b]. In [McG14], McGregor surveys much of this progress and provides a more complete list of citations.
2 Streaming Sparsification
There has also been a focus on computing general purpose graph compressions in the streaming setting. The goal is to find a subgraph of an input graph that has significantly fewer edges than , but still maintains important properties of the graph. Hopefully, this sparsified graph can be used to approximately answer a variety of questions about with reduced space and time complexity. Typically, the goal is to find a subgraph with just edges in comparison to the possible edges in .
First introduced by Benczúr and Karger [BK96], a cut sparsifier of a graph is a weighted subgraph with only edges that preserves the total edge weight over every cut in to within a multiplicative factor. Cut sparsifiers can be used to compute approximations for minimum cut, sparsest cut, maximum flow, and a variety of other problems over . In [ST11], Spielman and Teng introduce the stronger spectral sparsifier, a weighted subgraph whose Laplacian spectrally approximates the Laplacian of . In addition to maintaining the cut approximation of Benczúr and Karger, spectral sparsifiers can be used to approximately solve linear systems over the Laplacian of , and to approximate effective resistances, spectral clusterings, random walk properties, and a variety of other computations.
3 Our Contribution
Our main result is an algorithm for maintaining a small graph sketch from which we can recover a spectral sparsifier. For simplicity, we present the algorithm in the case of unweighted graphs. However, in Section 6, we show that it is easily extended to weighted graphs. This model matches what is standard for dynamic cut sparsifiers [AGM12b, GKP12].
The fact that our algorithm maintains a linear sketch of the streamed graph allows for the simple handling of edge deletions, which are treated as negative edge insertions. Additionally, due to their linearity, our sketches are composable – sketches of subgraphs can simply be added to produce a sketch of the full graph. Thus, our techniques are directly applicable in distributed settings where separate processors hold different subgraphs or each processes different edge substreams.
4 Road Map
Lay out notation, build linear algebraic foundations for spectral sparsification, and present lemmas for graph sampling and sparse recovery required by our algorithm.
Give an overview of our central algorithm, providing intuition and motivation.
Present an algorithm of Miller and Peng ([MP12]) for building a chain of coarse sparsifiers and prove our main result, assuming a primitive for sampling edges by effective resistance in the streaming model.
Develop this sampling primitive, our main technical contribution.
Show how to extend the algorithm to weighted graphs.
Show how to extend the algorithm to general structured matrices.
Remove our assumption of fully independent hash functions, using a pseudorandom number generator to achieve a final small space algorithm.
Notation and Preliminaries
We write the vertex edge incidence matrix of an unweighted, undirected graph as where is an diagonal matrix with ones at positions corresponding to edges contained in and zeros elsewhere.Typically rows of that are all are removed, but we find this formulation more convenient for our purposes. The Laplacian matrix of is given by .
2 Spectral Sparsification
3 Leverage Scores and Row Sampling
The leverage score, , for a row in is defined as
The last inequality follows from the fact that every row in a matrix with orthonormal columns has norm less than 1. In a graph, , where is the effective resistance of edge and is the edge’s weight. Furthermore,
A proof of Lemma 1 based on a matrix concentration result from [Tro12] can be found in [CLM+15] (Lemma 4). Note that, when applied to the vertex edge incidence matrix of a graph, leverage score sampling is equivalent to effective resistance sampling, as introduced in [SS11] for graph sparsification.
4 Sparse Recovery
This procedure allows us to distinguish from a sketch whether or not a specified entry in is equal to 0 or has value . We give a proof of Lemma 2 in Appendix A
Algorithm Overview
Before formally presenting a proof of our main result, Theorem 1, we give an informal overview of the algorithm to provide intuition.
As explained in Section 2.3, spectral sparsifiers can be generated by sampling edges, i.e. rows of the vertex edge incidence matrix. For an unweighted graph , each edge is sampled independently with probability proportional to its leverage score, . After sampling, we reweight and combine any sampled edges. The result is a subgraph of containing, with high probability, edges and spectrally approximating .
If we view as an electrical circuit, with each edge representing a unit resistor, the leverage score of an edge is equivalent to its effective resistance. This value can be computed by forcing unit of current out of vertex and unit of current into vertex . The resulting voltage difference between the two vertices is the effective resistance of . Qualitatively, if the voltage drop is low, there are many low resistance (i.e. short) paths between and . Thus, maintaining a direct connection between these vertices is less critical in approximating , so is less likely to be sampled. Effective resistance can be computed as:
Note that can be computed for any pair of vertices, , or in other words, for any possible edge in . We can evaluate even if is not present in the graph. Thus, we can reframe our sampling procedure. Instead of just sampling edges actually in , imagine we run a sampling procedure for every possible . When recombining edges to form a spectral sparsifier, we separately check whether each edge is in and only insert into the sparsifier if it is.
2 Sampling in the Streaming Model
With this procedure in mind, a sampling method that works in the streaming setting requires two components. First, we need to obtain a constant factor approximation to for any . Known sampling algorithms, including our Lemma 1, are robust to this level of estimation. Second, we need to compress our edge insertions and deletions in such a way that, during post-processing of our sketch, we can determine whether or not a sampled edge actually exists in .
Solving part two (determining which edges are actually in ) is a bit more involved. As a first step, consider writing
Referring to Section 2, recall that is exactly the same as a standard vertex edge incidence matrix except that rows in corresponding to nonexistent edges are zeroed out instead of removed. Denote . Each nonzero entry in contains the voltage difference across some edge (resistor) in when one unit of current is forced from to .
where is sampled at rate . Then, as explained, we can use our sparse recovery routine to determine whether or not is present. If it is, we have obtained a sample for our spectral sparsifier!
3 A Chain of Coarse Sparsifiers
Putting everything together, we maintain sketches for . We first use a weighted identity matrix as a coarse approximation for , which allows us to recover a good approximation to from our sketch. This approximation will in turn be a coarse approximation for , so we can recover a good sparsifier of . Continuing up the chain, we eventually recover a good sparsifier for our final matrix, .
Recursive Sparsifier Construction
In this section, we formalize a recursive procedure for obtaining a chain of coarse sparsifiers that was introduced by Miller and Peng – “Introduction and Removal of Artificial Bases” [MP12]. We prove Theorem 1 by combining this technique with the sampling algorithm developed in Section 5.
So, and . Then the chain of PSD matrices, with
,
.
When is the Laplacian of an unweighted graph, its largest eigenvalue and its smallest non-zero eigenvalue . Thus the length of our chain, , is .
Furthermore, by assumption we have the inequalities:
Finally, to obtain a bonafide graph sparsifier (a weighted subgraph of our streamed graph), let:
Streaming Row Sampling
In this section, we develop the sparsifier refinement routine required for Theorem 1.
The challenge in the semi-streaming setting is actually sampling edges given only a sketch of . The general idea is explained in Section 3, with detailed pseudocode included below.
For let be a uniform hash function. Let be with all rows except those with zeroed out. So is with rows sampled independently at rate . is simply .
Maintain sketchs where are drawn from the distribution from Lemma 2 with .
Output all of these sketches stacked: .
For every edge in the set of possible edges:
If it is determined that set .
Implementation in the Semi-Streaming Model.
Unfortunately, storing uniform hash functions over requires space, and is thus impossible in the semi-streaming setting. If Section 8 we show how to cope with this issue by using a small-seed pseudorandom number generator.
For step 2(a), the chosen to guarantee could in theory be larger than the index of the last sketch maintained. However, if we take samplings, our last will be empty with high probability. Accordingly, all samplings for higher values of can be considered empty as well and we can just skip steps 2(b) and 2(c) for such values of . Thus, sampling levels are sufficient.
Correctness
The probability that is included in the sampled matrix is simply , and sampling is done independently using uniform hash functions. So, we just need to show that, with high probability, any included in its respective is recovered by Step 2(b).
we can set and conclude that
Sparsification of Weighted Graphs
Sparsification of Structured Matrices
We overcome this problem by modifying our algorithm to compute more sketches. Rather than computing a single , for every sampling rate , we compute sketches of different samplings of at rate . Each sampling is fully independent from the all others, including those at the same and different rates. This differs from the graph case, where was always a subsampling of (for ease of exposition). Our modified set up lets us show that, with high probability, the norm of is close to its expectation for at least a fraction of the independent samplings for rate . We can recover row if it is present in one of the ‘good’ samplings.
Ultimately, we argue, in a similar manner to [KP12], that we can sample rows according to some distribution that is close to the distribution obtained by independently sampling rows according to leverage score. Using this primitive, we can proceed as in the previous sections to prove Theorem 4. In Section 7.1, we provide the row sampling subroutine and in Section 7.2, we show how to use this sampling routine to prove Theorem 4.
Our leverage score sampling algorithm for the streaming model is as follows:
For all and maintain sketch where each is drawn independently from the distribution in Lemma 2 with and .
Add rows of , independently sampled at rate , to each sketch.
Pick uniformly at random and use Lemma 2 to check if .
If is recovered, add row to the set of sampled edges with weight .
2 Generalized Recursive Sparsification
Next we show how to construct a spectral sparsifier in the streaming model for a general structured matrix using the row sampling subroutine, RowSampleMatrix. In the graph case, Theorem 1 shows that, if we can find a sparsifier to a graph using a coarse sparsifier, then we can use the chain of spectrally similar graphs provided in Theorem 2 to find a final sparsifier for our input graph.
The proof of Theorem 1 includes our third reliance on the fact that we are sparsifying graphs – we claim that the condition number of an unweighted graph is polynomial in . This fact does not hold in the general matrix case since the condition number can be exponentially large even for bounded integer matrices. Therefore, our result for general matrix depends on the condition number of .
Using a Pseudorandom Number Generator
In the proof of our sketching algorithm, Theorem 3, we assume that MaintainSketches has access to uniform random hash functions, mapping every edge to . These functions are used to subsample our vertex edge incidence matrix, , at geometrically decreasing rates. Storing the functions as described would require space - we need random bits for each possible edge.
Any randomized algorithm running in and using random bits may be converted to one that uses only random bits (and runs in space ).
[Nis92] gives this conversion explicitly by describing a method for generating pseudorandom bits from truly random bits. For any algorithm running in , the pseudorandom bits are “good enough” in that the output distribution of the algorithm under pseudorandom bits is very close to the output distribution under truly random bits. In particular, the total variation distance between the distributions is at worst (see Lemma 3 in [Nis92]). It follows that using pseudorandom bits increases the failure probability of any randomized algorithm by just in the worst case.
Acknowledgements
We would like to thank Richard Peng for pointing us to the recursive row sampling algorithm contained in [MP12], which became a critical component of our streaming algorithm. We would also like to thank Jonathan Kelner for useful discussions and Jelani Nelson for a helpful initial conversation on oblivious graph compression.
This work was partially supported by NSF awards 0843915, 1111109, and 0835652, CCF-1065125, CCF-AF-0937274, CCF-0939370, and CCF-1217506, NSF Graduate Research Fellowship grant 1122374, Hong Kong RGC grant 2150701, AFOSR grants FA9550-13-1-0042 and FA9550-12-1-0411, MADALGO center, Simons Foundation, and the Defense Advanced Research Projects Agency (DARPA).
References
Appendix A Sparse Recovery
where is the best -term approximation to and . Our main sparse recovery primitive is the following result of [GLPS12]:
with probability at least . The decoding algorithm runs in time .
Using this primitive, we can prove Lemma A.
Note that since we are only using Markov’s inequality, it is sufficient to have be pairwise independent. Such a function can be represented in small space. Now invoke the result of Theorem 7 on with , , and let be the output. We have
This shows that applying sketches from Theorem 7 to vectors , for and outputting the vector with allows us to recover all with additive error with probability at least .
Appendix B Recursive Sparsification
For completeness, we give a short proof of Theorem 2:
So, and . Then the chain of PSD matrices, with:
When is the Laplacian of an unweighted graph, and (where here is the smallest nonzero eigenvalue). Thus the length of our chain, , is .
Relation 1 follows trivially from the fact that is smaller than the smallest nonzero eigenvalue of . For any :
The other direction follows from . Using the same argument, relation 3 follows from the fact that . For relation 2:
Finally, we need to prove the required eigenvalue bounds. For an unweighted graph, follows from fact that is the maximum eigenvalue of the Laplacian of the complete graph on vertices. by Lemma 6.1 of [ST14]. Note that this argument extends to weighted graphs when the ratio between the heaviest and lightest edge is bounded by a polynomial in . ∎