Use this if you are using igraph from R
A topological sorting of a directed acyclic graph is a linear ordering of its nodes where each node comes before all nodes to which it has edges.
topo_sort(graph, mode = c("out", "all", "in"))
The input graph, should be directed
Specifies how to use the direction of the edges. For
Every DAG has at least one topological sort, and may have many. This function returns a possible topological sort among them. If the graph is not acyclic (it has at least one cycle), a partial topological sort is returned and a warning is issued.
A vertex sequence (by default, but see the
igraph_options) containing vertices in
topologically sorted order.
g <- barabasi.game(100) topo_sort(g)