Skip to main content

Transitive closure

Short answer

Transitive closure of a directed graph G is a graph G* with an edge (i,j) whenever a path from i to j exists in G. It is represented as a Boolean matrix and computed by Warshall's algorithm in O(n³).

What is transitive closure?

The transitive closure of a directed graph G = (V, E) is a graph G* = (V, E*) that has an edge (i, j) whenever there is a path of any length from vertex i to vertex j in G. It is stored as a Boolean matrix P where P[i][j] = 1 if j is reachable from i. It tells which vertices can reach which others, and is computed with Warshall's algorithm in O(n³).

Example: edges a→b, b→c give transitive closure edges a→b, b→c and a→c.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Data Structure and Algorithm chapter 10 questions →