From charlesreid1

No edit summary
Line 27: Line 27:
* [[Graphs/Euler Tour]]
* [[Graphs/Euler Tour]]


Related pages on tree traversal:
Tree traversal:
* [[Trees/Preorder]]
* [[Trees/Preorder]]
* [[Trees/Postorder]]
* [[Trees/Postorder]]
* [[Trees/Inorder]]
* [[Trees/Inorder]]


Related pages on breadth-first search and traversal:
Breadth-first search and traversal on trees:
* [[BFS]] - breadth first search
* [[BFS]] - breadth first search
* [[BFT]] - breadth first traversal
* [[BFT]] - breadth first traversal


Related pages on  
Depth-first search and traversal on trees:
* [[DFS]] - depth first search
* [[DFS]] - depth first search
* [[DFT]] - depth first traversal
* [[DFT]] - depth first traversal

Revision as of 15:40, 7 September 2017

Notes

Definition

Graph traversal is a systematic method for walking through every vertex and edge in the graph. Generally, a traversal visits each vertex exactly once. However, with an Euler tour (traversal), each edge is visited exactly once.

There are some similarities with tree traversal, but graph traversal is basically a more general version of tree traversal - trees are DAGs (directed acyclic graphs), so tree traversals are traversals on a DAG.

Recursion is an important concept in both graph and tree traversal - specifically for depth-first traversal methods.

Traversal is a useful building block for other algorithms. Traversal helps address questions of reachability - whether and how you can reach one vertex from another, finding the shortest path, finding whether a graph is connected, finding cycles, and finding spanning trees.

These algorithms all build on the idea of graph traversal, so this is a really important concept to nail down before moving on to other graph algorithms!

Depth first search and traversal generally uses recursion and backtracking to traverse all vertices on the graph.

Breadth first search and traversal generally uses a queue data structure to traverse all vertices on a graph. As each vertex is visited, neighbors of said vertex are added to the queue. Once a particular vertex is visited, the next vertex to visit is obtained by popping an item from queue.

Related

Recursion:

On a graph:

Tree traversal:

Breadth-first search and traversal on trees:

  • BFS - breadth first search
  • BFT - breadth first traversal

Depth-first search and traversal on trees:

  • DFS - depth first search
  • DFT - depth first traversal

Flags