Graph Theory37 sections · 1633 units
Open in Course

Transitive Closure

Reachability instead of dis...

Transitive closure asks: can you reach vertex jj from vertex ii?

You can adapt Floyd-Warshall: instead of minimizing distance, use boolean OR. Set reach[i][j] = true if there is a path from ii to jj. Update: reach[i][j] = reach[i][j] || (reach[i][k] && reach[k][j]). This computes reachability in O(n3)O(n^3) time. It answers questions like "is there any path from ii to jj?" without caring about distance.

Space complexity is O(n2)O(n^2) for the data structures used.