Home  Writing  Games  Music  Dev  About 

Graphs

Searching

DFS traversal Iterative using Stack

  1. push root vertex to stack
  2. pop vertex from stack (LIFO, so will be the last pushed vertex) and mark as visited
  3. push children or connected vertices of popped vertex to stack.
  4. Repeat from 2 until no more unvisted vertices left, or element found

DFS traversal Recursive

  1. Start from Root
  2. On each child of root, recursively go through each child's children
  3. So follow one branch until find a leaf, then head back up and follow down the next branch until find a leaf.

Minimal Spanning Tree

Topological Sort

implement

A* Algorithm

Dijkstra's algorithm