Given a graph G = (V, E) (directed or undirected) with n = |V| vertices and m = |E| edges:
Formal Definition
A path p from source s to destination t is a sequence of vertices p = (v_0, v_1, v_2, \dots, v_k) where v_0 = s, v_k = t, and (v_{i-1}, v_i) \in E for all i \in \{1, \dots, k\}.
Shortest paths are among the most pervasive algorithmic primitives in modern computing:
How practical domains map to our graph-theoretic models:
| Domain | Weight Model | Vertices (V) & Edges (E) | Cost Semantics |
|---|---|---|---|
| GPS Navigation | Weighted (w \ge 0) | Intersections & Roads | Travel duration / Distance |
| Internet Routing | Weighted (w > 0) | Routers & Network Links | Latency & Link Congestion |
| Social Networks | Unweighted (w = 1) | Users & Connections | Number of friend / follower hops |
| Robotics & Motion | Weighted (w \ge 0) | Configuration States | Actuator energy / Path clearance |
| Financial Arbitrage | Arbitrary (w \in \mathbb{R}) | Currencies & Rates | -\log(\text{rate}): negative cycles = profit |
| Problem | Algorithm | Time Complexity | Graph Model / Allowed Weights |
|---|---|---|---|
| SSSP | Dijkstra | O(m + n \log n) | Directed/Undirected, Non-negative (w \ge 0) |
| SSSP | Bellman–Ford | O(mn) | Directed, Arbitrary weights (no negative cycles) |
| APSP | Floyd–Warshall | \Theta(n^3) | Dense graphs, Arbitrary weights |
| APSP | n \times \text{BFS} | O(nm) \to \mathbf{O(n^3)} | Unweighted (w = 1) |
| APSP | Seidel’s Algorithm | \mathbf{\tilde{O}(n^\omega) \approx O(n^{2.372})} | Undirected, Unweighted (w = 1) |
Can linear algebra compute shortest paths?
Let A be the unweighted adjacency matrix of graph G.
Matrix Multiplication Property: (A^k)_{u,v} = \sum_{i_1, i_2, \dots, i_{k-1}} A_{u, i_1} A_{i_1, i_2} \cdots A_{i_{k-1}, v}
(A^k)_{u,v} counts the exact number of walks of length k from u to v.
Unweighted Shortest Path Distance: d(u,v) = \min \{ k \ge 0 \mid (A^k)_{u,v} > 0 \}
In ordinary matrix algebra over ring (\mathbb{R}, +, \times), computing A^2 takes O(n^\omega) time (\omega < 2.372).
Can we compute high powers A^k without performing k sequential multiplications?
Repeated Squaring (Binary Exponentiation)
Compute powers by repeatedly squaring previous results: A \longrightarrow A^2 \longrightarrow A^4 \longrightarrow A^8 \longrightarrow \cdots \longrightarrow A^{2^{\lfloor \log_2 k \rfloor}}
Recursive Formulation: A^k = \begin{cases} (A^{k/2})^2 & \text{if } k \text{ is even} \\ A \cdot (A^{(k-1)/2})^2 & \text{if } k \text{ is odd} \end{cases}
Operation Count: Requires only \lceil \log_2 k \rceil matrix multiplications!
Total Runtime: O(n^\omega \log k)
When k = n, we can compute A^n in O(n^\omega \log n) time.
Does there exist a path between u and v in G?
The Path Length Bound: In any graph with n vertices, any simple path has length at most n - 1.
The Reachability Criterion: \exists \text{ path } u \rightsquigarrow v \iff (A + A^2 + A^3 + \dots + A^{n-1})_{u,v} > 0
If (A^k)_{u,v} > 0 for any 1 \le k \le n - 1, there exists a walk (and hence a simple path) of length \le n - 1 between u and v.
Transitive Closure Matrix: T = \sum_{k=0}^{n-1} A^k A pair (u, v) is connected if and only if T_{u,v} > 0.
Can we sum all powers of A in a single matrix inversion?
The Matrix Geometric Series (Neumann Series)
Recall the scalar geometric series: for |x| < 1, \sum_{k=0}^\infty x^k = \frac{1}{1 - x}. For a matrix A (scaled so spectral radius \rho(A) < 1): \sum_{k=0}^\infty A^k = (I - A)^{-1}
Algebraic Verification: (I - A) \big(I + A + A^2 + \dots + A^k\big) = I - A^{k+1}
If A^{k+1} \to 0 (or working over formal power series \mathbb{R}[[A]]): (I - A) \sum_{k=0}^\infty A^k = I \implies \sum_{k=0}^\infty A^k = (I - A)^{-1}
Algorithmic Takeaway: The entries of (I - \epsilon A)^{-1} encode all-paths reachability and walk counts across all lengths simultaneously!
Seidel’s Algorithm & The Isolation Lemma — Solving unweighted APSP in \tilde{O}(n^\omega) via fast matrix multiplication over \mathbb{Z}, and parallel matchings via the MVV Isolation Lemma.
CS G526: Advanced Algorithms & ComplexityTulasimohan Molli