Graph Traversal Techniques
Graph traversal involves visiting all the vertices and edges in a graph. Common traversal techniques include:
- Breadth-First Search (BFS):
- Explores all neighbors of a vertex before moving to the next level.
- Uses a queue.
- Time Complexity: O(V+E).
2. Depth-First Search (DFS):
- Explores as far as possible along a branch before backtracking.
- Uses a stack (or recursion).
- Time Complexity: O(V+E).