Graph Traversals and Topological Sorting

Graph Traversal

Topological Sorting

  1. Theorem 17: A graph can be topologically sorted iff it is acyclic. There are two cycles in E: BCD and BDE. Therefore, to get a graph that can be sorted topologically, we need to remove (C,D) and (E,D).
E=E{(C,D),(E,D)}
  1. topological sorting = A D B C E

Explanation: ord of nodes:

n | number of edges
--------------------------
1 | 0
2 | 1
3 | 2+1 = 3
4 | 3+2+1 = 6

Conjuncture: The maximum number of edges in a directed graph with n vertices that can be topologically sorted is:

i=1n1i=n(n1)2