A nearly-mlogn time solver for SDD linear systems
Ioannis Koutis, Gary Miller, Richard Peng
Introduction
Solvers for symmetric diagonally dominant (SDD)A system is SDD when is symmetric and . systems are a crucial component of the fastest known algorithms for a multitude of problems that include (i) Computing the first non-trivial (Fiedler) eigenvector of the graph, with well known applications to the sparsest-cut problem [Fie73, ST96, Chu97]; (ii) Generating spectral sparsifiers that also act as cut-preserving sparsifiers [SS08]; (iii) Solving linear systems derived from elliptic finite element discretizations of a significant class of partial differential equations [BHV04]; (iv) Generalized lossy flow problems [SD08]; (v) Generating random spanning trees [KM09]; (vi) Faster maximum flow algorithms [CKM+11]; and (vii) Several optimization problems in computer vision [KMST09b, KMT11] and graphics [MP08, JMD+07].
The speedup of the SDD solver applies to all algorithms listed above, and we believe that it will prove to be quite important in practice, as applications of SDD solvers frequently involve massive graphs [Ten10].
The key to all known near-linear work SDD solvers is spectral graph sparsification, which on a given input graph constructs a sparser graph such that and are ‘spectrally similar’ in the condition number sense, defined in Section 2. Spectral graph sparsification can be seen as a significant strengthening of the notion of cut-preserving sparsification [BK96].
The new solver follows the framework of recursive preconditioned Chebyshev iterations [ST06, KMP10a]. The iterations are driven by a so-called preconditioning chain of graphs, where is a spectral sparsifier for and is generated by contracting via a greedy elimination of degree 1 and 2 nodes. The total work of the solver includes the time for constructing the chain, and the work spent on actual iterations which is a function on the preconditioning quality of the chain. The preconditioning quality of the chain in turn depends on the guarantees of the sparsification algorithm.
The incremental sparsification algorithm in [KMP10a] computes and keeps in a properly scaled copy of a low-stretch spanning tree of , and adds to a number of off-tree samples from . The key enabling observation in the new analysis is that the total stretch of the off-tree edges is essentially invariant under sparsification. In other words, the total stretch of the off-tree edges in is at most equal to that . The total stretch is invariable under the graph contraction process as well. The elimination process that generates from naturally generates a spanning tree for . The total stretch of the off-tree edges in is at most equal to that in . This effectively allows us to compute only one low-stretch spanning tree for the first graph in the chain, and keep the same tree for the rest of the chain. This is a significant departure from previous constructions, where a low-stretch spanning tree had to be calculated for each .
In order to analyze this new chain we view the graphs as multi-graphs or graphs of samples. In the sampling procedure that generates , some off-tree edges of can be sampled multiple times, and so is naturally a multi-graph, where the weight of a ‘traditional’ edge is split among a number of parallel multi-edges with the same endpoints. The progress of the overall sparsification in the chain is then monitored in terms of the number of multi-edges in the ’s. In other words, when the algorithm appears to be stagnated in terms of the edge count in the ’s, progress is still happening by ‘thinning’ the off-tree edges. The details are given in Section 4.
Background and notation
A matrix is symmetric diagonally dominant if it is symmetric and . It is well understood that any linear system whose matrix is SDD is easily reducible to a system whose matrix is the Laplacian of a weighted graph with positive weights [Gre96]. The Laplacian matrix of a graph is the matrix defined as
There is a one-to-one correspondence between graphs and Laplacians which allows us to extend some algebraic operations to graphs. Concretely, if and are graphs, we will denote by the graph whose Laplacian is , and by the graph whose Laplacian is .
[Spectral ordering of graphs] We define a partial ordering of graphs by letting
If there is a constant such that , we say that the condition of the pair is . In our proofs we will find useful to view a graph as a graph with multiple edges.
[Graph of samples] A graph is called a graph of samples, when each edge of weight is considered as a sum of a set of parallel edges, each of weight . When needed we will emphasize the fact that a graph is viewed as having parallel edges, by using the notation
[Stretch of edge by tree] Let be a tree. For let . Let be an edge not necessarily in , of weight . If the unique path connecting the endpoints of in consists of edges , the stretch of by is defined to be
A key to our results is viewing graphs as resistive electrical networks [DS00]. More concretely, if each corresponds to a resistor of capacity connecting the two endpoints of . We denote by the effective resistance between the endpoints of in . The effective resistance on trees is easy to calculate; we have . Thus
We extend the definition to in the natural way
and note that .
This definition can also be extended to set of edges. Thus denotes the vector of stretch values of all edges in . We also let denote the vector of stretch for edges in .
[Total Off-Tree Stretch] Let be a graph, be a spanning tree of . We define
Incremental Sparsifier
In their remarkable work [SS08], Spielman and Srivastava analyzed a spectral sparsification algorithm based on a simple sampling procedure. The sampling probabilities were proportional to the effective resistances of the edges on the input graph . Our solver in [KMP10a] was based on an incremental sparsification algorithm which used upper bounds on the effective resistances, that are more easily calculated. In this section we give a more careful analysis of the incremental sparsifier algorithm given in [KMP10a].
We start by reviewing the basic Sample procedure. The procedure takes as input a weighted graph and frequencies for each edge . These frequencies are normalized to probabilities summing to . It then picks in rounds exactly samples which are weighted copies of the edges. The probability that given edge is picked in a given round is . The weight of the corresponding sample is set so that the expected weight of the edge after sampling is equal to its actual weight in the input graph. The details are given in the following pseudocode.
The following Theorem characterizes the quality of as a spectral sparsifier for and it was proved in [KMP10a].
(Oversampling) Let be a graph. Assuming that for each edge , and , the graph satisfies
Suppose we are given a spanning tree of . The incremental sparsification algorithm of [KMP10a] was based on two key observations: (a) By Rayleigh’s monotonicity law [DS00] we have because is a subgraph of . Hence the numbers satisfy the condition of Theorem 3.1 and they can be used in Sample. (b) Scaling up the edges of in by a factor of gives a new graph where the stretches of the off-tree are smaller by a factor of relative to those in . This forces Sample (when applied on ) to sample more often edges from , and return a graph with a smaller number of off-tree edges. In other words, the scale-up factor allows us to control the number of off-tree edges. Of course this comes at the cost of incurring condition between and .
In this paper we follow the same approach, but also modify IncrementalSparsify so that the output graph is a union of a copy of and the off-tree samples picked by Sample. To emphasize this, we will denote the edge set of the output graph by . The details are given in the following algorithm.
Let be a graph with vertices and edges and be a spanning tree of . Then for , computes with probability at least a graph such that
We now bound the number of off-tree samples drawn by Sample. For the number used in Sample we have and is the number samples drawn by Sample. Let be a random variable which is if the sample picked by Sample is a non-tree edge and otherwise. The total number of non-tree samples is the random variable , and its expected value can be calculated using the fact :
Step 12 assures that does not contain more than edges so the claim about the number of off-tree samples is automatically satisfied. A standard form of Chernoff’s inequality is:
Letting , and since we get . So, the probability that the algorithm returns a FAIL is at most . It follows that the probability that an output of Sample satisfies inequality 3.1 and doesn’t get rejected by IncrementalSparsify is at least .
We now concentrate on the edges of . Any fixed edge is sampled with probability in Sample. Let denote the random variable equal to number of times is sampled. Since there are iterations of sampling, we have . By the Chernoff inequalities above, setting we get that
Overall, the probability that the output of IncrementalSparsify satisfies the claim about the condition number is at least .
Since the weights of the tree-edges in are different than those in , we will use to denote the spanning tree of whose edge-set is . We now show a key property of IncrementalSparsify.
(Uniform Sample Stretch) Let , and as defined in Theorem 3.2. For all , we have
Proof Let . Consider an arbitrary non-tree edge of defined in Step 5 of IncrementalSparsify. The probability of it being sampled is:
where is the effective resistance of in and is the total stretch of all edges by . If is picked, the corresponding sample has weight scaled up by a factor of , but then divided by at the end. This gives
So the stretch of with respect to is independent from and equal to
Finally note that . This proves the claim.
Solving using Incremental Sparsifiers
We follow the framework of the solvers in [ST06] and [KMP10a] which consist of two phases. The preconditioning phase builds a chain of graphs starting with , along with a corresponding list of positive numbers where is an upper bound on the condition number of the pair . The process for building alternates between calls to a sparsification routine (in our case IncrementalSparsify) which constructs from and a routine GreedyElimination which constructs from , by applying a greedy elimination of degree and nodes. The preconditioning phase is independent from the -side of the system . The solve phase passes , and a number of iterations (depending on a desired error ) to the recursive preconditioning algorithm R-P-Chebyshev, described in [ST06] or in the appendix of [KMP10a].
We first give pseudocode for GreedyElimination, which deviates slightly from the standard presentation where the input and output are the two graphs and , to include a spanning tree of the graphs.
Of course we still need to prove that the output is indeed a spanning tree. We prove the claim in the following Lemma that also examines the effect of GreedyElimination to the total stretch of the off-tree edges.
Let . The output is a spanning tree of , and
Proof We prove the claim inductively by showing that it holds for all the pairs throughout the loop, where denotes the pair after the elimination during the course of the algorithm. The base of the induction is the input pair and so the claim holds for it.
When a degree- node gets eliminated the corresponding edge is necessarily in by the inductive hypothesis. Its elimination doesn’t affect the stretch of any off-tree edge. So, it is clear that if satisfy the claim then after the elimination of a degree- node will also satisfy the claim.
By the inductive hypothesis about if are eliminated then at least one of the two edges must be in . We first consider the case where one of the two (say ) is not in . Both and must be connected to the rest of through edges of different than and . Hence is a spanning tree of . Observe that we eliminate at most two non-tree edges from : and with corresponding weights and respectively. Let denote the unique tree-path between the endpoints of in . The contribution of the two eliminated edges to the total stretch is equal to
The two eliminated edges get replaced by the edge with weight . The contribution of the new edge to the total stretch in is equal to
We have since all the edges in the tree-path of are not affected by the elimination. We also have , hence . The claim follows from the fact that no other edges are affected by the elimination, so
We now consider the case where both edges eliminated in Steps 5-13 are in . It is clear that is a spanning tree of . Consider any off-tree edge not in . One of its two endpoints must be different than either or , so its endpoints and weight are the same in . However the elimination of may affect the stretch of if goes through . Let
Since individual edge stretches only decrease, the total stretch also decreases and the claim follows.
A preconditioning chain of graphs must certain properties in order to be useful with R-P-Chebyshev.
[Good Preconditioning Chain] Let be a chain of graphs and a list of numbers. We say that is a good preconditioning chain for , if there exist a list of numbers such that:
.
.
is at least the number of edges in .
, where is the number of edges in .
for all where is an explicitly known constant.
is a smaller than a fixed constant.
Spielman and Teng [ST06] analyzed the recursive preconditioned Chebyshev iteration R-P-Chebyshev that can be found in the appendix of [KMP10a] and showed that the solution of an arbitrary SDD system can be reduced to the computation of a good preconditioning chain. This is captured more concretely by the following Lemma which is adapted from Theorem 5.5 in [ST06].
Let be an SDD matrix with where is a diagonal matrix with non-negative elements, and is the Laplacian of a graph . Given a good preconditioning chain for , a vector such that can be computed in time .
Before we proceed to the algorithm for building the chain we will need a modified version of a result by Abraham, Bartal, and Neiman [ABN08], which we prove in Section 5.
There is an algorithm LowStretchTree that, given a graph , outputs a spanning tree of such that
The algorithm runs in time.
Algorithm BuildChain generates the chain of graphs.
It remains to show that our algorithm indeed generates a good preconditioning chain.
Proof Let denote the number of edges in and the number of off-tree samples for . We prove by induction on that:
, where and are as defined in Theorem 3.2 for the graph .
We now exhibit the list of numbers required by Definition 4.2. A key property of GreedyElimination is that if is a graph with edges, the output of GreedyElimination has at most vertices and edges [ST06]. Hence the graph returned by has at most edges. Therefore setting gives an upper bound on the number of edges in and:
At the same time we have . By picking to be large enough we can satisfy all the requirements for the preconditioning chain.
The probability that has the above properties is by construction at least . Since there are at most levels in the chain, the probability that the requirements hold for all is then at least
Combining Lemmas 4.3 and 4.5 proves our main Theorem.
Speeding Up Low Stretch Spanning Tree Construction
We improve the running time of the algorithm for finding a low stretch spanning tree given in [EEST05, ABN08] by a factor of , while retaining the bound on total stretch given in [ABN08]. Specifically, we claim the following Theorem.
There is an algorithm LowStretchTree that given a graph , outputs a spanning tree of in time such that
We first show that if the graph only has distinct edge weights, Dijkstra’s algorithm can be modified to run in time. Our approach is identical to the algorithm described in [OMSW10]. However, we obtain a slight improvement in running time over the bound given in [OMSW10].
The low stretch spanning tree algorithm in [EEST05, ABN08] makes use of Dijkstra’s, as well as intermediate stages of it in the routines BallCut and ConeCut. We first improve the underlying data structure used by these routines.
There is a data structure that given a list of non-negative values (the distinct edge lengths), maintains a set of keys (distances) starting with under the following operations:
: returns the element with minimum key.
: delete the element with minimum key.
: insert the minimum key plus into the set of keys.
: decrease the key of to the minimum key plus .
Insert and DecreaseKey have amortized cost and DeleteMin has amortized cost.
Proof We maintain queues containing the keys with the invariant that the keys stored in them are in non-decreasing order. We also maintain a Fibonacci heap as described in [FT87] containing the first element of all non-empty queues. Since the number of elements in this heap is at most , we can perform Insert and DecreaseKey in and DeleteMin in amortized time on these elements. The invariant then allows us to support FindMin in time.
Since , the new key introduced by Insert or DecreaseKey is always at least the minimum key. Therefore the minimum key is non-decreasing throughout the operations. So if we only append keys generated by adding to the minimum key to the end of , the invariant that the queues are monotonically non-decreasing is maintained. Specifically, can be performed by appending a new entry to the tail of .
For , suppose is currently stored in queue . We consider two cases:
has a predecessor in . Then the key of is not the key of in the Fibonacci heap and we can remove from in time while keeping the invariant. Then we can insert with its new key at the end of using one Insert operation.
is currently at the head of . Then simply decreasing the key of would not violate the invariant of all keys in the queues being monotonic. As the new key will be present in the heap containing the first elements of the queues, a decrease key needs to be performed on the Fibonacci heap containing those elements.
DeleteMin can be done by doing a delete min in the Fibonacci heap, and removing the element from the queue containing it. If the queue is still not empty, it can be reinserted into the Fibonacci heap with key equaling to that of its new first element. The amortized cost of this is .
The running times of Dijkstra’s algorithm, BallCut and ConeCut then follows.
Let be a connected weighted graph and be some vertex. If there are distinct values of , Dijkstra’s algorithm can compute for all vertices in time.
Proof Same as the proof of Dijkstra’s algorithm with Fibonacci heap, except the cost of a DeleteMin is .
(Corollary 4.3 of [EEST05]) If there are at most distinct distances in the graph, then BallCut returns ball such that
in time.
(Lemma 4.2 of [EEST05]) If there are at most distinct values in the cone distance , then
For any two values , ConeCut finds a real such that
in time, where is the set of all vertices within distance from in cone length .
Proof The existence such a follows from Lemma 4.2 of [EEST05] and the running time follows from the bounds given in Lemma 5.2.
We now proceed to show a faster algorithm for constructing low stretch spanning trees by using the data structure from Lemma 5.2. Our presentation is based on the algorithm described in [ABN08], which consists of HierarchicalStarPartition at the top level that makes repeated calls to StarPartition. StarPartition then in turn obtains a desired partition via. calls to BallCut and ImpConeDecomp which uses ConeCut. Due to space limitations we refer to these routines without stating their parameters and guarantees.
Given a graph that has distinct edge lengths, The version of StarPartition that uses ImpConeDecomp as stated in Corollary 6 of [ABN08] runs in time .
Proof Finding radius and calling BallCut takes time. Since the s form a partition of the vertices and ImpConeDecomp never reduce the size of a cone, the total cost of all calls to ImpConeDecomp is
We now need to ensure that all calls to StarPartition are made with a small value of . This can be done by rounding the edge lengths so that at any iteration of HierarchicalStarPartition, the graph has distinct edge weights.
Let be any spanning tree of , and any pair of vertices, we have
Proof Summing the bound on a single edge over all edges on the tree path suffices.
Combining these two gives the following Corollary.
For any pair of vertices such that ,
Discussion
The output of IncrementalSparsify is a graph of samples with a remarkable property as a direct consequence of Lemma 3.3; its further incremental sparsification can be performed by a mere uniform sampling of its off-tree multi-edges.
This leads naturally to the definition of a smooth sequence of (multi)-graphs on a common set of vertices, with the following properties: (i) it is of logarithmic size, (ii) the first graph is spine-heavy, (iii) every two subsequent graphs have a constant condition number, and (iv) the last graph is a tree. The sequence can be obtained by applying one round of IncrementalSparsify to the spine-heavy graph, and then rounds of uniform sampling.
Smooth sequences of graphs can be useful in an alternative way for building a chain of preconditioners, which separates sparsification from greedy elimination. More concretely, the alternative algorithm first builds a smooth sequence of graphs, starting from the spine-heavy version of the input graph. Then, somewhat roughly speaking, the final chain is obtained by applying a slightly less aggressive version of GreedyElimination to each graph in the sequence; this version eliminates degree-one nodes as usually, but restricts itself to degree-two nodes whose both adjacent edges are in the low-stretch tree. The simplicity of this approach is particularly highlighted in the case of low-diameter unweighted graphs. Solving such graphs has now been essentially reduced to the computation of a BFS tree followed by a number of rounds of uniform sampling.
We believe that smooth sequences of graphs is a notion of independent interest that may found other applications.