1. The document describes the depth-first search (DFS) and breadth-first search (BFS) algorithms on both undirected and directed graphs.
2. For DFS on an undirected graph, it provides an example trace showing the explored, visited, and solved vertices at each iteration to find the shortest path from A to C to F.
3. For BFS on an undirected graph, it again provides an example trace showing the open and closed vertices at each iteration to find the shortest path from A to F.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
9 views
DFS Algorithm in Undirected Graph
1. The document describes the depth-first search (DFS) and breadth-first search (BFS) algorithms on both undirected and directed graphs.
2. For DFS on an undirected graph, it provides an example trace showing the explored, visited, and solved vertices at each iteration to find the shortest path from A to C to F.
3. For BFS on an undirected graph, it again provides an example trace showing the open and closed vertices at each iteration to find the shortest path from A to F.
0 [A] EMPTY 1 A [B,C,D] A 2 B [G,I, C,D] A,B 3 G [I,C,D] A,B,G 4 I [C,D] A,B,G,I 5 C [E,F,D] A,B,G,I,C 6 E [K,F,D] A,B,G,I,C,E 7 K [F,D] A,B,G,I,C,E,K 8 F [D] A,B,G,I,C,E,K,F D EMPTY A,B,G,I,C,E,K,F,D Shortest path: A → C → F
DFS In directed graph:
FIND THE SHORTEST PATH FROM A TO B BY USING DFS SEARCH
Find the shortest path from A to F by using BFS algorithm.
Iteration Vertex Open CLose
0 [A] [] 1 A [B,C,D] A 2 B [C,D,G,I] A,B 3 C [D,G,I,E,F] A,B,C 4 D [G,I,E,F] A,B,C,D 5 G [I,E,F] A,B,C,D,G 6 I [E,F] A,B,C,D,G,I 7 E [F,K] A,B,C,D,G,I,E 8 F [K] A,B,C,D,G,I,E,F K EMPTY A,B,C,D,G,I,E,F,K
Shortest path: A → C → F BFS in directed graph: Find the Shortest path from A to B by using BFS