Abstract

In a graph, there consists of many types of edges that connects from node to node


Tree Edge (Forward Edge)

A solid edge included in the DFS Output Tree, in other words, edges that have been visited by Depth First Search (DFS) or Explore. This edge leads to a descendent

Note

Although Tree Edge and Forward Edge are similar in both directing an edge forward down the graph, the Forward Edge specifies any edge that connects to a node that may require 2 or more edges in the tree to reach said node

Pre/Post Number Determination

is a tree/forward edge when


Back Edge

An edge that is not included in the DFS Output Tree that leads to an ancestor

Note

Back Edge is slightly different in directed and undirected graphs

Back edges in an undirected graph that has been explored are edges in that are not in the DFS tree of but connects vertices in the DFS output tree.

Removing a back edge will not disconnect the graph

Removing an edge that is in a cycle will not disconnect an undirected graph and removing an edge that is not in a cycle will disconnect an undirected graph

Graph Cycles Theorem

An undirected connected graph has a cycle if and only if it’s DFS output tree has a back edge.

Proof:

  1. If has a cycle → DFS output has a back edge
  2. If DFS has a back edge → has a cycle

Pre/Post Number Determination

is a back edge when


Cross Edge

An edge that is not included in the DFS Output Tree that leads to neither and ancestor nor descendent

Pre/Post Number Determination

is a cross edge when


Example

Given this graph:

Run Depth First Search (DFS) starting from vertex , we get the following output:

ccpostprevpre
A1161
B163C
C1152A
D154B
E1147C
F198E
G11310E
H11211G

From this table, we find the following DFS Output Forest