- More on Depth First Search on directed and undirected
graphs: collecting information about vertices and edges. White
(not seen yet),
grey (considered but not finished) and black (finished) vertices.
Edges: tree, back, forward and cross edges.
- What types of edges are possible in undirected graphs?
- DFS numbering: prefix or postfix numbering of the visited vertices.
- Linear time algorithms for:
- Deciding connectivity of an
- Finding directed cycles in a digraph. Lemma: a
digraph is acyclic iff there are no back edges.
if the graph is bipartite. Lemma: a graph is bipartite
iff it does not contain an odd cycle.
- Application: Linear time algorithm for strongly connected
- Decomposition into strongly connected components and the
condensed graph of a digraph.
- Do a DFS traversal of the digraph, label the vertices in
postfix DFS order.
- Compute the reversed digraph (all arrows are
- Perform DFS of the reverse graph beginning at the highest
numbered vertex. If the search does not visit all the vertices,
choose the highest numbered unvisited vertex and resume the
- Continue until all vertices are visited. In the resulting
forest, each tree contains the vertices of a strongly connected
- Application: Topological Sort. Algorithm:
- Perform a DFS on the directed graph, check for acyclicity (if
- Label the vertices in postorder (by finishing time).
- As each vertex is finished, insert it in front of a linked
- Return the linked list of vertices.