The predecessor subgraph of a DFS forms a depth-first forest comprising several depth-first trees. We also do timestamps for each vertex which notice the arrival time and finished time. (u.d denote discovered time which start from parent time + 1, u.f denote finished time which end with the last child time + 1). According the time structure we have properties, for a node :
- if and are disjoint, then and are not a descendant of each other in the depth-first forest.
- if is a subset of , then is a descendant of in the depth-first forest.
We also define several edges of depth-first forest:
- tree edge: an edge such that .
- back edge: an edge , such that and . Self-loop is also a back edge.
- forward edge: an edge such that and .
- cross edge: all other edges.
An undirected graph , every edge of is either a tree edge or a back edge.
The DFS algorithm take time.