Depth-First Search

  • Defined as starting from multiple sources, until all vertices are traversed.
  • Predecessor subgraph: , where , a depth-first forest consists of multiple depth-first trees.
  • Two timestamps: discover time and finish time . i.e. is white before , gray between and , and black after .
  • Parenthesis structure
  • Four types of edges in
    • Tree edges, edges in
    • Back edges, proper descendants to predecessors
    • Forward edges, predecessors to proper descendants
    • Cross edges
  • DFS trees of unweighted graph contain only tree edges and back edges.
  • A directed graph is acyclic iff yields no back edges.
  • Very hard to parallelize!