GF4: Algorithms on DAGs

San Skulrattanakulchai

November 8, 2018

Topics

Directed Acyclic Graphs (DAG’s)

Topological sort

Topological sort algorithm

Implementation

Implementation, continued

Running Time

Notes

  1. Our algorithm shows that numbering the vertices in decreasing finish time gives a topological numbering.
  2. Would numbering the vertices in order of increasing discovery time gives a valid topological numbering?
  3. Knuth's topological sort algorithm works by repeatedly finding a source \(s\), assigning the next lowest number to \(s\), and deleting \(s\) from the current graph. His algorithm can also be implemented in linear time.

Longest path in a weighted dag

Longest path algorithm

Notes

  1. Give the opposite recurrence & dynamic programming solution to this problem.
  2. The longest paths in a dag are known as “critical paths” when doing Critical Path Method.
  3. Finding a longest path in a general graph is NP-complete.
  4. Our algorithm illustrates dynamic programming in dags. Similar algorithms exist for finding a longest path from s to t; a shortest path from s, etc.