public static IEnumerable <Vertex <TVertexId> > DfsTopologicalSort <TVertexId, TVertexProperty, TEdgeProperty>( this IDirectedGraph <TVertexId, TVertexProperty, TEdgeProperty> graph) { if (graph.EdgesCount == 0) { return(graph.Vertices); } var strategy = new TopologicalStrategy <TVertexId>(); graph.DfsRecursive(strategy, graph.Vertices); return(strategy.order.Reverse <Vertex <TVertexId> >()); }