Graph Traversal: BFS: Breadth First Search
Graph Traversal: BFS: Breadth First Search
Graph Traversal: BFS: Breadth First Search
F B G C
C B
C F
D C
E D C J
D E F D
G
G C E
J D K
J K
HK Rana, Dept. of CSE, GUB K E G
Graph Traversal: BFS
A->J
A QUEUE ORIG
A Ø
F C B
D E G
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: BFS
A QUEUE ORIG
A Ø
F C B F A
D E G
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: BFS
A QUEUE ORIG
A Ø
F C B F A
C A
D E G
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: BFS
A QUEUE ORIG
A Ø
F C B F A
C A
B A
D E G
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: BFS
A QUEUE ORIG
A Ø
F C B F A
C A
B A
D F
D E G
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: BFS
A QUEUE ORIG
A Ø
F C B F A
C A
B A
D F
D E G
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: BFS
A QUEUE ORIG
A Ø
F C B F A
C A
B A
D F
D G B
E G
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: BFS
A QUEUE ORIG
A Ø
F C B F A
C A
B A
D F
D G B
E G
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: BFS
A QUEUE ORIG
A Ø
F C B F A
C A
B A
D F
D G B
E G
E G
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: BFS
A QUEUE ORIG
A Ø
F C B F A
C A
B A
D F
D G B
E G
E G
J E
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: BFS
A QUEUE ORIG
A Ø
F C B F A
C A
B A
D F
D G B
E G
E G
J E
J K K J
HK Rana, Dept. of CSE, GUB
Graph Traversal: BFS
A QUEUE ORIG
A Ø
F C B F A
C A
B A
D F
D G B
E G
E G
J E
J K K J
HK Rana, Dept. of CSE, GUB
Graph Traversal: BFS
Path for A->J
A QUEUE ORIG
A Ø
F C B F A
C A
B A
D F
D G B
E G
E G
J E
J K K J
HK Rana, Dept. of CSE, GUB
Graph Traversal: DFS
F B G C
C B
C F
D C
E D C J
D E F D
G
G C E
J D K
J K
HK Rana, Dept. of CSE, GUB K E G
Graph Traversal: DFS
A->J
A STACK ORIG
A Ø
F C B
D E G
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: DFS
A STACK ORIG
A Ø
F C B F A
D E G
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: DFS
A STACK ORIG
A Ø
F C B F A
C A
D E G
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: DFS
A STACK ORIG
A Ø
F C B F A
C A
B A
D E G
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: DFS
A STACK ORIG
A Ø
F C B F A
C A
B A
G B
D E G
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: DFS
A STACK ORIG
A Ø
F C B F A
C A
B A
G B
D E G
E G
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: DFS
A STACK ORIG
A Ø
F C B F A
C A
B A
G B
D E G
E G
D E
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: DFS
A STACK ORIG
A Ø
F C B F A
C A
B A
G B
D E G
E G
D E
J E
J K
HK Rana, Dept. of CSE, GUB
Graph Traversal: DFS
A STACK ORIG
A Ø
F C B F A
C A
B A
G B
D E G
E G
D E
J E
J K K J
HK Rana, Dept. of CSE, GUB
Graph Traversal: DFS
A STACK ORIG
A Ø
F C B F A
C A
B A
G B
D E G
E G
D E
J E
J K K J
HK Rana, Dept. of CSE, GUB
Graph Traversal: DFS
A STACK ORIG
A Ø
F C B F A
C A
B A
G B
D E G
E G
D E
J E
J K K J
HK Rana, Dept. of CSE, GUB
Graph Traversal: DFS
A STACK ORIG
A Ø
F C B F A
C A
B A
G B
D E G
E G
D E
J E
J K K J
HK Rana, Dept. of CSE, GUB
Graph Traversal: DFS
A STACK ORIG
A Ø
F C B F A
C A
B A
G B
D E G
E G
D E
J E
J K K J
HK Rana, Dept. of CSE, GUB
Graph Traversal: DFS
Path for A->J
A STACK ORIG
A Ø
F C B F A
C A
B A
G B
D E G
E G
D E
J E
J K K J
HK Rana, Dept. of CSE, GUB
Dijkstra Animated Example