[Lemon-commits] [lemon_svn] klao: r1456 - in hugo/trunk/src: lemon work/jacint

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


Author: klao
Date: Fri Jan  7 19:53:02 2005
New Revision: 1456

Modified:
   hugo/trunk/src/lemon/undir_graph_extender.h
   hugo/trunk/src/work/jacint/bug.cc

Log:
Nasty bug in undir_graph_extender.h


Modified: hugo/trunk/src/lemon/undir_graph_extender.h
==============================================================================
--- hugo/trunk/src/lemon/undir_graph_extender.h	(original)
+++ hugo/trunk/src/lemon/undir_graph_extender.h	Fri Jan  7 19:53:02 2005
@@ -140,51 +140,53 @@
 
     template <typename E>
     void _dirFirstOut(E &e, const Node &n) const {
-      Parent::firstOut(e,n);
+      Parent::firstIn(e,n);
       if( UndirEdge(e) != INVALID ) {
-	e.forward = true;
+	e.forward = false;
       }
       else {
-	Parent::firstIn(e,n);
-	e.forward = false;
+	Parent::firstOut(e,n);
+	e.forward = true;
       }
     }
     template <typename E>
     void _dirFirstIn(E &e, const Node &n) const {
-      Parent::firstIn(e,n);
+      Parent::firstOut(e,n);
       if( UndirEdge(e) != INVALID ) {
-	e.forward = true;
+	e.forward = false;
       }
       else {
-	Parent::firstOut(e,n);
-	e.forward = false;
+	Parent::firstIn(e,n);
+	e.forward = true;
       }
     }
 
     template <typename E>
     void _dirNextOut(E &e) const {
-      if( e.forward ) {
-	Parent::nextOut(e);
+      if( ! e.forward ) {
+	Node n = Parent::target(e);
+	Parent::nextIn(e);
 	if( UndirEdge(e) == INVALID ) {
-	  Parent::firstIn(e, Parent::source(e));
-	  e.forward = false;
+	  Parent::firstOut(e, n);
+	  e.forward = true;
 	}
       }
       else {
-	Parent::nextIn(e);
+	Parent::nextOut(e);
       }
     }
     template <typename E>
     void _dirNextIn(E &e) const {
-      if( e.forward ) {
-	Parent::nextIn(e);
+      if( ! e.forward ) {
+	Node n = Parent::source(e);
+	Parent::nextOut(e);
 	if( UndirEdge(e) == INVALID ) {
-	  Parent::firstOut(e, Parent::target(e));
-	  e.forward = false;
+	  Parent::firstIn(e, n);
+	  e.forward = true;
 	}
       }
       else {
-	Parent::nextOut(e);
+	Parent::nextIn(e);
       }
     }
 
@@ -226,7 +228,7 @@
     }
 
 
-    int maxId(Node n) const {
+    int maxId(Node) const {
       return Parent::maxId(Node());
     }
 

Modified: hugo/trunk/src/work/jacint/bug.cc
==============================================================================
--- hugo/trunk/src/work/jacint/bug.cc	(original)
+++ hugo/trunk/src/work/jacint/bug.cc	Fri Jan  7 19:53:02 2005
@@ -1,4 +1,3 @@
-//lasd megjegyzes a 49-es sorban
 #include <iostream>
 #include <queue>
 #include <vector>
@@ -6,23 +5,28 @@
 
 #include <lemon/invalid.h>
 #include <lemon/list_graph.h>
+#include <lemon/smart_graph.h>
 #include <matching.h>
 
 using namespace lemon;
+using namespace std;
 
-int main(int, char **) {
 
-  typedef UndirListGraph Graph;
+int main() {
+
+  typedef UndirSmartGraph Graph;
 
   typedef Graph::Edge Edge;
   typedef Graph::UndirEdgeIt UndirEdgeIt;
   typedef Graph::IncEdgeIt IncEdgeIt;
   typedef Graph::NodeIt NodeIt;
   typedef Graph::Node Node;
+
+  typedef Graph::OutEdgeIt OutEdgeIt;
    
   Graph G;
 
-  G.clear();
+  // G.clear();
   std::vector<Graph::Node> nodes;
   for (int i=0; i<5; ++i)
       nodes.push_back(G.addNode());
@@ -35,7 +39,8 @@
   G.addEdge(nodes[2], nodes[4]);
 
   for(UndirEdgeIt e(G); e!=INVALID; ++e) {
-    std::cout<<G.id(e)<<" : "<<G.id(G.source(e))<<" " <<G.id(G.target(e))<<std::endl;
+    std::cout<<G.id(e)<<" : "<<G.id(G.source(e))
+	     <<" " <<G.id(G.target(e))<<std::endl;
   }
 
   std::cout <<"Nodes:"<<std::endl;
@@ -44,11 +49,32 @@
     std::cout<<G.id(v)<<std::endl;
   }
 
-  std::cout<<"Edges of node " << G.id(nodes[1])<<std::endl;
+  cout << "Dev Out edges from node " << G.id(nodes[1])<<std::endl;
+  Edge f;
+  for(G.firstOut(f, nodes[1]); f!=INVALID; G.nextOut(f)) {
+    cout<<"edge " << G.id(f) << " goes"
+	     <<" from "<< G.id(G.source(f)) 
+	     << " to " << G.id(G.target(f))<<std::endl;
+  }
+
+  cout << "Out edges from node " << G.id(nodes[1])<<std::endl;
+  for( OutEdgeIt f(G,nodes[1]); f!=INVALID; ++f ) {
+    cout<<"edge " << G.id(f) << " goes"
+	     <<" from "<< G.id(G.source(f)) 
+	     << " to " << G.id(G.target(f))<<std::endl;
+  }
 
+  std::cout<<"Edges of node " << G.id(nodes[1])<<std::endl;
   for( IncEdgeIt f(G,nodes[1]); f!=INVALID; ++f ) {
-    std::cout<<"edge " << G.id(f)<< " goes to " << G.id(G.target(f))<<std::endl;
-  }//ez a ket for ciklus meg lefut - bar hibas eleken iteral -, de a matching.h-s mar segfaultol
+    cout<<"edge " << G.id(f) << " goes"
+	     <<" from "<< G.id(G.source(f)) 
+	     << " to " << G.id(G.target(f))<<std::endl;
+  }
+
+  //return 0;
+
+  //ez a ket for ciklus meg lefut - bar hibas eleken iteral -, de a
+  //matching.h-s mar segfaultol
 
   for( IncEdgeIt f(G,nodes[1]); f!=INVALID; ++f ) {
     std::cout<<"edge " << G.id(f)<< " goes to " << G.id(G.target(f))<<std::endl;



More information about the Lemon-commits mailing list