Demo Dfs Directed 1

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 18

Directed Depth First Search

Adjacency Lists
B I H C

A: B: C: D: E: F: G: H: I:

F G A H A D C F C D G E: : B: H:

Directed Depth First Search


A

B I

Undiscovered Marked Active Finished

dfs(A)
A-F A-G

Function call stack:


2

Directed Depth First Search


A

B I

visit(F) F-E

Undiscovered Marked Active Finished

dfs(A)
A-F A-G

Function call stack:


3

Directed Depth First Search


A

B I

dfs(E)
E

E-C E-D E-G


dfs(F) F-E

Undiscovered Marked Active Finished

dfs(A)
A-F A-G

Function call stack:


4

Directed Depth First Search


A

B I

dfs(C) C-A C-D


D

dfs(E)
E

E-C E-D E-G


dfs(F) F-E

Undiscovered Marked Active Finished

dfs(A)
A-F A-G

Function call stack:


5

Directed Depth First Search


A

B I

dfs(C) C-A C-D


D

dfs(E)
E

E-C E-D E-G


dfs(F) F-E

Undiscovered Marked Active Finished

dfs(A)
A-F A-G

Function call stack:


6

Directed Depth First Search


A

dfs(D)
B I H C

D-C D-F dfs(C) C-A C-D

dfs(E)
E

E-C E-D E-G


dfs(F) F-E

Undiscovered Marked Active Finished

dfs(A)
A-F A-G

Function call stack:


7

Directed Depth First Search


A

dfs(D)
B I H C

D-C D-F dfs(C) C-A C-D

dfs(E)
E

E-C E-D E-G


dfs(F) F-E

Undiscovered Marked Active Finished

dfs(A)
A-F A-G

Function call stack:


8

Directed Depth First Search


A

dfs(D)
B I H C

D-C D-F dfs(C) C-A C-D

dfs(E)
E

E-C E-D E-G


dfs(F) F-E

Undiscovered Marked Active Finished

dfs(A)
A-F A-G

Function call stack:


9

Directed Depth First Search


A

B I

dfs(C) C-A C-D


D

dfs(E)
E

E-C E-D E-G


dfs(F) F-E

Undiscovered Marked Active Finished

dfs(A)
A-F A-G

Function call stack:


10

Directed Depth First Search


A

B I

dfs(E)
E

E-C E-D E-G


dfs(F) F-E

Undiscovered Marked Active Finished

dfs(A)
A-F A-G

Function call stack:


11

Directed Depth First Search


A

B I

dfs(E)
E

E-C E-D E-G


dfs(F) F-E

Undiscovered Marked Active Finished

dfs(A)
A-F A-G

Function call stack:


12

Directed Depth First Search


A

B I

dfs(G)
D

dfs(E)
E

E-C E-D E-G


dfs(F) F-E

Undiscovered Marked Active Finished

dfs(A)
A-F A-G

Function call stack:


13

Directed Depth First Search


A

B I

dfs(E)
E

E-C E-D E-G


dfs(F) F-E

Undiscovered Marked Active Finished

dfs(A)
A-F A-G

Function call stack:


14

Directed Depth First Search


A

B I

dfs(F) F-E

Undiscovered Marked Active Finished

dfs(A)
A-F A-G

Function call stack:


15

Directed Depth First Search


A

B I

Undiscovered Marked Active Finished

dfs(A)
A-F A-G

Function call stack:


16

Directed Depth First Search


A

B I

Undiscovered Marked Active Finished

dfs(A)
A-F A-G

Function call stack:


17

Directed Depth First Search


A

B I

Undiscovered Marked Active Finished

Function call stack:


18

You might also like