Graphs

less than 1 minute read

Graphs

full

Explore a graph, e.g:

  • find a path from start vertex s to a desired vertex
  • visit all vertices or edge of graph, or only those reachable from s

    Graph Representations

    full

  • level 0={s}
  • level = vertices reachable by path of i edges but not fewer
  • build level i>0 from level i-1 by trying all outgoing edges, but ignoring vertices from previous levels
  • O(V+E) (Linear time) full

    Shortest Paths

    full

    full full full

    Cycle Detection

    Graph G has a cycle <=> DFS has a back edge full

Source

https://ocw.mit.edu/courses/6-006-introduction-to-algorithms-fall-2011/pages/lecture-notes/

Updated: