Let's have a standard topological ordering algorithm (from CLRS):
Topological_ordering(G) foreach vertex v in V do v.color = white for each vertex v in V do if v.color = white then Stack = DFS(G, v, Stack) return Stack // DFS DFS (G, v, Stack) v.color = gray for each u adjacent of v do if u.color = white then Stack = DFS(G, u, Stack) v.color = black Stack.push(v) return Stack
Now let's apply this to a cyclic graph G.
We will not have a topological ordering of the vertices of G, but we shall have a topological ordering of the graph of the Strongly Connected Components
The graph of the Strongly Connnected Components derived from the graph G is a graph in which each SCC is represented by only one vertex (also called compressed SCC graph or supergraph)
For example let's look at this graph: https://imgur.com/a/0EXOxJt (sorry for the poor drawing skills). In green the SSC of this graph.
Applying the algorithm above, one possible stack configuration is:
head ----> 2 ; 3 ; 4 ; 5 ; 1 ; 6 , 8 ; 7 ; 9
As you can see the vertices of an SCC are "all together". In other words we cannot have in the stack $v_1, v_2, v_3$ where $v_1 \in S_1 \land v_3 \in S_1$ and $v_2 \in S_2$.
How to prove this mathematically? Thank you.