Warshall's Algorithm The Path Matrix What's the path matrix (or reachability matrix) of a graph? p[i][j] is true if there's a path from node i to node j What do you get if you compute the transitive closure of the adjacency matrix? The path matrix How do you compute the path matrix from the adjacency matrix? Suppose a[i][k] and a[k][j] are both true in the adjacency matrix. What should be true in the path matrix? What happens if you check a[i][k] and a[k][j] for all possible triples of nodes (k, i, j)? for (k = 0; k < n; k++) for (i = 0; i < n; i++) for (j = 0; j < n; j++) if (a[i][k] && a[k][j]) a[i][j] = true; What's the node k commonly called? This algorithm is called Warshall's Algorithm. Warshall's Algorithm computes transitive closure. Show the steps of Warshall's algorithm. Give the matrix after using each node as the pivot. (after each iteration of the outside loop) (graph4.pdf) a b c d e a - 1 - 1 - b 1 - 1 - - c - - - - 1 d 1 - - - 1 e - 1 - - - Classwork You may work with a partner. Show the steps of Warshall's algorithm. Give the matrix after pivoting with each node. (graph5.pdf) a b c d e a - - 1 - 1 b - - - - - c 1 - - - - d - 1 - - - e - - 1 1 -