diff -r fb261e3a9a0f -r 405ccc3105e1 src/work/marci/bipartite_graphs.h --- a/src/work/marci/bipartite_graphs.h Thu May 06 13:21:24 2004 +0000 +++ b/src/work/marci/bipartite_graphs.h Thu May 06 13:44:48 2004 +0000 @@ -35,5 +35,26 @@ } return true; } + + /// experimental topsort, + /// I think the final version will work as an iterator + template + void topSort(Graph& g, std::list& l) { + l.clear(); + typedef typename Graph::template NodeMap ReachedMap; + ReachedMap reached(g/*, false*/); + DfsIterator dfs(g, reached); + FOR_EACH_LOC(typename Graph::NodeIt, n, g) { + if (!reached[n]) { + dfs.pushAndSetReached(n); + while (!bfs.finished()) { + if (bfs.isANodeExamined()) { + l.push_back(bfs.aNode()); + } + ++bfs; + } + } + } + } } #endif //HUGO_BIPARTITE_GRAPHS_H