Graph Journey

To search in a graph (path of Graphs), we first build a tree covering the graph.

Breadth-first search / Deep search

BFS traverses the tree increasing the depth to the root.

Breadth first search Breadth of Graphs
BFS(Graph G, Node s): {f = CreateQueue (); f.stack (s); mark (s);
  while no f.empty () s = f.pop (); print (s);
      for each children t of s in G
           yew t unmarked DO f.stack (t); mark (t);
           end if
      end for
  end while       
 }

In-depth search: pre-order

In-depth algorithms are recursive. In the prefix path, we always traverse the left subtree before processing the right subtree.

In-depth search: pre-order
  1. Check if the current node is empty or null.
  2. Displays the data portion of the root (or current node).
  3. Traverse the left subtree by recursively calling the preorder function.
  4. Traverse the right subtree by recursively calling the preorder function.

In-depth search: in-order

The LNR traverses as far left as possible, and displays branches from left to right. This algorithm displays diagonals from bottom to top.

In-depth search: in-order
  1. Check if the current node is empty or null.
  2. Traverse the left subtree by recursively calling the in-order function.
  3. Displays the data portion of the root (or current node).
  4. Traverse the right subtree by recursively calling the in-order function.

In-depth search: out-order

It is a diagonal navigation from top to bottom.

In-depth search: out-order
  1. Check if the current node is empty or null.
  2. Traverse the left subtree by recursively calling the post-order function.
  3. Traverse the right subtree by recursively calling the post-order function.
  4. Displays the data portion of the root (or current node).