# HG changeset patch # User marci # Date 1083857082 0 # Node ID 83c22ca968d8c0d3601195eb62edabd3d6e0afe5 # Parent d167149bde9583892380f4b19e74e439a317dbb7 top-sort, for fezso's sake diff -r d167149bde95 -r 83c22ca968d8 src/work/marci/bfs_dfs_misc.h --- a/src/work/marci/bfs_dfs_misc.h Thu May 06 15:19:59 2004 +0000 +++ b/src/work/marci/bfs_dfs_misc.h Thu May 06 15:24:42 2004 +0000 @@ -50,10 +50,10 @@ if (!reached[n]) { dfs.pushAndSetReached(n); while (!dfs.finished()) { + ++dfs; if (dfs.isANodeExamined()) { l.push_back(dfs.aNode()); } - ++dfs; } } } diff -r d167149bde95 -r 83c22ca968d8 src/work/marci/top_sort.dim --- a/src/work/marci/top_sort.dim Thu May 06 15:19:59 2004 +0000 +++ b/src/work/marci/top_sort.dim Thu May 06 15:24:42 2004 +0000 @@ -1,5 +1,6 @@ -p mat 5 4 +p mat 5 5 a 1 3 a 2 3 a 3 5 a 3 4 +a 5 4 \ No newline at end of file diff -r d167149bde95 -r 83c22ca968d8 src/work/marci/top_sort_test.cc --- a/src/work/marci/top_sort_test.cc Thu May 06 15:19:59 2004 +0000 +++ b/src/work/marci/top_sort_test.cc Thu May 06 15:24:42 2004 +0000 @@ -6,20 +6,35 @@ #include #include #include +#include using namespace hugo; int main() { typedef ListGraph Graph; Graph g; - readDimacs(std::cin, g); - std::list l; - topSort(g, l); - std::cout << "Leaving order of dfs which is pretopological..." << std::endl; - for(std::list::const_iterator i=l.begin(); i!=l.end(); ++i) { - std::cout << *i << " "; + readDimacs(std::cin, g); + { + std::list l; + topSort(g, l); + std::cout << "Leaving order of dfs which is pretopological..." << std::endl; + for(std::list::const_iterator i=l.begin(); i!=l.end(); ++i) { + std::cout << *i << " "; + } + std::cout << std::endl; } - std::cout << std::endl; + + { + typedef RevGraphWrapper GW; + GW gw(g); + std::list l; + topSort(gw, l); + std::cout << "Same in the revered oriented graph..." << std::endl; + for(std::list::const_iterator i=l.begin(); i!=l.end(); ++i) { + std::cout << *i << " "; + } + std::cout << std::endl; + } return 0; }