This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: if e is not explored: if vertex w is unexplored: label e as a discovered edge DFS(w) else: label e as a back edge example black edges: discovered gray edges: back Directed Graph (digraph) (12.4, p. 611) a graph with directional edges one-way streets Makefile dependencies terms acyclic strongly connected: each vertex can reach all other vertices each strongly connected subgraph must be cyclic Transitive Closure (12.4.2, p. 615) denoted G* if there is a path A-B-C, add an edge AC computation DFS for each vertex v: for each vertex w in DFS(v): add (v,w) to G* Floyd-Warshall algorithm G* = G for k = 1 upto n for j = 1 upto n for i = 1 upto n if (i != j && j != k && i != k && (vi, vk) in G* G* += (vi, vj) comparably costly: O(n^3) Floyd-Warshall is easier to implement DFS only wins if the graph is sparse and represented w/ an adjacency list...
View Full Document