[Lemon-commits] [lemon_svn] marci: r725 - hugo/trunk/src/work/marci

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:41:10 CET 2006


Author: marci
Date: Thu May  6 17:24:42 2004
New Revision: 725

Modified:
   hugo/trunk/src/work/marci/bfs_dfs_misc.h
   hugo/trunk/src/work/marci/top_sort.dim
   hugo/trunk/src/work/marci/top_sort_test.cc

Log:
top-sort, for fezso's sake


Modified: hugo/trunk/src/work/marci/bfs_dfs_misc.h
==============================================================================
--- hugo/trunk/src/work/marci/bfs_dfs_misc.h	(original)
+++ hugo/trunk/src/work/marci/bfs_dfs_misc.h	Thu May  6 17:24:42 2004
@@ -50,10 +50,10 @@
       if (!reached[n]) {
 	dfs.pushAndSetReached(n);
 	while (!dfs.finished()) {
+	  ++dfs;
 	  if (dfs.isANodeExamined()) {
 	    l.push_back(dfs.aNode());
 	  }
-	  ++dfs;
 	}
       }
     }

Modified: hugo/trunk/src/work/marci/top_sort.dim
==============================================================================
--- hugo/trunk/src/work/marci/top_sort.dim	(original)
+++ hugo/trunk/src/work/marci/top_sort.dim	Thu May  6 17:24:42 2004
@@ -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

Modified: hugo/trunk/src/work/marci/top_sort_test.cc
==============================================================================
--- hugo/trunk/src/work/marci/top_sort_test.cc	(original)
+++ hugo/trunk/src/work/marci/top_sort_test.cc	Thu May  6 17:24:42 2004
@@ -6,20 +6,35 @@
 #include <hugo/dimacs.h>
 #include <bfs_dfs_misc.h>
 #include <list_graph.h>
+#include <graph_wrapper.h>
 
 using namespace hugo;
 
 int main() {
   typedef ListGraph Graph;
   Graph g;
-  readDimacs(std::cin, g);
-  std::list<Graph::Node> l;
-  topSort(g, l);
-  std::cout << "Leaving order of dfs which is pretopological..." << std::endl;
-  for(std::list<Graph::Node>::const_iterator i=l.begin(); i!=l.end(); ++i) {
-    std::cout << *i << " ";
+  readDimacs(std::cin, g); 
+  {
+    std::list<Graph::Node> l;
+    topSort(g, l);
+    std::cout << "Leaving order of dfs which is pretopological..." << std::endl;
+    for(std::list<Graph::Node>::const_iterator i=l.begin(); i!=l.end(); ++i) {
+      std::cout << *i << " ";
+    }
+    std::cout << std::endl;
+  }
+  
+  {
+    typedef RevGraphWrapper<Graph> GW;
+    GW gw(g);
+    std::list<GW::Node> l;
+    topSort(gw, l);
+    std::cout << "Same in the revered oriented graph..." << std::endl;
+    for(std::list<GW::Node>::const_iterator i=l.begin(); i!=l.end(); ++i) {
+      std::cout << *i << " ";
+    }
+    std::cout << std::endl;
   }
-  std::cout << std::endl;
 
   return 0;
 }



More information about the Lemon-commits mailing list