Definition: Spanner
Let be a weighted graph and let .
A subgraph is called a -spanner of if for all vertices ,
So approximately preserves all shortest-path distances while using fewer edges.
Greedy spanner algorithm
The greedy spanner constructs a sparse -spanner as follows:
- Sort all edges in nondecreasing order by weight.
- Start with .
- For each edge in that order:
- if the current graph already contains a path from to of length at most , do not add ;
- otherwise add to .
Intuition:
- short edges are considered first;
- a later edge is only kept if the current graph does not already provide a sufficiently short detour;
- therefore many edges are discarded, and the final graph is much sparser.
Why the result is a -spanner
Consider any edge of the original graph .
When the algorithm processes , one of two things happens:
- either is inserted into ;
- or there is already a path in the current graph from to of length at most .
Hence after the algorithm finishes, every original edge has a replacement path in whose length is at most times the edge length.
Now take any two vertices and a shortest path
in . Replacing each edge by its corresponding path in gives a walk from to in of length at most
Therefore
so is indeed a -spanner.
Dynamic graphs
The classical greedy spanner algorithm is usually presented for a static graph.
Still, the greedy criterion is useful in dynamic graphs as well:
- when edges are inserted or deleted, one can try to update the spanner locally instead of rebuilding it from scratch;
- many dynamic spanner data structures are inspired by the same idea: keep an edge only if it is needed to maintain short approximate paths.
So the main characteristic is:
Dynamic viewpoint
Greedy spanner ideas extend naturally to dynamic settings, because edge decisions are based on whether a sufficiently short replacement path already exists.
Remarks
- Greedy spanners are usually sparse.
- In geometric and network settings, they are a standard tool for reducing graph size while approximately preserving distances.