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 ss-tt connectivity requires Ω(n)\Omega(n) 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 GG that has significantly fewer edges than GG, but still maintains important properties of the graph. Hopefully, this sparsified graph can be used to approximately answer a variety of questions about GG with reduced space and time complexity. Typically, the goal is to find a subgraph with just O(nlog⁡n)O(n\log n) edges in comparison to the possible O(n2)O(n^{2}) edges in GG.

First introduced by Benczúr and Karger [BK96], a cut sparsifier of a graph GG is a weighted subgraph with only O(1ϵ2nlog⁡n)O(\frac{1}{\epsilon^{2}}n\log n) edges that preserves the total edge weight over every cut in GG to within a (1±ϵ)(1\pm\epsilon) multiplicative factor. Cut sparsifiers can be used to compute approximations for minimum cut, sparsest cut, maximum flow, and a variety of other problems over GG. In [ST11], Spielman and Teng introduce the stronger spectral sparsifier, a weighted subgraph whose Laplacian spectrally approximates the Laplacian of GG. 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 GG, 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 G(V,E)G(V,E) as B=SBn\mathbf{B}=\mathbf{S}\mathbf{B}_{n} where S\mathbf{S} is an (n2)×(n2){n\choose 2}\times{n\choose 2} diagonal matrix with ones at positions corresponding to edges contained in GG and zeros elsewhere.Typically rows of B\mathbf{B} that are all are removed, but we find this formulation more convenient for our purposes. The n×nn\times n Laplacian matrix of GG is given by K=B⊤B\mathbf{K}=\mathbf{B}^{\top}\mathbf{B}.

2 Spectral Sparsification

3 Leverage Scores and Row Sampling

The leverage score, τi\tau_{i}, for a row bi\mathbf{b}_{i} in B\mathbf{B} 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, τi=riwi\tau_{i}=r_{i}w_{i}, where rir_{i} is the effective resistance of edge ii and wiw_{i} 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 x\mathbf{x} is equal to 0 or has value >2η∥x∥2>2\eta\|\mathbf{x}\|_{2}. 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 GG, each edge ee is sampled independently with probability proportional to its leverage score, τe\tau_{e}. After sampling, we reweight and combine any sampled edges. The result is a subgraph of GG containing, with high probability, O(1ϵ2nlog⁡n)O(\frac{1}{\epsilon^{2}}n\log n) edges and spectrally approximating GG.

If we view GG as an electrical circuit, with each edge representing a unit resistor, the leverage score of an edge e=(i,j)e=(i,j) is equivalent to its effective resistance. This value can be computed by forcing 11 unit of current out of vertex ii and 11 unit of current into vertex jj. The resulting voltage difference between the two vertices is the effective resistance of ee. Qualitatively, if the voltage drop is low, there are many low resistance (i.e. short) paths between ii and jj. Thus, maintaining a direct connection between these vertices is less critical in approximating GG, so ee is less likely to be sampled. Effective resistance can be computed as:

Note that τe\tau_{e} can be computed for any pair of vertices, (i,j)(i,j), or in other words, for any possible edge in GG. We can evaluate be⊤K+be\mathbf{b}_{e}^{\top}\mathbf{K}^{+}\mathbf{b}_{e} even if ee is not present in the graph. Thus, we can reframe our sampling procedure. Instead of just sampling edges actually in GG, imagine we run a sampling procedure for every possible ee. When recombining edges to form a spectral sparsifier, we separately check whether each edge ee is in GG 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 τe\tau_{e} for any ee. 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 ee actually exists in GG.

Solving part two (determining which edges are actually in GG) is a bit more involved. As a first step, consider writing

Referring to Section 2, recall that B=SBn\mathbf{B}=\mathbf{S}\mathbf{B}_{n} is exactly the same as a standard vertex edge incidence matrix except that rows in Bn\mathbf{B}_{n} corresponding to nonexistent edges are zeroed out instead of removed. Denote xe=SBnK+be\mathbf{x}_{e}=\mathbf{S}\mathbf{B}_{n}\mathbf{K}^{+}\mathbf{b}_{e}. Each nonzero entry in xe\mathbf{x}_{e} contains the voltage difference across some edge (resistor) in GG when one unit of current is forced from ii to jj.

where xe1/2s(e)\mathbf{x}_{e}^{1/2^{s}}(e) is xe\mathbf{x}_{e} sampled at rate 1/2s≈τe1/2^{s}\approx\tau_{e}. Then, as explained, we can use our sparse recovery routine to determine whether or not ee 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 O(log⁡n)O(\log n) sketches for [K(0),K(1),…,K(d),K]\begin{bmatrix}\mathbf{K}(0),\mathbf{K}(1),\ldots,\mathbf{K}(d),\mathbf{K}\end{bmatrix}. We first use a weighted identity matrix as a coarse approximation for K(0)\mathbf{K}(0), which allows us to recover a good approximation to K(0)\mathbf{K}(0) from our sketch. This approximation will in turn be a coarse approximation for K(1)\mathbf{K}(1), so we can recover a good sparsifier of K(1)\mathbf{K}(1). Continuing up the chain, we eventually recover a good sparsifier for our final matrix, K\mathbf{K}.

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, γ(0)=λu\gamma(0)=\lambda_{u} and γ(d)≤λl\gamma(d)\leq\lambda_{l}. Then the chain of PSD matrices, [K(0),K(1),…,K(d)]\begin{bmatrix}\mathbf{K}(0),\mathbf{K}(1),\ldots,\mathbf{K}(d)\end{bmatrix} with

K⪯rK(d)⪯r2K\mathbf{K}\preceq_{r}\mathbf{K}(d)\preceq_{r}2\mathbf{K},

K(0)⪯2γ(0)I⪯2K(0)\mathbf{K}(0)\preceq 2\gamma(0)\mathbf{I}\preceq 2\mathbf{K}(0).

When K\mathbf{K} is the Laplacian of an unweighted graph, its largest eigenvalue λmax<2n\lambda_{max}<2n and its smallest non-zero eigenvalue λmin>8/n2\lambda_{min}>8/n^{2}. Thus the length of our chain, d=⌈log⁡2λu/λl⌉d=\lceil\log_{2}\lambda_{u}/\lambda_{l}\rceil, is O(log⁡n)O(\log n).

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 B\mathbf{B}. The general idea is explained in Section 3, with detailed pseudocode included below.

For s∈{1,...O(log⁡n)}s\in\{1,...O(\log n)\} let hs:(n2)→{0,1}h_{s}:{n\choose 2}\rightarrow\{0,1\} be a uniform hash function. Let Bs\mathbf{B}_{s} be B\mathbf{B} with all rows except those with ∏j≤shj(e)=0\prod_{j\leq s}h_{j}(e)=0 zeroed out. So Bs\mathbf{B}_{s} is B\mathbf{B} with rows sampled independently at rate 12s\frac{1}{2^{s}}. B0\mathbf{B}_{0} is simply B\mathbf{B}.

Maintain sketchs Π0B0,Π1B1,...,ΠO(log⁡n)BO(log⁡n)\mathbf{\Pi}_{0}\mathbf{B}_{0},\mathbf{\Pi}_{1}\mathbf{B}_{1},...,\mathbf{\Pi}_{O(\log n)}\mathbf{B}_{O(\log n)} where {Π0,Π1,...ΠO(log⁡n)}\{\mathbf{\Pi}_{0},\mathbf{\Pi}_{1},...\mathbf{\Pi}_{O(\log n)}\} are drawn from the distribution from Lemma 2 with η=ϵc1log⁡n\eta=\frac{\epsilon}{c_{1}\sqrt{\log n}}.

Output all of these sketches stacked: ΠB=Π0B0⊕…⊕ΠO(log⁡n)BO(log⁡n)\boldsymbol{\Pi}\mathbf{B}=\mathbf{\Pi}_{0}\mathbf{B}_{0}\oplus\ldots\oplus\mathbf{\Pi}_{O(\log n)}\mathbf{B}_{O(\log n)}.

For every edge ee in the set of (n2){n\choose 2} possible edges:

If it is determined that xe(e)≠0\mathbf{x}_{e}(e)\neq 0 set W(e,e)=2s\mathbf{W}(e,e)=2^{s}.

Implementation in the Semi-Streaming Model.

Unfortunately, storing O(log⁡n)O(\log n) uniform hash functions over (n2){n\choose 2} requires O(n2log⁡n)O(n^{2}\log n) 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 ss chosen to guarantee min⁡{1,pe}≤12s≤min⁡{1,2pe}\min\{1,p_{e}\}\leq\frac{1}{2^{s}}\leq\min\{1,2p_{e}\} could in theory be larger than the index of the last sketch ΠiBi\boldsymbol{\Pi}_{i}\mathbf{B}_{i} maintained. However, if we take O(log⁡n)O(\log n) samplings, our last will be empty with high probability. Accordingly, all samplings for higher values of ss can be considered empty as well and we can just skip steps 2(b) and 2(c) for such values of ss. Thus, O(log⁡n)O(\log n) sampling levels are sufficient.

Correctness

The probability that be\mathbf{b}_{e} is included in the sampled matrix Bs(e)\mathbf{B}_{s(e)} is simply 1/2s(e)1/2^{s(e)}, and sampling is done independently using uniform hash functions. So, we just need to show that, with high probability, any be\mathbf{b}_{e} included in its respective Bs(e)\mathbf{B}_{s(e)} is recovered by Step 2(b).

we can set δ=ϵ\delta=\epsilon 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 ΠAs\mathbf{\Pi}\mathbf{A}_{s}, for every sampling rate 1/2s1/2^{s}, we compute O(log⁡n)O(\log n) sketches of different samplings of A\mathbf{A} at rate 1/2s1/2^{s}. Each sampling is fully independent from the all others, including those at the same and different rates. This differs from the graph case, where B1/2s+1\mathbf{B}_{1/2^{s+1}} was always a subsampling of B1/2s\mathbf{B}_{1/2^{s}} (for ease of exposition). Our modified set up lets us show that, with high probability, the norm of xis(i)\mathbf{x_{i}}^{s(i)} is close to its expectation for at least a (1−ϵ)(1-\epsilon) fraction of the independent samplings for rate s(i)s(i). We can recover row ii 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 s∈[S]s\in[S] and t∈[T]t\in[T] maintain sketch Πs(t)Fs(t)A\mathbf{\Pi}_{s}^{(t)}\mathbf{F}_{s}^{(t)}\mathbf{A} where each Πs(t)\mathbf{\Pi}_{s}^{(t)} is drawn independently from the distribution in Lemma 2 with η2=1C\eta^{2}=\frac{1}{C} and C=c1ϵ−3log⁡mlog⁡nC=c_{1}\epsilon^{-3}\log m\log n.

Add rows of γI\gamma\mathbf{I}, independently sampled at rate 12s\frac{1}{2^{s}} , to each sketch.

Pick ti∈[T]t_{i}\in[T] uniformly at random and use Lemma 2 to check if xsi(ti)(i)2≥C−1∥xsi(ti)∥22\mathbf{x}_{s_{i}}^{(t_{i})}(i)^{2}\geq C^{-1}\|\mathbf{x}_{s_{i}}^{(t_{i})}\|_{2}^{2}.

If ii is recovered, add row ii to the set of sampled edges with weight 2si2^{s_{i}}.

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 GG using a coarse sparsifier, then we can use the chain of spectrally similar graphs provided in Theorem 2 to find a final (1±ϵ)(1\pm\epsilon) 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 nn. 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 A\mathbf{A}.

Using a Pseudorandom Number Generator

In the proof of our sketching algorithm, Theorem 3, we assume that MaintainSketches has access to O(log⁡n)O(\log n) uniform random hash functions, h1,…,hO(log⁡n)h_{1},\ldots,h_{O(\log n)} mapping every edge to {0,1}\{0,1\}. These functions are used to subsample our vertex edge incidence matrix, B\mathbf{B}, at geometrically decreasing rates. Storing the functions as described would require O(n2log⁡n)O(n^{2}\log n) space - we need O(log⁡n)O(\log n) random bits for each possible edge.

Any randomized algorithm running in space(S)space(S) and using RR random bits may be converted to one that uses only O(Slog⁡R)O(S\log R) random bits (and runs in space O(Slog⁡R)O(S\log R)).

[Nis92] gives this conversion explicitly by describing a method for generating RR pseudorandom bits from O(Slog⁡R)O(S\log R) truly random bits. For any algorithm running in space(S)space(S), 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 2−O(S)2^{-O(S)} (see Lemma 3 in [Nis92]). It follows that using pseudorandom bits increases the failure probability of any randomized algorithm by just 2−O(S)2^{-O(S)} 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 xk\mathbf{x}_{k} is the best kk-term approximation to x\mathbf{x} and C>1C>1. Our main sparse recovery primitive is the following result of [GLPS12]:

with probability at least 3/43/4. The decoding algorithm runs in time O(klog⁡O(1)N/ϵ)O(k\log^{O(1)}N/\epsilon).

Using this primitive, we can prove Lemma A.

Note that since we are only using Markov’s inequality, it is sufficient to have hh be pairwise independent. Such a function hh can be represented in small space. Now invoke the result of Theorem 7 on yh(i)\mathbf{y}^{h(i)} with k=1k=1, ϵ=1\epsilon=1, and let wh(i)\mathbf{w}^{h(i)} be the output. We have

This shows that applying sketches from Theorem 7 to vectors yj\mathbf{y}^{j}, for j=1,…,16/η2j=1,\ldots,16/\eta^{2} and outputting the vector w\mathbf{w} with wi=wih(i)\mathbf{w}_{i}=\mathbf{w}^{h(i)}_{i} allows us to recover all i∈[N]i\in[N] with η∥x∥2\eta\|\mathbf{x}\|_{2} additive error with probability at least 3/4−1/83/4-1/8.

Appendix B Recursive Sparsification

For completeness, we give a short proof of Theorem 2:

So, γ(d)≤λl\gamma(d)\leq\lambda_{l} and γ(0)=λu\gamma(0)=\lambda_{u}. Then the chain of PSD matrices, [K(0),K(1),…,K(d)]\begin{bmatrix}\mathbf{K}(0),\mathbf{K}(1),\ldots,\mathbf{K}(d)\end{bmatrix} with:

K⪯rK(d)⪯r2K\mathbf{K}\preceq_{r}\mathbf{K}(d)\preceq_{r}2\mathbf{K}

K(0)⪯2γ(0)I⪯2K(0)\mathbf{K}(0)\preceq 2\gamma(0)\mathbf{I}\preceq 2\mathbf{K}(0)

When K\mathbf{K} is the Laplacian of an unweighted graph, λmax<2n\lambda_{max}<2n and λmin>8/n2\lambda_{min}>8/n^{2} (where here λmin\lambda_{min} is the smallest nonzero eigenvalue). Thus the length of our chain, d=⌈log⁡2λu/λl⌉d=\lceil\log_{2}\lambda_{u}/\lambda_{l}\rceil, is O(log⁡n)O(\log n).

Relation 1 follows trivially from the fact that γ(d)≤λl\gamma(d)\leq\lambda_{l} is smaller than the smallest nonzero eigenvalue of K\mathbf{K}. For any x⊥ker⁡(K)\mathbf{x}\perp\operatorname*{ker}(\mathbf{K}):

The other direction follows from γ(d)I⪰0\gamma(d)\mathbf{I}\succeq 0. Using the same argument, relation 3 follows from the fact that γ(0)≥λmax(K)\gamma(0)\geq\lambda_{max}(\mathbf{K}). For relation 2:

Finally, we need to prove the required eigenvalue bounds. For an unweighted graph, λmax<n\lambda_{max}<n follows from fact that nn is the maximum eigenvalue of the Laplacian of the complete graph on nn vertices. λmin>8/n2\lambda_{min}>8/n^{2} 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 nn. ∎