- G = (V, E)

- BFS, use FIFO queue to process all adjacent vertices. generate only one tree. it can be used for shortest path (without weight on path) of two vertices.

graphic

graphic

- DFS, process it with start time and finish time. could generate multiple trees.

graphic

graphic

- Topological sort, sort by finish time in descending order

graphic

- strong-connected components

  • generate DFS trees of G
  • generate reversed graphic G1 of G
  • sort vertices by finish time in main loop of DFS of G1
  • output vertices of each tree of the second DFS of G1

相关文章: