Depth-first Search in Digraphs — examples

Depth-first Search in Digraphs — examples
denotes a tree edge.
d(v), f(v) appears above or below each node v:
d(v) = discovery time of node v. The time at which node v is
first reached. The time of preorder processing.
f(v) = finish time of node v. The time at which node v is exited
for the last time. The time of postorder processing.
For a node v, active(v) = time interval d(v) to f(v) (inclusive).
Example 1: In this particular depth-first search, the alphabetically-first node is chosen, whenever an arbitrary choice is made.
2,29
1,34
A
14,27
E
3,12
B
D
30,33
31,32
F
C
13,28
H
17,22
G
L
16,23
19,20
J
K
18,21
N
O
8,9
I
15,26
5,10
Q
24,25
M
4,11
P
6,7
Example 2: Depth-first search of the same digraph. The alphabetically-last node is chosen, whenever an arbitrary choice is
made.
4,33
26,31
A
24,25
E
9,10
B
D
27,30
28,29
F
C
5,32
H
16,17
G
L
15,18
14,19
J
K
13,22
N
O
1,34
I
20,21
7,8
Q
12,23
M
6,11
P
2,3
Example 3: Depth-first search of the same digraph. In choosing
among adjacent vertices not yet discovered, the alphabeticallyfirst vertex is chosen. However, we choose H as the starting
vertex, and when the stack becomes empty (which didn’t occur
in Example 1 or 2), we choose E, then P, and then D as the next
vertex to discover.
21,30
23,28
A
13*,14
E
17*,34
B
D
24,27
25,26
F
C
18,33
N
22,29
20,31
I
1*,12
H
3,8
G
L
2,9
J
K
4,7
O
Q
10,11
M
5,6
19,32
P
15*,16
Depth-first Search in Digraphs — edges classified
Edge (u,v) is
a tree edge if
active(u) ⊃ active(v), and there is no vertex
x with active(u) ⊃ active(x) ⊃ active(v),
a forward edge
if active(u) ⊃ active(v), but (u,v) is not a
tree edge,
a back edge
if active(u) ⊂ active(v),
a cross edge
if active(u) ∩ active(v) = ∅ (in which case
active(v) entirely precedes active(u).
denotes a tree edge.
denotes a back edge.
denotes a forward edge.
denotes a cross edge.
In an undirected graph,
these two types are not
distinguishable
Here depth-first search of Example 1, with edges classified.
1,28
0,33
A
13,26
E
2,11
B
D
29,32
30,31
F
C
12,27
H
16,21
G
L
15,22
18,19
J
K
17,20
N
O
7,8
I
14,25
4,9
Q
23,24
M
3,10
P
5,6