The matrix that is a graph

A graph with a tenth of the edges

Keeping 344 of 1,225 edges, sampled by effective resistance and reweighted, preserves every eigenvalue of the Laplacian to within a factor of 1.7. It preserves no degree — half of them are wrong by more than a third — and it takes the diameter from one to three.

Worth reading first: A distance computed by a solve · A matrix with no numbers in it · A bound that holds with probability.

A sparsifier is a graph with fewer edges that behaves like the original. Which behaviour is preserved is the entire content of the definition, and the version that has a theorem behind it preserves the quadratic form:

(1 − ε) · xᵀL x   ≤   xᵀL' x   ≤   (1 + ε) · xᵀL x      for every x

Every x. Not every x in a subspace, not with high probability for a given x — every vector at once, which means every cut, every eigenvalue, and the answer to every linear system.

344 of 1225 edges keep every eigenvalue and no degreeA fifty-vertex complete graph sparsified by keeping 400 samples drawn in proportion to each edge's effective resistance and reweighted by the reciprocal of its probability, which leaves 344 distinct edges of 1225. The filled curve is the ratio of each eigenvalue of the sample's Laplacian to the original's, in ascending order: it stays between 0.432 and 1.67, so every quadratic form, every cut and every solve is preserved to that factor. The open curve is the ratio of each vertex's degree, which runs from 0.562 to 1.5 — half the graph's degrees are wrong by more than a third. And the graph's diameter goes from 1 to 3: no shortest path survives. A sparsifier preserves what the Laplacian says and nothing else about the graph, and the two are easy to confuse because they are the same object.19172533414911.251.51.752indexsample ÷ originalkept, and not keptedges kept344of1225eigenvalue ratio, low0.43high1.7degree ratio, low0.56high1.5diameter, after3filled dots are eigenvaluesopen dots are degrees
Fig. 1 A fifty-vertex complete graph sampled down to 344 of its 1,225 edges. The filled curve is the ratio of each eigenvalue to the original’s; the open dots are the ratio of each vertex’s degree.

The construction

Keep each edge with probability proportional to its effective resistance times its weight, sample q times with replacement, and give each kept edge a weight of w/(q·p) where p was its probability.

The reweighting is what makes it work. An edge kept once carries w/(q·p); kept twice, twice that. So the expected Laplacian of the sample is exactly the Laplacian of the original — the estimator is unbiased, edge by edge, and that is the only part of the construction that is a theorem rather than a measurement.

The probabilities come out normalised for free, and by Foster’s identity: Σ w·R(e) over the edges is exactly n − 1 for any connected graph, so dividing by n − 1 gives a distribution without a normalising pass. The assertion in this library checks that sum to 10⁻⁸n before sampling anything, which is Foster’s theorem being used as a precondition rather than as a curiosity.

What survives

On a fifty-vertex complete graph, sampling at five different counts:

samples   edges kept   eigenvalue ratios   degree ratios   diameter after
  200        187        0.289 – 2.018      0.37 – 1.75          3
  400        344        0.432 – 1.674      0.56 – 1.50          3
  800        599        0.611 – 1.589      0.72 – 1.53          2
 1600        887        0.654 – 1.377      0.72 – 1.31          2
 3200       1123        0.721 – 1.222      0.76 – 1.16          2

At 400 samples the graph has 28% of its edges and every one of its forty-nine non-zero eigenvalues is within a factor of 1.7 of the original. That is the theorem working: no vector, of the 2⁵⁰ cuts or the continuum of directions, sees a distortion larger than the band.

The band closes like the square root of the sample count, which is the ordinary rate for an average of independent draws and is the only asymptotic in the construction. Sixteen times the samples buys four times the accuracy: 2.02 down to 1.22 at the top of the band.

What does not

The degree column is the one to read next.

At 400 samples the degrees run from 0.56 to 1.50 of their original values. Half the vertices in a graph whose spectrum is preserved to within 1.7 have a degree wrong by more than a third, and the worst is wrong by half.

That is not a defect of the sampler; it is what the theorem does not claim. A degree is xᵀLx for x = eᵢ — a single indicator vector — and the guarantee is a relative one, so a quantity that is small relative to the norm is preserved only relatively to itself, with a variance that comes from one vertex’s worth of draws rather than the whole graph’s. Fewer draws, wider band.

And the two bands close at different rates, which is what makes the degree column the one to watch.

96 of 1225 edges keep every eigenvalue and no degreeA fifty-vertex complete graph sparsified by keeping 100 samples drawn in proportion to each edge's effective resistance and reweighted by the reciprocal of its probability, which leaves 96 distinct edges of 1225. The filled curve is the ratio of each eigenvalue of the sample's Laplacian to the original's, in ascending order: it stays between 0.132 and 2.57, so every quadratic form, every cut and every solve is preserved to that factor. The open curve is the ratio of each vertex's degree, which runs from 0.25 to 2 — half the graph's degrees are wrong by more than a third. And the graph's diameter goes from 1 to 4: no shortest path survives. A sparsifier preserves what the Laplacian says and nothing else about the graph, and the two are easy to confuse because they are the same object.19172533414911.251.51.7522.252.5indexsample ÷ originalkept, and not keptedges kept96of1225eigenvalue ratio, low0.13high2.6degree ratio, low0.25high2diameter, after4filled dots are eigenvaluesopen dots are degrees
Fig. 2 A hundred samples, keeping 96 of the 1,225 edges. The eigenvalues run 0.132 to 2.57 and the degrees 0.25 to 2.
599 of 1225 edges keep every eigenvalue and no degreeA fifty-vertex complete graph sparsified by keeping 800 samples drawn in proportion to each edge's effective resistance and reweighted by the reciprocal of its probability, which leaves 599 distinct edges of 1225. The filled curve is the ratio of each eigenvalue of the sample's Laplacian to the original's, in ascending order: it stays between 0.611 and 1.59, so every quadratic form, every cut and every solve is preserved to that factor. The open curve is the ratio of each vertex's degree, which runs from 0.719 to 1.53 — half the graph's degrees are wrong by more than a third. And the graph's diameter goes from 1 to 2: no shortest path survives. A sparsifier preserves what the Laplacian says and nothing else about the graph, and the two are easy to confuse because they are the same object.19172533414911.251.51.752indexsample ÷ originalkept, and not keptedges kept599of1225eigenvalue ratio, low0.61high1.6degree ratio, low0.72high1.5diameter, after2filled dots are eigenvaluesopen dots are degrees
Fig. 3 Eight hundred samples, 599 edges: eigenvalues 0.611 to 1.59, degrees 0.719 to 1.53.

A factor of thirty-two in the sampling closes the spectral band from 19.5 to 1.7 and the degree band only from 8 to 1.5. Across 100, 800, 1,600 and 3,200 samples the eigenvalue range runs 0.132–2.57, 0.611–1.59, 0.654–1.38 and 0.721–1.22 — a ratio of extremes going 19.5, 2.6, 2.1, 1.7 — while the degree range runs 0.25–2, 0.719–1.53, 0.719–1.31 and 0.758–1.16, a ratio going 8.0, 2.1, 1.8, 1.5.

887 of 1225 edges keep every eigenvalue and no degreeA fifty-vertex complete graph sparsified by keeping 1600 samples drawn in proportion to each edge's effective resistance and reweighted by the reciprocal of its probability, which leaves 887 distinct edges of 1225. The filled curve is the ratio of each eigenvalue of the sample's Laplacian to the original's, in ascending order: it stays between 0.654 and 1.38, so every quadratic form, every cut and every solve is preserved to that factor. The open curve is the ratio of each vertex's degree, which runs from 0.719 to 1.31 — half the graph's degrees are wrong by more than a third. And the graph's diameter goes from 1 to 2: no shortest path survives. A sparsifier preserves what the Laplacian says and nothing else about the graph, and the two are easy to confuse because they are the same object.19172533414911.251.51.752indexsample ÷ originalkept, and not keptedges kept887of1225eigenvalue ratio, low0.65high1.4degree ratio, low0.72high1.3diameter, after2filled dots are eigenvaluesopen dots are degrees
Fig. 4 Sixteen hundred samples, 887 edges: eigenvalues 0.654 to 1.38.
1123 of 1225 edges keep every eigenvalue and no degreeA fifty-vertex complete graph sparsified by keeping 3200 samples drawn in proportion to each edge's effective resistance and reweighted by the reciprocal of its probability, which leaves 1123 distinct edges of 1225. The filled curve is the ratio of each eigenvalue of the sample's Laplacian to the original's, in ascending order: it stays between 0.721 and 1.22, so every quadratic form, every cut and every solve is preserved to that factor. The open curve is the ratio of each vertex's degree, which runs from 0.758 to 1.16 — half the graph's degrees are wrong by more than a third. And the graph's diameter goes from 1 to 2: no shortest path survives. A sparsifier preserves what the Laplacian says and nothing else about the graph, and the two are easy to confuse because they are the same object.19172533414911.251.51.752indexsample ÷ originalkept, and not keptedges kept1123of1225eigenvalue ratio, low0.72high1.2degree ratio, low0.76high1.2diameter, after2filled dots are eigenvaluesopen dots are degrees
Fig. 5 And thirty-two hundred, keeping 1,123 of 1,225 edges — 92% of them — for an eigenvalue band of 0.721 to 1.22.

The last figure is the one that prices the whole method. Thirty-two hundred samples retain 1,123 of the graph’s 1,225 edges: the sparsifier is 92% of the original and the spectral band is still 1.7 wide. So the tightening is bought by giving up the sparsity, and the interesting regime is the left of the sweep rather than the right — at 800 samples the graph is half its original size with a band of 2.6, and past that each halving of the band costs most of what was saved. A guarantee that converges only as the approximation becomes the original is a guarantee about existence rather than about a useful setting, which is the same shape the oversampling essays reach from the randomised side.

The diameter is starker. A complete graph has diameter one: every pair is adjacent. The sample has diameter three at 400 samples and two at 800. No shortest path survives. Every pair of vertices that was one hop apart is now up to three, and a routing algorithm run on the sparsifier would return answers that are wrong by a factor rather than by a percentage.

The band is not the same as the error

One reading of the eigenvalue column needs correcting before it becomes a habit, and it is the reading that treats the band as an accuracy.

The guarantee is a relative distortion of a quadratic form, applied uniformly. So a solve using the sparsified Laplacian as a preconditioner converges at a rate governed by the band’s width — a band of 0.43 to 1.67 is a condition number of 3.9 for the preconditioned system, which is excellent — and the answer it converges to is the answer to the original system, exactly, because the preconditioner does not change the problem.

That is the use in which the band is an accuracy of nothing and a cost of something.

The other use is to solve with the sparsifier directly, treating it as a substitute for the graph. The answer is then wrong by the band: a solve with L’ rather than L returns a vector differing from the true one by a relative amount of order ε, and at 400 samples that is tens of per cent. Which is usually not what anybody wanted.

So the same object is either a free speedup or a large approximation error depending on which side of the solve it is put on, and the distinction is not visible in the object. The preconditioning essays make the general form of this argument: an approximate inverse used as a preconditioner is exact in the answer and approximate in the cost, and used as a solver is the reverse.

Why the two are so easy to confuse

The trap is that the sparsifier is the graph, in the sense that it is a set of vertices and weighted edges, and every graph algorithm will run on it and return something.

Run a spectral partitioner on it and the answer is right, because a partition is a quadratic form. Run a solver on it as a preconditioner and it works, because a solve is a quadratic form. Run a shortest-path algorithm on it and the answer is wrong, and nothing warns, because the input was a perfectly well-formed graph.

The general form of that is a shape this site keeps meeting: an approximation preserves the quantity it was built to preserve, and an object that is an approximation for one purpose is not labelled as such. The half of a problem a sketch may touch makes the same argument about randomised sketching — a sketch is a valid input to any routine and is a valid approximation for only some of them — and a rank that is a number of digits makes it about a hierarchical format.

When it fails outright

There is a failure worse than a wide band, and the sampler is not immune to it.

At 200 samples on an eighty-vertex two-block graph, the sample came back disconnected — one vertex with no edges at all. Its eigenvalue ratios then include a zero where the original had a positive eigenvalue, which is not a factor of ε; it is a quadratic form that vanishes on a vector where the original’s does not, and the guarantee has failed completely rather than by a margin.

Undersampling is the whole cause, and there is a bound saying how many samples are enough — of order n log n divided by ε² — with constants nobody uses because they are pessimistic by orders. So in practice the sample count is chosen by measurement, and the measurement to make is not the eigenvalue band but whether the sample is connected, which costs one breadth-first search and catches the catastrophic case before the numerical one.

Which is a stronger recommendation than it sounds

That reads as advice about ordering — check the cheap thing first. Measured, the two quantities do not merely fail in an order; they behave completely differently in the sample count. Twelve seeds at each of several counts, on the eighty-vertex two-block graph:

q connected worst band over the connected samples
150 1 of 12 0.809 … 1.278
200 8 of 12 0.727 … 1.355
300 11 of 12 0.760 … 1.305
500 12 of 12 0.780 … 1.221
800 12 of 12 0.835 … 1.167
2000 12 of 12 0.902 … 1.119

Connectedness has a threshold and the band does not. The connected fraction goes from one in twelve to twelve in twelve across a threefold range of q; the band conditional on connectedness moves from 1.36 to 1.12 across a tenfold one — and is already inside a factor of 1.3 at the count where only one sample in twelve survives at all.

So the check is not a cheap precaution taken before an expensive one. It is the whole of the difference between a usable sparsifier and a broken one on this family. A connected sample is within a factor of 1.4 of the original’s quadratic form at every count tried; a disconnected one has a form that vanishes on a vector where the original’s does not. There is no regime in which the band is what decides.

That also says what the sample count is buying, which is not what the ε in the theorem suggests. It is not buying accuracy — the band barely moves — it is buying the probability of connectedness. A code that sampled until connected and then stopped would be spending its draws on the quantity that decides the outcome, and the theorem’s n log n / ε² is sizing the wrong one: ε is the parameter in the bound and connectivity is the parameter in practice.

One caution belongs with that, and it is the reason the theorem sizes what it sizes. Sampling until connected and stopping is a data-dependent stopping rule, and the guarantee above is a statement about a fixed number of independent draws. Conditioning on the outcome is exactly the operation that invalidates it: the connected samples at q = 150 are the lucky one in twelve, and their band being 1.28 is a fact about that selection rather than a bound on what the next lucky draw would give.

So the honest procedure has two parts and only the first is free. Check connectivity, because a disconnected sample is not an ε-approximation of anything. And then, if the guarantee is being relied on rather than merely hoped for, take the sample count from the bound and accept its constants — because the count that makes connectedness likely and the count that makes the theorem apply are different numbers, and this measurement says only that the first is much smaller than the second.

That is the same asymmetry the randomised field describes: the guarantee changes kind, from a bound that holds to a bound that holds with a probability, and the low-probability event is not a slightly worse answer but a different one.

187 of 1225 edges keep every eigenvalue and no degreeA fifty-vertex complete graph sparsified by keeping 200 samples drawn in proportion to each edge's effective resistance and reweighted by the reciprocal of its probability, which leaves 187 distinct edges of 1225. The filled curve is the ratio of each eigenvalue of the sample's Laplacian to the original's, in ascending order: it stays between 0.289 and 2.02, so every quadratic form, every cut and every solve is preserved to that factor. The open curve is the ratio of each vertex's degree, which runs from 0.375 to 1.75 — half the graph's degrees are wrong by more than a third. And the graph's diameter goes from 1 to 3: no shortest path survives. A sparsifier preserves what the Laplacian says and nothing else about the graph, and the two are easy to confuse because they are the same object.19172533414911.251.51.752indexsample ÷ originalkept, and not keptedges kept187of1225eigenvalue ratio, low0.29high2degree ratio, low0.37high1.7diameter, after3filled dots are eigenvaluesopen dots are degrees
Fig. 6 Two hundred samples on the same graph, where the band is twice as wide and the degrees are wrong by up to seventy-five per cent.

Why resistance is the right probability

Uniform sampling fails on graphs where sparsification is most wanted, and the refusal in this field is exactly that case.

A barbell is two cliques joined by one edge. Keeping edges uniformly at random with probability a quarter keeps about a quarter of the clique edges, which is plenty — the cliques are massively redundant — and keeps the bridge with probability a quarter. Three times in four the sample is disconnected, and a graph in two pieces does not approximate a connected one in any sense at all.

Resistance sampling keeps the bridge with probability one. Its effective resistance is 1, the largest in the graph by a factor of about k², so it takes a proportionate share of the samples and the construction cannot lose it.

That is the informal reading of what effective resistance measures: how much of the graph’s connectivity an edge is personally responsible for. An edge in a clique has dozens of parallel routes and low resistance; a bridge has none and resistance 1. Sampling in proportion to it is sampling in proportion to irreplaceability, and the spectral form of the quantity says why: a high-resistance edge is one the low eigenvalue modes depend on.

What it costs to build

The awkward part of the construction is that computing the sampling probabilities requires all the effective resistances, and computing those requires solving with the Laplacian — which is the thing the sparsifier was going to make cheaper.

Three ways round it, in increasing order of practicality.

Solve exactly anyway. For a graph small enough this is what the figures here do, and it makes the measurement clean at the cost of making the construction pointless.

Estimate the resistances. They can be approximated by a Johnson–Lindenstrauss projection — project the incidence matrix onto O(log n) random directions and read the resistances as squared distances — which needs only O(log n) approximate solves rather than n exact ones. That is the route that makes the whole thing practical, and it is a randomised approximation inside a randomised approximation.

Or use something cheaper as a proxy. Sampling by weight, or by an edge’s position in a spanning tree, gives weaker guarantees and is sometimes enough.

The recursion in the second route is worth noticing: to sparsify a graph cheaply, one needs to solve with it cheaply, which is what sparsification is for. The published algorithms break the circle by building a chain of progressively sparser graphs, each used to precondition the solve that builds the next.

Sampling with replacement, and the edges kept twice

A detail of the construction is worth pulling out because it is where the count of edges and the count of samples part company.

The sampling is with replacement, so 400 samples do not produce 400 edges. They produced 344 in the table above, because fifty-odd of the draws duplicated an edge already kept, and a duplicate adds its weight rather than appearing twice.

That gap widens as the sample count rises relative to the number of edges: 3,200 samples on a graph with 1,225 edges keep 1,123 of them, so at that point 65 per cent of the draws are duplicates and the sparsifier is nearly the original graph with slightly wrong weights.

Two consequences. First, the sample count is the right knob and the edge count is the wrong one: asking for “half the edges” does not determine the accuracy, because how many distinct edges a given number of draws produces depends on the resistance distribution. Second, the construction degrades gracefully into the identity — oversampling gives back something close to the original graph with a narrow band, which is a sensible limit for a randomised method to have and is not automatic.

The weights of the kept edges are also not the original weights. An edge kept once in 400 draws with probability p carries w/(400p), which is w only if it was drawn exactly its expected number of times. So a sparsifier of an unweighted graph is a weighted graph, always, and any downstream code that assumes unit weights is reading a third thing that was not preserved.

What to check when using one

Three things, and the order matters because they fail in this order.

Connectivity. One breadth-first search, which is also the exact route to a component count. A disconnected sample is not an ε-approximation of anything and is the failure mode of undersampling.

The spectral band. For a graph small enough to diagonalise, the ratio of each eigenvalue to the original’s is the direct measurement of ε and takes no argument about constants. For a larger one, the extreme eigenvalues of L’⁺L by a few iterations of a Lanczos process bound the band from both sides.

And the list of things not preserved. Degrees, distances, triangle counts, edge counts, anything local. A sparsifier is an approximation in one norm and in no other, and a pipeline that hands it to a routine reading a degree has substituted a different graph.

The last of those is the one that costs afternoons, because it produces answers rather than errors — which is this site’s most-repeated observation, and is why the essay measures the degrees and the diameter beside the spectrum rather than only the thing that works.

What this field gets from the randomised one

The construction is a randomised method and it inherits the whole of that field’s vocabulary, which is worth stating because the inheritance is exact rather than analogical.

The guarantee changes kind. Everything else in the graph field is deterministic: a conductance is below a bound or it is not. A sparsifier’s band holds with a probability, and the failure event — undersampling to disconnection — is not a slightly worse answer.

The seed is part of the answer. Two sparsifiers of one graph, from two seeds, are different graphs with different degrees and different diameters, and both satisfy the theorem. Reporting one without its seed makes the result irreproducible in exactly the way the seed essays describe.

And the band should be drawn rather than stated. A single run’s eigenvalue ratios are one draw from a distribution, so quoting “ε = 0.5” from one run is quoting a sample. The figures here draw the whole spectrum’s ratios, which is one run seen completely rather than summarised, and the honest version over seeds would be a band of bands.

What the graph field adds in return is a sampling probability that is not uniform and not heuristic. Most randomised methods on this site sample uniformly or with Gaussian weights, because nothing better is available; here the right probability is a computable property of each edge, it is what makes the guarantee hold for every vector at once, and the identity that normalises it is a hundred-year-old theorem about electrical networks.

What links here

Computed from the collection, not written here: the essays that point at this one.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A flat tag is an object no other essay names yet.

Degree sequenceEffective resistanceFoster theoremGraph laplacianImportance samplingQuadratic formRandomisedSpectral sparsification