Topological sort of a graph- how can we find a contradiction?

197 Views Asked by At

The topological sort of a graph can be considered as an order of its nodes along a horizontal line so that all the directed edges go from the left to the right.

How could we show that all the directed edges go fom the left to the right?

We suppose that it is:

enter image description here

Then it holds that $[d(w),f(w)] \subset [d(u),f(u)]$, right?

How could we find a contradiction?

PS: d(u) is the discovery time of the node u , the first time we visit it. f(u) is the finishing time of the node u , the time when it can be considered discovered.

We find these values using the DFS algorithm.

This the algorithm that it given for the topological sort:

TOPOLOGICALSORT(G)
1. Call DFS(G) to compute finishing times f(v),  for all v in V.
2. When a vertex is finished put it in front of a linked list.
3. return the linked list of vertices.