Question

I have an intuition that topo-sort of an original graph

 A -> B -> C
 D -> B

topo-sort is [D, A, B, C] or [A, D, B, C]

If I transpose the graph

  C -> B -> A   
       B -> D

the postordering dfs of this transposed graph also gives [D, A, B, C] or [A, D, B, C]

Please, I can't mathematically prove/disprove it. If not true, an counter example would helpful.

A postordering is a list of the vertices in the order that they were last visited by the algorithm

https://en.wikipedia.org/wiki/Depth-first_search

Was it helpful?

Solution

Let $G$ be a graph and $G'$ be it's transposed version. Your property follows from the following two facts:

1) The order in which vertices are visited by a postorder visit on $G'$ is the reverse of a topological order $\sigma'$ for $G'$ (in fact, that's a standard way to compute a topological order). You can see that this is true by noticing that if $(u,v) \in G'$ then $v$ must be visited before $u$ can be visited, i.e., $v$ follows $u$ in $\sigma'$.

2) If $\sigma'$ is a topological order for $G'$, then the linear order $\sigma$ obtained by reversing $\sigma'$ is a topological order for $G$. You can see that this is true because, for every edge $(u,v)$ of $G$, $G'$ contains $(v,u)$ and therefore $v$ precedes $u$ in $\sigma'$. This means that $(u,v) \in G \implies u$ precedes $v$ in $\sigma$.

Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange
scroll top