e01.org

Seidel's algorithm

Seidel's algorithm is an algorithm designed by Raimund Seidel in 1992 for the all-pairs-shortest-path problem for undirected, unweighted, connected graphs. It solves the problem in O(V^\omega \log V) expected time for a graph with V vertices, where \omega is the exponent in the complexity O(n^\omega) of n \times n matrix multiplication. If only the distances between each pair of vertices are sought, the same time bound can be achieved in the worst case. Even though the algorithm is designed for connected graphs, it can be applied individually to each connected component of a graph with the same running time overall. There is an exception to the expected running time given above for computing the paths: if \omega = 2 the expected running time becomes O(V^2 \log^2 V) .

Seidel's algorithm is an algorithm designed by Raimund Seidel in 1992 for the all-pairs-shortest-path problem for undirected, unweighted, connected graphs. It solves the problem in O(V^\omega \log V) expected time for a graph with V vertices, where \omega is the exponent in the complexity O(n^\omega) of n \times n matrix multiplication. If only the distances between each pair of vertices are sought, the same time bound can be achieved in the worst case. Even though the algorithm is designed for connected graphs, it can be applied individually to each connected component of a graph with the same running time overall. There is an exception to the expected running time given above for computing the paths: if \omega = 2 the expected running time becomes O(V^2 \log^2 V) . In the worst case this can be done in O(V^\omega \log V) time. Once the lengths are computed, the paths can be reconstructed using a Las Vegas algorithm whose expected running time is O(V^\omega \log V) for \omega > 2 and O(V^2 \log^2 V) for \omega = 2 . def apd(A, n: int): """Compute the shortest-paths lengths.""" if all(A[i][j] for i in range(n) for j in range(n) if i != j): return A Z = A**2 B = matrix( [ [1 if i != j and (A[i][j] == 1 or Z[i][j] > 0) else 0 for j in range(n)] for i in range(n) ] ) T = apd(B, n) X = T * A degree = [sum(A[i][j] for j in range(n)) for i in range(n)] D = matrix( [ [ 2 * T[i][j] if X[i][j] >= T[i][j] * degree[j] else 2 * T[i][j] - 1 for j in range(n) ] for i in range(n) ] ) return D The base case tests whether the input adjacency matrix describes a complete graph, in which case all shortest paths have length 1 .

source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"Seidel's algorithm". 1759957758. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1315835003

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·