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

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


Author: marci
Date: Tue Aug 31 13:26:59 2004
New Revision: 1068

Modified:
   hugo/trunk/src/hugo/graph_wrapper.h
   hugo/trunk/src/work/marci/augmenting_flow.h
   hugo/trunk/src/work/marci/makefile
   hugo/trunk/src/work/marci/max_flow_demo.cc

Log:
ResGraphWrapper<Graph> is done, so does dimacs.h.


Modified: hugo/trunk/src/hugo/graph_wrapper.h
==============================================================================
--- hugo/trunk/src/hugo/graph_wrapper.h	(original)
+++ hugo/trunk/src/hugo/graph_wrapper.h	Tue Aug 31 13:26:59 2004
@@ -347,6 +347,8 @@
 
   };
 
+
+
   /// A graph wrapper for hiding nodes and edges from a graph.
   
   /// This wrapper shows a graph with filtered node-set and 
@@ -380,69 +382,109 @@
       edge_filter_map(&_edge_filter_map) { }  
 
     typedef typename GraphWrapper<Graph>::Node Node;
-    class NodeIt { 
-      friend class GraphWrapper<Graph>;
+//     class NodeIt { 
+//       friend class GraphWrapper<Graph>;
+//       friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>;
+//       typename Graph::NodeIt n;
+//      public:
+//       NodeIt() { }
+//       NodeIt(const typename Graph::NodeIt& _n) : n(_n) { }
+//       NodeIt(const Invalid& i) : n(i) { }
+//       NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G) : 
+// 	n(*(_G.graph)) { 
+// 	while (_G.graph->valid(n) && !(*(_G.node_filter_map))[n]) 
+// 	  _G.graph->next(n);
+//       }
+//       operator Node() const { return Node(typename Graph::Node(n)); }
+//     };
+    class NodeIt : public Node { 
+      const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>* gw;
       friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>;
-      typename Graph::NodeIt n;
-     public:
+    public:
       NodeIt() { }
-      NodeIt(const typename Graph::NodeIt& _n) : n(_n) { }
-      NodeIt(const Invalid& i) : n(i) { }
-      NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G) : 
-	n(*(_G.graph)) { 
-	while (_G.graph->valid(n) && !(*(_G.node_filter_map))[n]) 
-	  _G.graph->next(n);
+      //      NodeIt(const NodeIt& n) : Node(n), gw(n.gw) { }
+      NodeIt(Invalid i) : Node(i) { }
+      NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw) : 
+	Node(typename Graph::NodeIt(*(_gw.graph))), gw(&_gw) { }
+      NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, 
+	     const Node& n) : 
+	Node(n), gw(&_gw) { }
+      NodeIt& operator++() { 
+	*(static_cast<Node*>(this))=
+	  ++(typename Graph::NodeIt(*(gw->graph), *this));
+	while (*static_cast<Node*>(this)!=INVALID && 
+	       !(*(gw->node_filter_map))[*this]) 
+	  *(static_cast<Node*>(this))=
+	    ++(typename Graph::NodeIt(*(gw->graph), *this));
+	return *this; 
       }
-      operator Node() const { return Node(typename Graph::Node(n)); }
     };
     typedef typename GraphWrapper<Graph>::Edge Edge;
-    class OutEdgeIt { 
-      friend class GraphWrapper<Graph>;
+    class OutEdgeIt : public Edge { 
+      const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>* gw;
       friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>;
-      typename Graph::OutEdgeIt e;
     public:
       OutEdgeIt() { }
-      OutEdgeIt(const typename Graph::OutEdgeIt& _e) : e(_e) { }
-      OutEdgeIt(const Invalid& i) : e(i) { }
-      OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G, 
-		const Node& _n) : 
-	e(*(_G.graph), typename Graph::Node(_n)) { 
-      	while (_G.graph->valid(e) && !(*(_G.edge_filter_map))[e]) 
-	  _G.graph->next(e);
+      //      OutEdgeIt(const OutEdgeIt& e) : Edge(e), gw(e.gw) { }
+      OutEdgeIt(Invalid i) : Edge(i) { }
+      OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, const Node& n) : 
+	Edge(typename Graph::OutEdgeIt(*(_gw.graph)), n), gw(&_gw) { }
+      OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, 
+	     const Edge& e) : 
+	Edge(e), gw(&_gw) { }
+      OutEdgeIt& operator++() { 
+	*(static_cast<Edge*>(this))=
+	  ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
+	while (*static_cast<Edge*>(this)!=INVALID && 
+	       !(*(gw->edge_filter_map))[*this]) 
+	  *(static_cast<Edge*>(this))=
+	    ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
+	return *this; 
       }
-      operator Edge() const { return Edge(typename Graph::Edge(e)); }
     };
-    class InEdgeIt { 
-      friend class GraphWrapper<Graph>;
+    class InEdgeIt : public Edge { 
+      const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>* gw;
       friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>;
-      typename Graph::InEdgeIt e;
     public:
       InEdgeIt() { }
-      InEdgeIt(const typename Graph::InEdgeIt& _e) : e(_e) { }
-      InEdgeIt(const Invalid& i) : e(i) { }
-      InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G, 
-	       const Node& _n) : 
-	e(*(_G.graph), typename Graph::Node(_n)) { 
-      	while (_G.graph->valid(e) && !(*(_G.edge_filter_map))[e]) 
-	  _G.graph->next(e);
+      //      InEdgeIt(const InEdgeIt& e) : Edge(e), gw(e.gw) { }
+      InEdgeIt(Invalid i) : Edge(i) { }
+      InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, const Node& n) : 
+	Edge(typename Graph::InEdgeIt(*(_gw.graph)), n), gw(&_gw) { }
+      InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, 
+	     const Edge& e) : 
+	Edge(e), gw(&_gw) { }
+      InEdgeIt& operator++() { 
+	*(static_cast<Edge*>(this))=
+	  ++(typename Graph::InEdgeIt(*(gw->graph), *this));
+	while (*static_cast<Edge*>(this)!=INVALID && 
+	       !(*(gw->edge_filter_map))[*this]) 
+	  *(static_cast<Edge*>(this))=
+	    ++(typename Graph::InEdgeIt(*(gw->graph), *this));
+	return *this; 
       }
-      operator Edge() const { return Edge(typename Graph::Edge(e)); }
     };
-    //typedef typename Graph::SymEdgeIt SymEdgeIt;
-    class EdgeIt { 
-      friend class GraphWrapper<Graph>;
+    class EdgeIt : public Edge { 
+      const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>* gw;
       friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>;
-      typename Graph::EdgeIt e;
     public:
       EdgeIt() { }
-      EdgeIt(const typename Graph::EdgeIt& _e) : e(_e) { }
-      EdgeIt(const Invalid& i) : e(i) { }
-      EdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G) : 
-	e(*(_G.graph)) { 
-      	while (_G.graph->valid(e) && !(*(_G.edge_filter_map))[e]) 
-	  _G.graph->next(e);
+      //      EdgeIt(const EdgeIt& e) : Edge(e), gw(e.gw) { }
+      EdgeIt(Invalid i) : Edge(i) { }
+      EdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw) : 
+	Edge(typename Graph::EdgeIt(*(_gw.graph))), gw(&_gw) { }
+      EdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, 
+	     const Edge& e) : 
+	Edge(e), gw(&_gw) { }
+      EdgeIt& operator++() { 
+	*(static_cast<Edge*>(this))=
+	  ++(typename Graph::EdgeIt(*(gw->graph), *this));
+	while (*static_cast<Edge*>(this)!=INVALID && 
+	       !(*(gw->edge_filter_map))[*this]) 
+	  *(static_cast<Edge*>(this))=
+	    ++(typename Graph::EdgeIt(*(gw->graph), *this));
+	return *this; 
       }
-      operator Edge() const { return Edge(typename Graph::Edge(e)); }
     };
 
     NodeIt& first(NodeIt& i) const { 
@@ -458,39 +500,39 @@
       i=EdgeIt(*this); return i;
     }
     
-    NodeIt& next(NodeIt& i) const {
-      this->graph->next(i.n); 
-      while (this->graph->valid(i) && !(*node_filter_map)[i.n]) { 
-	this->graph->next(i.n); }
-      return i;
-    }
-    OutEdgeIt& next(OutEdgeIt& i) const {
-      this->graph->next(i.e); 
-      while (this->graph->valid(i) && !(*edge_filter_map)[i.e]) { 
-	this->graph->next(i.e); }
-      return i;
-    }
-    InEdgeIt& next(InEdgeIt& i) const {
-      this->graph->next(i.e); 
-      while (this->graph->valid(i) && !(*edge_filter_map)[i.e]) { 
-	this->graph->next(i.e); }
-      return i;
-    }
-    EdgeIt& next(EdgeIt& i) const {
-      this->graph->next(i.e); 
-      while (this->graph->valid(i) && !(*edge_filter_map)[i.e]) { 
-	this->graph->next(i.e); }
-      return i;
-    }
-
-    Node aNode(const OutEdgeIt& e) const { 
-      return Node(this->graph->aNode(e.e)); }
-    Node aNode(const InEdgeIt& e) const { 
-      return Node(this->graph->aNode(e.e)); }
-    Node bNode(const OutEdgeIt& e) const { 
-      return Node(this->graph->bNode(e.e)); }
-    Node bNode(const InEdgeIt& e) const { 
-      return Node(this->graph->bNode(e.e)); }
+//     NodeIt& next(NodeIt& i) const {
+//       this->graph->next(i.n); 
+//       while (this->graph->valid(i) && !(*node_filter_map)[i.n]) { 
+// 	this->graph->next(i.n); }
+//       return i;
+//     }
+//     OutEdgeIt& next(OutEdgeIt& i) const {
+//       this->graph->next(i.e); 
+//       while (this->graph->valid(i) && !(*edge_filter_map)[i.e]) { 
+// 	this->graph->next(i.e); }
+//       return i;
+//     }
+//     InEdgeIt& next(InEdgeIt& i) const {
+//       this->graph->next(i.e); 
+//       while (this->graph->valid(i) && !(*edge_filter_map)[i.e]) { 
+// 	this->graph->next(i.e); }
+//       return i;
+//     }
+//     EdgeIt& next(EdgeIt& i) const {
+//       this->graph->next(i.e); 
+//       while (this->graph->valid(i) && !(*edge_filter_map)[i.e]) { 
+// 	this->graph->next(i.e); }
+//       return i;
+//     }
+
+//     Node aNode(const OutEdgeIt& e) const { 
+//       return Node(this->graph->aNode(e.e)); }
+//     Node aNode(const InEdgeIt& e) const { 
+//       return Node(this->graph->aNode(e.e)); }
+//     Node bNode(const OutEdgeIt& e) const { 
+//       return Node(this->graph->bNode(e.e)); }
+//     Node bNode(const InEdgeIt& e) const { 
+//       return Node(this->graph->bNode(e.e)); }
 
     /// This function hides \c n in the graph, i.e. the iteration 
     /// jumps over it. This is done by simply setting the value of \c n  
@@ -753,13 +795,14 @@
 	       !(*(gw->forward_filter))[*this]) 
 	  *(static_cast<GraphEdge*>(this))=
 	    ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
-	if (*static_cast<GraphEdge*>(this)==INVALID) 
+	if (*static_cast<GraphEdge*>(this)==INVALID) {
 	  *static_cast<Edge*>(this)=
 	    Edge(typename Graph::InEdgeIt(*(_gw.graph), n), true);
-	while (*static_cast<GraphEdge*>(this)!=INVALID && 
-	       !(*(gw->backward_filter))[*this]) 
-	  *(static_cast<GraphEdge*>(this))=
-	    ++(typename Graph::InEdgeIt(*(gw->graph), *this));
+	  while (*static_cast<GraphEdge*>(this)!=INVALID && 
+		 !(*(gw->backward_filter))[*this]) 
+	    *(static_cast<GraphEdge*>(this))=
+	      ++(typename Graph::InEdgeIt(*(gw->graph), *this));
+	}
       }
       OutEdgeIt(const SubBidirGraphWrapper<Graph, 
 		ForwardFilterMap, BackwardFilterMap>& _gw, const Edge& e) : 
@@ -773,13 +816,14 @@
 		 !(*(gw->forward_filter))[*this]) 
 	    *(static_cast<GraphEdge*>(this))=
 	      ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
-	  if (*static_cast<GraphEdge*>(this)==INVALID) 
+	  if (*static_cast<GraphEdge*>(this)==INVALID) {
 	    *static_cast<Edge*>(this)=
 	      Edge(typename Graph::InEdgeIt(*(gw->graph), n), true);
-	  while (*static_cast<GraphEdge*>(this)!=INVALID && 
-		 !(*(gw->backward_filter))[*this]) 
-	    *(static_cast<GraphEdge*>(this))=
-	      ++(typename Graph::InEdgeIt(*(gw->graph), *this));
+	    while (*static_cast<GraphEdge*>(this)!=INVALID && 
+		   !(*(gw->backward_filter))[*this]) 
+	      *(static_cast<GraphEdge*>(this))=
+		++(typename Graph::InEdgeIt(*(gw->graph), *this));
+	  }
 	} else {
 	  *(static_cast<GraphEdge*>(this))=
 	    ++(typename Graph::InEdgeIt(*(gw->graph), *this));
@@ -809,33 +853,35 @@
 	       !(*(gw->forward_filter))[*this]) 
 	  *(static_cast<GraphEdge*>(this))=
 	    ++(typename Graph::InEdgeIt(*(gw->graph), *this));
-	if (*static_cast<GraphEdge*>(this)==INVALID) 
+	if (*static_cast<GraphEdge*>(this)==INVALID) {
 	  *static_cast<Edge*>(this)=
 	    Edge(typename Graph::OutEdgeIt(*(_gw.graph), n), true);
-	while (*static_cast<GraphEdge*>(this)!=INVALID && 
-	       !(*(gw->backward_filter))[*this]) 
-	  *(static_cast<GraphEdge*>(this))=
-	    ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
+	  while (*static_cast<GraphEdge*>(this)!=INVALID && 
+		 !(*(gw->backward_filter))[*this]) 
+	    *(static_cast<GraphEdge*>(this))=
+	      ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
+	}
       }
       InEdgeIt(const SubBidirGraphWrapper<Graph, 
 	       ForwardFilterMap, BackwardFilterMap>& _gw, const Edge& e) : 
 	Edge(e), gw(&_gw) { }
       InEdgeIt& operator++() { 
 	if (!this->backward) {
-	  Node n=gw->head(*this);
+	  Node n=gw->tail(*this);
 	  *(static_cast<GraphEdge*>(this))=
 	    ++(typename Graph::InEdgeIt(*(gw->graph), *this));
 	  while (*static_cast<GraphEdge*>(this)!=INVALID && 
 		 !(*(gw->forward_filter))[*this]) 
 	    *(static_cast<GraphEdge*>(this))=
 	      ++(typename Graph::InEdgeIt(*(gw->graph), *this));
-	  if (*static_cast<GraphEdge*>(this)==INVALID) 
+	  if (*static_cast<GraphEdge*>(this)==INVALID) {
 	    *static_cast<Edge*>(this)=
 	      Edge(typename Graph::OutEdgeIt(*(gw->graph), n), true);
-	  while (*static_cast<GraphEdge*>(this)!=INVALID && 
-		 !(*(gw->backward_filter))[*this]) 
-	    *(static_cast<GraphEdge*>(this))=
-	      ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
+	    while (*static_cast<GraphEdge*>(this)!=INVALID && 
+		   !(*(gw->backward_filter))[*this]) 
+	      *(static_cast<GraphEdge*>(this))=
+		++(typename Graph::OutEdgeIt(*(gw->graph), *this));
+	  }
 	} else {
 	  *(static_cast<GraphEdge*>(this))=
 	    ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
@@ -859,19 +905,20 @@
       EdgeIt(Invalid i) : Edge(i) { }
 //the unique invalid iterator
       EdgeIt(const SubBidirGraphWrapper<Graph, 
-		ForwardFilterMap, BackwardFilterMap>& _gw) : 
-	Edge(typename Graph::EdgeIt(*(_gw.graph)), false), gw(&_gw) { 
+	     ForwardFilterMap, BackwardFilterMap>& _gw) : 
+	Edge(typename Graph::OutEdgeIt(*(_gw.graph)), false), gw(&_gw) { 
 	while (*static_cast<GraphEdge*>(this)!=INVALID && 
 	       !(*(gw->forward_filter))[*this]) 
 	  *(static_cast<GraphEdge*>(this))=
 	    ++(typename Graph::EdgeIt(*(gw->graph), *this));
-	if (*static_cast<GraphEdge*>(this)==INVALID) 
+	if (*static_cast<GraphEdge*>(this)==INVALID) {
 	  *static_cast<Edge*>(this)=
 	    Edge(typename Graph::EdgeIt(*(_gw.graph)), true);
-	while (*static_cast<GraphEdge*>(this)!=INVALID && 
-	       !(*(gw->backward_filter))[*this]) 
-	  *(static_cast<GraphEdge*>(this))=
-	    ++(typename Graph::EdgeIt(*(gw->graph), *this));
+	  while (*static_cast<GraphEdge*>(this)!=INVALID && 
+		 !(*(gw->backward_filter))[*this]) 
+	    *(static_cast<GraphEdge*>(this))=
+	      ++(typename Graph::EdgeIt(*(gw->graph), *this));
+	}
       }
       EdgeIt(const SubBidirGraphWrapper<Graph, 
 	     ForwardFilterMap, BackwardFilterMap>& _gw, const Edge& e) : 
@@ -884,13 +931,14 @@
 		 !(*(gw->forward_filter))[*this]) 
 	    *(static_cast<GraphEdge*>(this))=
 	      ++(typename Graph::EdgeIt(*(gw->graph), *this));
-	  if (*static_cast<GraphEdge*>(this)==INVALID) 
+	  if (*static_cast<GraphEdge*>(this)==INVALID) {
 	    *static_cast<Edge*>(this)=
 	      Edge(typename Graph::EdgeIt(*(gw->graph)), true);
-	  while (*static_cast<GraphEdge*>(this)!=INVALID && 
-		 !(*(gw->backward_filter))[*this]) 
-	    *(static_cast<GraphEdge*>(this))=
-	      ++(typename Graph::EdgeIt(*(gw->graph), *this));
+	    while (*static_cast<GraphEdge*>(this)!=INVALID && 
+		   !(*(gw->backward_filter))[*this]) 
+	      *(static_cast<GraphEdge*>(this))=
+		++(typename Graph::EdgeIt(*(gw->graph), *this));
+	  }
 	} else {
 	  *(static_cast<GraphEdge*>(this))=
 	    ++(typename Graph::EdgeIt(*(gw->graph), *this));

Modified: hugo/trunk/src/work/marci/augmenting_flow.h
==============================================================================
--- hugo/trunk/src/work/marci/augmenting_flow.h	(original)
+++ hugo/trunk/src/work/marci/augmenting_flow.h	Tue Aug 31 13:26:59 2004
@@ -1020,7 +1020,7 @@
 	break;
       case AFTER_AUGMENTING:
 //	std::cout << "AFTER_AUGMENTING" << std::endl;
-	for(g->first(v); g->valid(v); g->next(v)) {
+	for(g->first(v); v!=INVALID; ++v) {
 	  if (level[v]) {
 	    M.set(v, true);
 	  } else {
@@ -1030,7 +1030,7 @@
 	break;
       case AFTER_FAST_AUGMENTING:
 //	std::cout << "AFTER_FAST_AUGMENTING" << std::endl;
-	for(g->first(v); g->valid(v); g->next(v)) {
+	for(g->first(v); v!=INVALID; ++v) {
 	  if (level[v]==number_of_augmentations) {
 	    M.set(v, true);
 	  } else {
@@ -1053,7 +1053,7 @@
 	queue.pop();
 
 	OutEdgeIt e;
-	for(g->first(e,w) ; g->valid(e); g->next(e)) {
+	for(g->first(e,w) ; e!=INVALID; ++e) {
 	  Node v=g->head(e);
 	  if (!M[v] && (*flow)[e] < (*capacity)[e] ) {
 	    queue.push(v);
@@ -1062,7 +1062,7 @@
 	}
 
 	InEdgeIt f;
-	for(g->first(f,w) ; g->valid(f); g->next(f)) {
+	for(g->first(f,w) ; f!=INVALID; ++f) {
 	  Node v=g->tail(f);
 	  if (!M[v] && (*flow)[f] > 0 ) {
 	    queue.push(v);
@@ -1133,11 +1133,11 @@
     //searching for augmenting path
     while ( !bfs.finished() ) {
       ResGWOutEdgeIt e=bfs;
-      if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
+      if (e!=INVALID && bfs.isBNodeNewlyReached()) {
 	Node v=res_graph.tail(e);
 	Node w=res_graph.head(e);
 	pred.set(w, e);
-	if (res_graph.valid(pred[v])) {
+	if (pred[v]!=INVALID) {
 	  free.set(w, std::min(free[v], res_graph.resCap(e)));
 	} else {
 	  free.set(w, res_graph.resCap(e));
@@ -1151,7 +1151,7 @@
     if (_augment) {
       Node n=t;
       Num augment_value=free[t];
-      while (res_graph.valid(pred[n])) {
+      while (pred[n]!=INVALID) {
 	ResGWEdge e=pred[n];
 	res_graph.augment(e, augment_value);
 	n=res_graph.tail(e);
@@ -1190,11 +1190,11 @@
     //searching for augmenting path
     while ( !bfs.finished() ) {
       ResGWOutEdgeIt e=bfs;
-      if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
+      if (e!=INVALID && bfs.isBNodeNewlyReached()) {
 	Node v=res_graph.tail(e);
 	Node w=res_graph.head(e);
 	pred.set(w, e);
-	if (res_graph.valid(pred[v])) {
+	if (pred[v]!=INVALID) {
 	  free.set(w, std::min(free[v], res_graph.resCap(e)));
 	} else {
 	  free.set(w, res_graph.resCap(e));
@@ -1208,7 +1208,7 @@
     if (_augment) {
       Node n=t;
       Num augment_value=free[t];
-      while (res_graph.valid(pred[n])) {
+      while (pred[n]!=INVALID) {
 	ResGWEdge e=pred[n];
 	res_graph.augment(e, augment_value);
 	n=res_graph.tail(e);
@@ -1244,7 +1244,7 @@
       res_graph_to_F(res_graph);
     {
       typename ResGW::NodeIt n;
-      for(res_graph.first(n); res_graph.valid(n); res_graph.next(n)) {
+      for(res_graph.first(n); n!=INVALID; ++n) {
 	res_graph_to_F.set(n, F.addNode());
       }
     }
@@ -1256,7 +1256,7 @@
 
     while ( !bfs.finished() ) {
       ResGWOutEdgeIt e=bfs;
-      if (res_graph.valid(e)) {
+      if (e!=INVALID) {
 	if (bfs.isBNodeNewlyReached()) {
 	  dist.set(res_graph.head(e), dist[res_graph.tail(e)]+1);
 	  typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.tail(e)],
@@ -1299,7 +1299,7 @@
 	    typename MG::Node v=F.aNode(dfs);
 	    typename MG::Node w=F.bNode(dfs);
 	    pred.set(w, dfs);
-	    if (F.valid(pred[v])) {
+	    if (pred[v]!=INVALID) {
 	      free.set(w, std::min(free[v], residual_capacity[dfs]));
 	    } else {
 	      free.set(w, residual_capacity[dfs]);
@@ -1319,7 +1319,7 @@
       if (__augment) {
 	typename MG::Node n=tF;
 	Num augment_value=free[tF];
-	while (F.valid(pred[n])) {
+	while (pred[n]!=INVALID) {
 	  typename MG::Edge e=pred[n];
 	  res_graph.augment(original_edge[e], augment_value);
 	  n=F.tail(e);
@@ -1337,8 +1337,6 @@
   }
 
 
-
-
   template <typename Graph, typename Num, typename CapMap, typename FlowMap>
   bool AugmentingFlow<Graph, Num, CapMap, FlowMap>::augmentOnBlockingFlow2()
   {
@@ -1354,7 +1352,7 @@
     DistanceMap<ResGW> dist(res_graph);
     while ( !bfs.finished() ) {
       ResGWOutEdgeIt e=bfs;
-      if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
+      if (e!=INVALID && bfs.isBNodeNewlyReached()) {
 	dist.set(res_graph.head(e), dist[res_graph.tail(e)]+1);
       }
       ++bfs;
@@ -1371,8 +1369,7 @@
     typename FilterResGW::template NodeMap<typename FilterResGW::OutEdgeIt>
       first_out_edges(filter_res_graph);
     typename FilterResGW::NodeIt v;
-    for(filter_res_graph.first(v); filter_res_graph.valid(v);
-	filter_res_graph.next(v))
+    for(filter_res_graph.first(v); v!=INVALID; ++v)
       {
  	typename FilterResGW::OutEdgeIt e;
  	filter_res_graph.first(e, v);
@@ -1418,7 +1415,7 @@
  	      typename ErasingResGW::Node w=erasing_res_graph.bNode(dfs);
 
  	      pred.set(w, /*typename ErasingResGW::OutEdgeIt*/(dfs));
- 	      if (erasing_res_graph.valid(pred[v])) {
+ 	      if (pred[v]!=INVALID) {
  		free1.set
 		  (w, std::min(free1[v], res_graph.resCap
 			       (typename ErasingResGW::OutEdgeIt(dfs))));

Modified: hugo/trunk/src/work/marci/makefile
==============================================================================
--- hugo/trunk/src/work/marci/makefile	(original)
+++ hugo/trunk/src/work/marci/makefile	Tue Aug 31 13:26:59 2004
@@ -4,7 +4,7 @@
 INCLUDEDIRS ?= -I../{jacint,marci,alpar,klao,akos,athos} -I../.. -I.. -I$(BOOSTROOT)
 
 LEDABINARIES = leda_graph_demo leda_bfs_dfs max_bipartite_matching_demo
-BINARIES = graph_wrapper_time max_flow_demo iterator_bfs_demo macro_test lg_vs_sg_vs_sg bfsit_vs_byhand bipartite_graph_wrapper_test bipartite_matching_demo top_sort_test max_flow_1 proba7
+BINARIES = graph_wrapper_time max_flow_demo iterator_bfs_demo macro_test lg_vs_sg_vs_sg bfsit_vs_byhand bipartite_graph_wrapper_test bipartite_matching_demo top_sort_test max_flow_1 proba7 proba8
 #BINARIES = preflow_bug
 #gw_vs_not preflow_demo_boost edmonds_karp_demo_boost preflow_demo_jacint preflow_demo_athos edmonds_karp_demo_alpar preflow_demo_leda
 

Modified: hugo/trunk/src/work/marci/max_flow_demo.cc
==============================================================================
--- hugo/trunk/src/work/marci/max_flow_demo.cc	(original)
+++ hugo/trunk/src/work/marci/max_flow_demo.cc	Tue Aug 31 13:26:59 2004
@@ -16,23 +16,7 @@
 using namespace hugo;
 
 // Use a DIMACS max flow file as stdin.
-// read_dimacs_demo < dimacs_max_flow_file
-
-
-//   struct Ize {
-//   };
-  
-//   struct Mize {
-//     Ize bumm;
-//   };
-
-//   template <typename B>
-//     class Huha {
-//     public:
-//       int u;
-//       B brr;
-//     };
-
+// max_flow_demo < dimacs_max_flow_file
 
 int main(int, char **) {
 
@@ -44,28 +28,6 @@
   typedef Graph::Node Node;
   typedef Graph::EdgeIt EdgeIt;
 
-
-//   Mize mize[10];
-//   Mize bize[0];
-//   Mize zize;
-//   typedef Mize Tize[0];
-
-//   std::cout << &zize << " " << sizeof(mize) << sizeof(Tize) << std::endl;
-//   std::cout << sizeof(bize) << std::endl;
-
-
-//   Huha<Tize> k;
-//   std::cout << sizeof(k) << std::endl;
-
-
-//   struct Bumm {
-//     //int a;
-//     bool b;
-//   };
-
-//   std::cout << sizeof(Bumm) << std::endl;
-
-
   Graph g;
 
   Node s, t;
@@ -141,33 +103,22 @@
   }
 
 //   {
-//     std::cout << "faster physical blocking flow augmentation ..." << std::endl;
+//     std::cout << "on-the-fly blocking flow augmentation ..." << std::endl;
 //     FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
 //     ts.reset();
 //     int i=0;
-//     while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) { ++i; }
+//     while (augmenting_flow_test.augmentOnBlockingFlow2()) { ++i; }
 //     std::cout << "elapsed time: " << ts << std::endl;
 //     std::cout << "number of augmentation phases: " << i << std::endl; 
-//     std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
-//   }
-
-  {
-    std::cout << "on-the-fly blocking flow augmentation ..." << std::endl;
-    FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
-    ts.reset();
-    int i=0;
-    while (augmenting_flow_test.augmentOnBlockingFlow2()) { ++i; }
-    std::cout << "elapsed time: " << ts << std::endl;
-    std::cout << "number of augmentation phases: " << i << std::endl; 
-    std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
+//     std::cout << "flow value: "<< augmenting_flow_test.flowValue() << std::endl;
 
-    FOR_EACH_LOC(Graph::EdgeIt, e, g) {
-      if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e]) 
-	std::cout << "Slackness does not hold!" << std::endl;
-      if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0) 
-	std::cout << "Slackness does not hold!" << std::endl;
-    }
-  }
+//     FOR_EACH_LOC(Graph::EdgeIt, e, g) {
+//       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e]) 
+// 	std::cout << "Slackness does not hold!" << std::endl;
+//       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0) 
+// 	std::cout << "Slackness does not hold!" << std::endl;
+//     }
+//   }
 
   {
     std::cout << "on-the-fly shortest path augmentation ..." << std::endl;



More information about the Lemon-commits mailing list