4 graph treversal
4 graph treversal
There are two graph traversal techniques and they are as follows...
DFS (Depth First Search)
BFS (Breadth First Search)
DFS (Depth First Search)
DFS traversal of a graph, produces a spanning tree as final result.
Spanning Tree is a graph without any loops. We use Stack data
structure with maximum size of total number of vertices in the graph to
implement DFS traversal of a graph.
Example
2- BFS (Breadth First Search)
BFS traversal of a graph, produces a spanning tree as final result.
Spanning Tree is a graph without any loops. We use Queue data
structure with maximum size of total number of vertices in the graph to
implement BFS traversal of a graph.