# HG changeset patch
# User jacint
# Date 1075474571 0
# Node ID e125f12784e2e82d2886f4e1996c85677e6baf0e
# Parent  f00a4f7e21498f1ad69dccfc5ba0f46e837d6f1d
*** empty log message ***

diff -r f00a4f7e2149 -r e125f12784e2 src/work/dijkstra.hh
--- a/src/work/dijkstra.hh	Fri Jan 30 14:55:10 2004 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,192 +0,0 @@
-/*
- *dijkstra
- *by jacint
- *Performs Dijkstra's algorithm from node s. 
- *
- *Constructor: 
- *
- *dijkstra(graph_type& G, node_iterator s, edge_property_vector& distance)
- *
- *
- *
- *Member functions:
- *
- *void run()
- *
- *  The following function should be used after run() was already run.
- *
- *
- *T dist(node_iterator v) : returns the distance from s to v. 
- *   It is 0 if v is not reachable from s.
- *
- *
- *edge_iterator pred(node_iterator v)
- *   Returns the last edge of a shortest s-v path. 
- *   Returns an invalid iterator if v=s or v is not
- *   reachable from s.
- *
- *
- *bool reach(node_iterator v) : true if v is reachable from s
- *
- *
- *
- *
- *
- *Problems: 
- * 
- *Heap implementation is needed, because the priority queue of stl
- *does not have a mathod for key-decrease, so we had to use here a 
- *g\'any solution.
- * 
- *The implementation of infinity would be desirable, see after line 100. 
- */
-
-#ifndef DIJKSTRA_HH
-#define DIJKSTRA_HH
-
-#include <queue>
-#include <algorithm>
-
-#include <marci_graph_traits.hh>
-#include <marci_property_vector.hh>
-
-
-namespace std {
-  namespace marci {
-
-
-
-
-
-    template <typename graph_type, typename T>
-    class dijkstra{
-      typedef typename graph_traits<graph_type>::node_iterator node_iterator;
-      typedef typename graph_traits<graph_type>::edge_iterator edge_iterator;
-      typedef typename graph_traits<graph_type>::each_node_iterator each_node_iterator;
-      typedef typename graph_traits<graph_type>::in_edge_iterator in_edge_iterator;
-      typedef typename graph_traits<graph_type>::out_edge_iterator out_edge_iterator;
-      
-      
-      graph_type& G;
-      node_iterator s;
-      node_property_vector<graph_type, edge_iterator> predecessor;
-      node_property_vector<graph_type, T> distance;
-      edge_property_vector<graph_type, T> length;
-      node_property_vector<graph_type, bool> reached;
-          
-  public :
-
-    /*
-      The distance of all the nodes is 0.
-    */
-    dijkstra(graph_type& _G, node_iterator _s, edge_property_vector<graph_type, T>& _length) : 
-      G(_G), s(_s), predecessor(G, 0), distance(G, 0), length(_length), reached(G, false) { }
-    
-
-      
-      /*By Misi.*/
-      struct node_dist_comp
-      {
-	node_property_vector<graph_type, T> &d;
-	node_dist_comp(node_property_vector<graph_type, T> &_d) : d(_d) {} 
-	
-	bool operator()(const node_iterator& u, const node_iterator& v) const 
-	{ return d.get(u) < d.get(v); }
-      };
-
-
-      
-      void run() {
-	
-	node_property_vector<graph_type, bool> scanned(G, false);
-	std::priority_queue<node_iterator, vector<node_iterator>, node_dist_comp> 
-	  heap(( node_dist_comp(distance) ));
-      
-	heap.push(s);
-	reached.put(s, true);
-
-	while (!heap.empty()) {
-
-	  node_iterator v=heap.top();	
-	  heap.pop();
-
-
-	  if (!scanned.get(v)) {
-	
-	    for(out_edge_iterator e=G.first_out_edge(v); e.valid(); ++e) {
-	      node_iterator w=G.head(e);
-
-	      if (!scanned.get(w)) {
-		if (!reached.get(w)) {
-		  reached.put(w,true);
-		  distance.put(w, distance.get(v)-length.get(e));
-		  predecessor.put(w,e);
-		} else if (distance.get(v)-length.get(e)>distance.get(w)) {
-		  distance.put(w, distance.get(v)-length.get(e));
-		  predecessor.put(w,e);
-		}
-		
-		heap.push(w);
-	      
-	      } 
-
-	    } 
-	    scanned.put(v,true);
-	    
-	  } // if (!scanned.get(v))
-	  
-	  
-	  
-	} // while (!heap.empty())
-
-	
-      } //void run()
-      
-      
-      
-
-
-      /*
-       *Returns the distance of the node v.
-       *It is 0 for the root and for the nodes not
-       *reachable form the root.
-       */      
-      T dist(node_iterator v) {
-	return -distance.get(v);
-      }
-
-
-
-      /*
-       *  Returns the last edge of a shortest s-v path. 
-       *  Returns an invalid iterator if v=root or v is not
-       *  reachable from the root.
-       */      
-      edge_iterator pred(node_iterator v) {
-	if (v!=s) { return predecessor.get(v);}
-	else {return edge_iterator();}
-      }
-     
-
-      
-      bool reach(node_iterator v) {
-	return reached.get(v);
-      }
-
-
-
-
-
-
-
-
-
-    };// class dijkstra
-
-
-
-  } // namespace marci
-}
-#endif //DIJKSTRA_HH
-
-
diff -r f00a4f7e2149 -r e125f12784e2 src/work/jacint/dijkstra.hh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/work/jacint/dijkstra.hh	Fri Jan 30 14:56:11 2004 +0000
@@ -0,0 +1,192 @@
+/*
+ *dijkstra
+ *by jacint
+ *Performs Dijkstra's algorithm from node s. 
+ *
+ *Constructor: 
+ *
+ *dijkstra(graph_type& G, node_iterator s, edge_property_vector& distance)
+ *
+ *
+ *
+ *Member functions:
+ *
+ *void run()
+ *
+ *  The following function should be used after run() was already run.
+ *
+ *
+ *T dist(node_iterator v) : returns the distance from s to v. 
+ *   It is 0 if v is not reachable from s.
+ *
+ *
+ *edge_iterator pred(node_iterator v)
+ *   Returns the last edge of a shortest s-v path. 
+ *   Returns an invalid iterator if v=s or v is not
+ *   reachable from s.
+ *
+ *
+ *bool reach(node_iterator v) : true if v is reachable from s
+ *
+ *
+ *
+ *
+ *
+ *Problems: 
+ * 
+ *Heap implementation is needed, because the priority queue of stl
+ *does not have a mathod for key-decrease, so we had to use here a 
+ *g\'any solution.
+ * 
+ *The implementation of infinity would be desirable, see after line 100. 
+ */
+
+#ifndef DIJKSTRA_HH
+#define DIJKSTRA_HH
+
+#include <queue>
+#include <algorithm>
+
+#include <marci_graph_traits.hh>
+#include <marci_property_vector.hh>
+
+
+namespace std {
+  namespace marci {
+
+
+
+
+
+    template <typename graph_type, typename T>
+    class dijkstra{
+      typedef typename graph_traits<graph_type>::node_iterator node_iterator;
+      typedef typename graph_traits<graph_type>::edge_iterator edge_iterator;
+      typedef typename graph_traits<graph_type>::each_node_iterator each_node_iterator;
+      typedef typename graph_traits<graph_type>::in_edge_iterator in_edge_iterator;
+      typedef typename graph_traits<graph_type>::out_edge_iterator out_edge_iterator;
+      
+      
+      graph_type& G;
+      node_iterator s;
+      node_property_vector<graph_type, edge_iterator> predecessor;
+      node_property_vector<graph_type, T> distance;
+      edge_property_vector<graph_type, T> length;
+      node_property_vector<graph_type, bool> reached;
+          
+  public :
+
+    /*
+      The distance of all the nodes is 0.
+    */
+    dijkstra(graph_type& _G, node_iterator _s, edge_property_vector<graph_type, T>& _length) : 
+      G(_G), s(_s), predecessor(G, 0), distance(G, 0), length(_length), reached(G, false) { }
+    
+
+      
+      /*By Misi.*/
+      struct node_dist_comp
+      {
+	node_property_vector<graph_type, T> &d;
+	node_dist_comp(node_property_vector<graph_type, T> &_d) : d(_d) {} 
+	
+	bool operator()(const node_iterator& u, const node_iterator& v) const 
+	{ return d.get(u) < d.get(v); }
+      };
+
+
+      
+      void run() {
+	
+	node_property_vector<graph_type, bool> scanned(G, false);
+	std::priority_queue<node_iterator, vector<node_iterator>, node_dist_comp> 
+	  heap(( node_dist_comp(distance) ));
+      
+	heap.push(s);
+	reached.put(s, true);
+
+	while (!heap.empty()) {
+
+	  node_iterator v=heap.top();	
+	  heap.pop();
+
+
+	  if (!scanned.get(v)) {
+	
+	    for(out_edge_iterator e=G.first_out_edge(v); e.valid(); ++e) {
+	      node_iterator w=G.head(e);
+
+	      if (!scanned.get(w)) {
+		if (!reached.get(w)) {
+		  reached.put(w,true);
+		  distance.put(w, distance.get(v)-length.get(e));
+		  predecessor.put(w,e);
+		} else if (distance.get(v)-length.get(e)>distance.get(w)) {
+		  distance.put(w, distance.get(v)-length.get(e));
+		  predecessor.put(w,e);
+		}
+		
+		heap.push(w);
+	      
+	      } 
+
+	    } 
+	    scanned.put(v,true);
+	    
+	  } // if (!scanned.get(v))
+	  
+	  
+	  
+	} // while (!heap.empty())
+
+	
+      } //void run()
+      
+      
+      
+
+
+      /*
+       *Returns the distance of the node v.
+       *It is 0 for the root and for the nodes not
+       *reachable form the root.
+       */      
+      T dist(node_iterator v) {
+	return -distance.get(v);
+      }
+
+
+
+      /*
+       *  Returns the last edge of a shortest s-v path. 
+       *  Returns an invalid iterator if v=root or v is not
+       *  reachable from the root.
+       */      
+      edge_iterator pred(node_iterator v) {
+	if (v!=s) { return predecessor.get(v);}
+	else {return edge_iterator();}
+      }
+     
+
+      
+      bool reach(node_iterator v) {
+	return reached.get(v);
+      }
+
+
+
+
+
+
+
+
+
+    };// class dijkstra
+
+
+
+  } // namespace marci
+}
+#endif //DIJKSTRA_HH
+
+
diff -r f00a4f7e2149 -r e125f12784e2 src/work/jacint/reverse_bfs.hh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/work/jacint/reverse_bfs.hh	Fri Jan 30 14:56:11 2004 +0000
@@ -0,0 +1,94 @@
+/*
+reverse_bfs
+by jacint
+Performs a bfs on the out edges. It does not count predecessors, 
+only the distances, but one can easily modify it to know the pred as well.
+
+Constructor: 
+
+reverse_bfs(graph_type& G, node_iterator t)
+
+
+
+Member functions:
+
+void run(): runs a reverse bfs from t
+
+  The following function should be used after run() was already run.
+
+int dist(node_iterator v) : returns the distance from v to t. It is the number of nodes if t is not reachable from v.
+
+*/
+#ifndef REVERSE_BFS_HH
+#define REVERSE_BFS_HH
+
+#include <queue>
+
+#include <marci_graph_traits.hh>
+#include <marci_property_vector.hh>
+
+
+
+namespace  marci {
+
+  template <typename graph_type>
+  class reverse_bfs {
+    typedef typename graph_traits<graph_type>::node_iterator node_iterator;
+    //typedef typename graph_traits<graph_type>::edge_iterator edge_iterator;
+    typedef typename graph_traits<graph_type>::each_node_iterator each_node_iterator;
+    typedef typename graph_traits<graph_type>::in_edge_iterator in_edge_iterator;
+
+
+    graph_type& G;
+    node_iterator t;
+//    node_property_vector<graph_type, edge_iterator> pred;
+    node_property_vector<graph_type, int> distance;
+    
+
+  public :
+
+    /*
+      The distance of the nodes is n, except t for which it is 0.
+    */
+    reverse_bfs(graph_type& _G, node_iterator _t) : G(_G), t(_t), distance(G, number_of(G.first_node())) {
+      distance.put(t,0);
+    }
+    
+    void run() {
+
+      node_property_vector<graph_type, bool> reached(G, false); 
+      reached.put(t, true);
+
+      std::queue<node_iterator> bfs_queue;
+      bfs_queue.push(t);
+
+      while (!bfs_queue.empty()) {
+
+        node_iterator v=bfs_queue.front();	
+	bfs_queue.pop();
+
+	for(in_edge_iterator e=G.first_in_edge(v); e.valid(); ++e) {
+	  node_iterator w=G.tail(e);
+	  if (!reached.get(w)) {
+	    bfs_queue.push(w);
+	    distance.put(w, distance.get(v)+1);
+	    reached.put(w, true);
+	  }
+	}
+      }
+    }
+
+
+
+    int dist(node_iterator v) {
+      return distance.get(v);
+    }
+
+
+  };
+
+} // namespace marci
+
+#endif //REVERSE_BFS_HH
+
+
diff -r f00a4f7e2149 -r e125f12784e2 src/work/preflow_push_hl.hh
--- a/src/work/preflow_push_hl.hh	Fri Jan 30 14:55:10 2004 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,320 +0,0 @@
-/*
-preflow_push_hl.hh
-by jacint. 
-Runs the highest label variant of the preflow push algorithm with 
-running time O(n^2\sqrt(m)). 
-
-Member functions:
-
-void run() : runs the algorithm
-
- The following functions should be used after run() was already run.
-
-T maxflow() : returns the value of a maximum flow
-
-T flowonedge(edge_iterator e) : for a fixed maximum flow x it returns x(e) 
-
-edge_property_vector<graph_type, T> allflow() : returns the fixed maximum flow x
-
-node_property_vector<graph_type, bool> mincut() : returns a 
-     characteristic vector of a minimum cut. (An empty level 
-     in the algorithm gives a minimum cut.)
-*/
-
-#ifndef PREFLOW_PUSH_HL_HH
-#define PREFLOW_PUSH_HL_HH
-
-#include <algorithm>
-#include <vector>
-#include <stack>
-
-#include <marci_graph_traits.hh>
-#include <marci_property_vector.hh>
-#include <reverse_bfs.hh>
-
-namespace marci {
-
-  template <typename graph_type, typename T>
-  class preflow_push_hl {
-    
-    typedef typename graph_traits<graph_type>::node_iterator node_iterator;
-    typedef typename graph_traits<graph_type>::edge_iterator edge_iterator;
-    typedef typename graph_traits<graph_type>::each_node_iterator each_node_iterator;
-    typedef typename graph_traits<graph_type>::out_edge_iterator out_edge_iterator;
-    typedef typename graph_traits<graph_type>::in_edge_iterator in_edge_iterator;
-    typedef typename graph_traits<graph_type>::each_edge_iterator each_edge_iterator;
-    
-
-    graph_type& G;
-    node_iterator s;
-    node_iterator t;
-    edge_property_vector<graph_type, T> flow;
-    edge_property_vector<graph_type, T>& capacity; 
-    T value;
-    node_property_vector<graph_type, bool> mincutvector;
-
-   
-  public:
-
-    preflow_push_hl(graph_type& _G, node_iterator _s, node_iterator _t, edge_property_vector<graph_type, T>& _capacity) : G(_G), s(_s), t(_t), flow(_G, 0), capacity(_capacity), mincutvector(_G, true) { }
-
-
-
-
-    /*
-      The run() function runs the highest label preflow-push, 
-      running time: O(n^2\sqrt(m))
-    */
-    void run() {
- 
-      node_property_vector<graph_type, int> level(G);         //level of node
-      node_property_vector<graph_type, T> excess(G);          //excess of node
-            
-      int n=number_of(G.first_node());                        //number of nodes 
-      int b=n; 
-      /*b is a bound on the highest level of an active node. In the beginning it is at most n-2.*/
-
-      std::vector<std::stack<node_iterator> > stack(2*n-1);    //Stack of the active nodes in level i.
-
-
-
-
-      /*Reverse_bfs from t, to find the starting level.*/
-
-      reverse_bfs<list_graph> bfs(G, t);
-      bfs.run();
-      for(each_node_iterator v=G.first_node(); v.valid(); ++v) {
-	level.put(v, bfs.dist(v)); 
-	//std::cout << "the level of " << v << " is " << bfs.dist(v);
-      }
-
-      /*The level of s is fixed to n*/ 
-      level.put(s,n);
-
-
-
-
-
-      /* Starting flow. It is everywhere 0 at the moment. */
-     
-      for(out_edge_iterator i=G.first_out_edge(s); i.valid(); ++i) 
-	{
-	  node_iterator w=G.head(i);
-	  flow.put(i, capacity.get(i)); 
-	  stack[bfs.dist(w)].push(w); 
-	  excess.put(w, capacity.get(i));
-	}
-
-
-      /* 
-	 End of preprocessing 
-      */
-
-
-
-      /*
-	Push/relabel on the highest level active nodes.
-      */
-	
-      /*While there exists active node.*/
-      while (b) { 
-
-	/*We decrease the bound if there is no active node of level b.*/
-	if (stack[b].empty()) {
-	  --b;
-	} else {
-
-	  node_iterator w=stack[b].top();    //w is the highest label active node.
-	  stack[b].pop();                    //We delete w from the stack.
-	
-	  int newlevel=2*n-2;                   //In newlevel we maintain the next level of w.
-	
-	  for(out_edge_iterator e=G.first_out_edge(w); e.valid(); ++e) {
-	    node_iterator v=G.head(e);
-	    /*e is the edge wv.*/
-
-	    if (flow.get(e)<capacity.get(e)) {              
-	      /*e is an edge of the residual graph */
-
-	      if(level.get(w)==level.get(v)+1) {      
-		/*Push is allowed now*/
-
-		if (capacity.get(e)-flow.get(e) > excess.get(w)) {       
-		  /*A nonsaturating push.*/
-		  
-		  if (excess.get(v)==0 && v != s) stack[level.get(v)].push(v); 
-		  /*v becomes active.*/
-		  
-		  flow.put(e, flow.get(e)+excess.get(w));
-		  excess.put(v, excess.get(v)+excess.get(w));
-		  excess.put(w,0);
-		  //std::cout << w << " " << v <<" elore elen nonsat pump "  << std::endl;
-		  break; 
-		} else { 
-		  /*A saturating push.*/
-
-		  if (excess.get(v)==0 && v != s) stack[level.get(v)].push(v); 
-		  /*v becomes active.*/
-
-		  excess.put(v, excess.get(v)+capacity.get(e)-flow.get(e));
-		  excess.put(w, excess.get(w)-capacity.get(e)+flow.get(e));
-		  flow.put(e, capacity.get(e));
-		  //std::cout << w<<" " <<v<<" elore elen sat pump "   << std::endl;
-		  if (excess.get(w)==0) break;
-		  /*If w is not active any more, then we go on to the next node.*/
-		  
-		} // if (capacity.get(e)-flow.get(e) > excess.get(w))
-	      } // if(level.get(w)==level.get(v)+1)
-	    
-	      else {newlevel = newlevel < level.get(v) ? newlevel : level.get(v);}
-	    
-	    } //if (flow.get(e)<capacity.get(e))
-	 
-	  } //for(out_edge_iterator e=G.first_out_edge(w); e.valid(); ++e) 
-	  
-
-
-	  for(in_edge_iterator e=G.first_in_edge(w); e.valid(); ++e) {
-	    node_iterator v=G.tail(e);
-	    /*e is the edge vw.*/
-
-	    if (excess.get(w)==0) break;
-	    /*It may happen, that w became inactive in the first for cycle.*/		
-	    if(flow.get(e)>0) {             
-	      /*e is an edge of the residual graph */
-
-	      if(level.get(w)==level.get(v)+1) {  
-		/*Push is allowed now*/
-		
-		if (flow.get(e) > excess.get(w)) { 
-		  /*A nonsaturating push.*/
-		  
-		  if (excess.get(v)==0 && v != s) stack[level.get(v)].push(v); 
-		  /*v becomes active.*/
-
-		  flow.put(e, flow.get(e)-excess.get(w));
-		  excess.put(v, excess.get(v)+excess.get(w));
-		  excess.put(w,0);
-		  //std::cout << v << " " << w << " vissza elen nonsat pump "     << std::endl;
-		  break; 
-		} else {                                               
-		  /*A saturating push.*/
-		  
-		  if (excess.get(v)==0 && v != s) stack[level.get(v)].push(v); 
-		  /*v becomes active.*/
-		  
-		  excess.put(v, excess.get(v)+flow.get(e));
-		  excess.put(w, excess.get(w)-flow.get(e));
-		  flow.put(e,0);
-		  //std::cout << v <<" " << w << " vissza elen sat pump "     << std::endl;
-		  if (excess.get(w)==0) { break;}
-		} //if (flow.get(e) > excess.get(v)) 
-	      } //if(level.get(w)==level.get(v)+1)
-	      
-	      else {newlevel = newlevel < level.get(v) ? newlevel : level.get(v);}
-	      
-
-	    } //if (flow.get(e)>0)
-
-	  } //for
-
-
-	  if (excess.get(w)>0) {
-	    level.put(w,++newlevel);
-	    stack[newlevel].push(w);
-	    b=newlevel;
-	    //std::cout << "The new level of " << w << " is "<< newlevel <<std::endl; 
-	  }
-
-
-	} //else
-       
-      } //while(b)
-
-      value = excess.get(t);
-      /*Max flow value.*/
-
-
-
-
-    } //void run()
-
-
-
-
-
-    /*
-      Returns the maximum value of a flow.
-     */
-
-    T maxflow() {
-      return value;
-    }
-
-
-
-    /*
-      For the maximum flow x found by the algorithm, it returns the flow value on edge e, i.e. x(e). 
-    */
-
-    T flowonedge(edge_iterator e) {
-      return flow.get(e);
-    }
-
-
-
-    /*
-      Returns the maximum flow x found by the algorithm.
-    */
-
-    edge_property_vector<graph_type, T> allflow() {
-      return flow;
-    }
-
-
-
-    /*
-      Returns a minimum cut by using a reverse bfs from t in the residual graph.
-    */
-    
-    node_property_vector<graph_type, bool> mincut() {
-    
-      std::queue<node_iterator> queue;
-      
-      mincutvector.put(t,false);      
-      queue.push(t);
-
-      while (!queue.empty()) {
-        node_iterator w=queue.front();
-	queue.pop();
-
-	for(in_edge_iterator e=G.first_in_edge(w) ; e.valid(); ++e) {
-	  node_iterator v=G.tail(e);
-	  if (mincutvector.get(v) && flow.get(e) < capacity.get(e) ) {
-	    queue.push(v);
-	    mincutvector.put(v, false);
-	  }
-	} // for
-
-	for(out_edge_iterator e=G.first_out_edge(w) ; e.valid(); ++e) {
-	  node_iterator v=G.head(e);
-	  if (mincutvector.get(v) && flow.get(e) > 0 ) {
-	    queue.push(v);
-	    mincutvector.put(v, false);
-	  }
-	} // for
-
-      }
-
-      return mincutvector;
-    
-    }
-
-
-  };
-}//namespace marci
-#endif 
-
-
-
-
diff -r f00a4f7e2149 -r e125f12784e2 src/work/preflow_push_max_flow.hh
--- a/src/work/preflow_push_max_flow.hh	Fri Jan 30 14:55:10 2004 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,315 +0,0 @@
-/*
-preflow_push_max_flow_hh
-by jacint. 
-Runs a preflow push algorithm with the modification, 
-that we do not push on nodes with level at least n. 
-Moreover, if a level gets empty, we put all nodes above that
-level to level n. Hence, in the end, we arrive at a maximum preflow 
-with value of a max flow value. An empty level gives a minimum cut.
-
-Member functions:
-
-void run() : runs the algorithm
-
-  The following functions should be used after run() was already run.
-
-T maxflow() : returns the value of a maximum flow
-
-node_property_vector<graph_type, bool> mincut(): returns a 
-     characteristic vector of a minimum cut.
-*/
-
-#ifndef PREFLOW_PUSH_MAX_FLOW_HH
-#define PREFLOW_PUSH_MAX_FLOW_HH
-
-#include <algorithm>
-#include <vector>
-#include <stack>
-
-#include <marci_list_graph.hh>
-#include <marci_graph_traits.hh>
-#include <marci_property_vector.hh>
-#include <reverse_bfs.hh>
-
-
-namespace marci {
-
-  template <typename graph_type, typename T>
-  class preflow_push_max_flow {
-    
-    typedef typename graph_traits<graph_type>::node_iterator node_iterator;
-    typedef typename graph_traits<graph_type>::each_node_iterator each_node_iterator;
-    typedef typename graph_traits<graph_type>::out_edge_iterator out_edge_iterator;
-    typedef typename graph_traits<graph_type>::in_edge_iterator in_edge_iterator;
-    
-    graph_type& G;
-    node_iterator s;
-    node_iterator t;
-    edge_property_vector<graph_type, T>& capacity; 
-    T value;
-    node_property_vector<graph_type, bool> mincutvector;    
-
-
-     
-  public:
-        
-    preflow_push_max_flow(graph_type& _G, node_iterator _s, node_iterator _t, edge_property_vector<graph_type, T>& _capacity) : G(_G), s(_s), t(_t), capacity(_capacity), mincutvector(_G, false) { }
-
-
-    /*
-      The run() function runs a modified version of the highest label preflow-push, which only 
-      finds a maximum preflow, hence giving the value of a maximum flow.
-    */
-    void run() {
- 
-      edge_property_vector<graph_type, T> flow(G, 0);         //the flow value, 0 everywhere  
-      node_property_vector<graph_type, int> level(G);         //level of node
-      node_property_vector<graph_type, T> excess(G);          //excess of node
-            
-      int n=number_of(G.first_node());                        //number of nodes 
-      int b=n-2; 
-      /*b is a bound on the highest level of an active node. In the beginning it is at most n-2.*/
-      
-      std::vector<int> numb(n);                                //The number of nodes on level i < n.
-
-      std::vector<std::stack<node_iterator> > stack(2*n-1);    //Stack of the active nodes in level i.
-
-
-
-      /*Reverse_bfs from t, to find the starting level.*/
-
-      reverse_bfs<list_graph> bfs(G, t);
-      bfs.run();
-      for(each_node_iterator v=G.first_node(); v.valid(); ++v) 
-	{
-	  int dist=bfs.dist(v);
-	  level.put(v, dist); 
-	  ++numb[dist];
-	}
-
-      /*The level of s is fixed to n*/ 
-      level.put(s,n);
-
-
-      /* Starting flow. It is everywhere 0 at the moment. */
-     
-      for(out_edge_iterator i=G.first_out_edge(s); i.valid(); ++i) 
-	{
-	  node_iterator w=G.head(i);
-	  flow.put(i, capacity.get(i)); 
-	  stack[bfs.dist(w)].push(w); 
-	  excess.put(w, capacity.get(i));
-	}
-
-
-      /* 
-	 End of preprocessing 
-      */
-
-
-
-
-      /*
-	Push/relabel on the highest level active nodes.
-      */
-	
-      /*While there exists an active node.*/
-      while (b) { 
-
-	/*We decrease the bound if there is no active node of level b.*/
-	if (stack[b].empty()) {
-	  --b;
-	} else {
-
-	  node_iterator w=stack[b].top();    //w is the highest label active node.
-	  stack[b].pop();                    //We delete w from the stack.
-	
-	  int newlevel=2*n-2;                //In newlevel we maintain the next level of w.
-	
-	  for(out_edge_iterator e=G.first_out_edge(w); e.valid(); ++e) {
-	    node_iterator v=G.head(e);
-	    /*e is the edge wv.*/
-
-	    if (flow.get(e)<capacity.get(e)) {              
-	      /*e is an edge of the residual graph */
-
-	      if(level.get(w)==level.get(v)+1) {      
-		/*Push is allowed now*/
-
-		if (capacity.get(e)-flow.get(e) > excess.get(w)) {       
-		  /*A nonsaturating push.*/
-		  
-		  if (excess.get(v)==0 && v != s) stack[level.get(v)].push(v); 
-		  /*v becomes active.*/
-		  
-		  flow.put(e, flow.get(e)+excess.get(w));
-		  excess.put(v, excess.get(v)+excess.get(w));
-		  excess.put(w,0);
-		  //std::cout << w << " " << v <<" elore elen nonsat pump "  << std::endl;
-		  break; 
-		} else { 
-		  /*A saturating push.*/
-
-		  if (excess.get(v)==0 && v != s) stack[level.get(v)].push(v); 
-		  /*v becomes active.*/
-
-		  excess.put(v, excess.get(v)+capacity.get(e)-flow.get(e));
-		  excess.put(w, excess.get(w)-capacity.get(e)+flow.get(e));
-		  flow.put(e, capacity.get(e));
-		  //std::cout << w <<" " << v <<" elore elen sat pump "   << std::endl;
-		  if (excess.get(w)==0) break; 
-		  /*If w is not active any more, then we go on to the next node.*/
-		  
-		} // if (capacity.get(e)-flow.get(e) > excess.get(w))
-	      } // if (level.get(w)==level.get(v)+1)
-	    
-	      else {newlevel = newlevel < level.get(v) ? newlevel : level.get(v);}
-	    
-	    } //if (flow.get(e)<capacity.get(e))
-	 
-	  } //for(out_edge_iterator e=G.first_out_edge(w); e.valid(); ++e) 
-	  
-
-
-	  for(in_edge_iterator e=G.first_in_edge(w); e.valid(); ++e) {
-	    node_iterator v=G.tail(e);
-	    /*e is the edge vw.*/
-
-	    if (excess.get(w)==0) break;
-	    /*It may happen, that w became inactive in the first 'for' cycle.*/		
-  
-	    if(flow.get(e)>0) {             
-	      /*e is an edge of the residual graph */
-
-	      if(level.get(w)==level.get(v)+1) {  
-		/*Push is allowed now*/
-		
-		if (flow.get(e) > excess.get(w)) { 
-		  /*A nonsaturating push.*/
-		  
-		  if (excess.get(v)==0 && v != s) stack[level.get(v)].push(v); 
-		  /*v becomes active.*/
-
-		  flow.put(e, flow.get(e)-excess.get(w));
-		  excess.put(v, excess.get(v)+excess.get(w));
-		  excess.put(w,0);
-		  //std::cout << v << " " << w << " vissza elen nonsat pump "     << std::endl;
-		  break; 
-		} else {                                               
-		  /*A saturating push.*/
-		  
-		  if (excess.get(v)==0 && v != s) stack[level.get(v)].push(v); 
-		  /*v becomes active.*/
-		  
-		  flow.put(e,0);
-		  excess.put(v, excess.get(v)+flow.get(e));
-		  excess.put(w, excess.get(w)-flow.get(e));
-		  //std::cout << v <<" " << w << " vissza elen sat pump "     << std::endl;
-		  if (excess.get(w)==0) { break;}
-		} //if (flow.get(e) > excess.get(v)) 
-	      } //if(level.get(w)==level.get(v)+1)
-	      
-	      else {newlevel = newlevel < level.get(v) ? newlevel : level.get(v);}
-	      //std::cout << "Leveldecrease of node " << w << " to " << newlevel << std::endl; 
-
-	    } //if (flow.get(e)>0)
-
-	  } //for in-edge
-
-
-
-
-	  /*
-	    Relabel
-	  */
-	  if (excess.get(w)>0) {
-	    /*Now newlevel <= n*/
-
-	    int l=level.get(w);	        //l is the old level of w.
-	    --numb[l];
-	   
-	    if (newlevel == n) {
-	      level.put(w,n);
-	      
-	    } else {
-	      
-	      if (numb[l]) {
-		/*If the level of w remains nonempty.*/
-		
-		level.put(w,++newlevel);
-		++numb[newlevel];
-		stack[newlevel].push(w);
-		b=newlevel;
-	      } else { 
-		/*If the level of w gets empty.*/
-	      
-		for (each_node_iterator v=G.first_node() ; v.valid() ; ++v) {
-		  if (level.get(v) >= l ) { 
-		    level.put(v,n);  
-		  }
-		}
-		
-		for (int i=l+1 ; i!=n ; ++i) numb[i]=0; 
-	      } //if (numb[l])
-	
-	    } // if (newlevel = n)
-	 
-	  } // if (excess.get(w)>0)
-
-
-	} //else
-       
-      } //while(b)
-
-      value=excess.get(t);
-      /*Max flow value.*/
-      
-
-
-      /*
-	We find an empty level, e. The nodes above this level give 
-	a minimum cut.
-      */
-      
-      int e=1;
-      
-      while(e) {
-	if(numb[e]) ++e;
-	else break;
-      } 
-      for (each_node_iterator v=G.first_node(); v.valid(); ++v) {
-	if (level.get(v) > e) mincutvector.put(v, true);
-      }
-      
-
-    } // void run()
-
-
-
-    /*
-      Returns the maximum value of a flow.
-     */
-
-    T maxflow() {
-      return value;
-    }
-
-
-
-    /*
-      Returns a minimum cut.
-    */
-    
-    node_property_vector<graph_type, bool> mincut() {
-      return mincutvector;
-    }
-    
-
-  };
-}//namespace marci
-#endif 
-
-
-
-
-
diff -r f00a4f7e2149 -r e125f12784e2 src/work/reverse_bfs.hh
--- a/src/work/reverse_bfs.hh	Fri Jan 30 14:55:10 2004 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/*
-reverse_bfs
-by jacint
-Performs a bfs on the out edges. It does not count predecessors, 
-only the distances, but one can easily modify it to know the pred as well.
-
-Constructor: 
-
-reverse_bfs(graph_type& G, node_iterator t)
-
-
-
-Member functions:
-
-void run(): runs a reverse bfs from t
-
-  The following function should be used after run() was already run.
-
-int dist(node_iterator v) : returns the distance from v to t. It is the number of nodes if t is not reachable from v.
-
-*/
-#ifndef REVERSE_BFS_HH
-#define REVERSE_BFS_HH
-
-#include <queue>
-
-#include <marci_graph_traits.hh>
-#include <marci_property_vector.hh>
-
-
-
-namespace  marci {
-
-  template <typename graph_type>
-  class reverse_bfs {
-    typedef typename graph_traits<graph_type>::node_iterator node_iterator;
-    //typedef typename graph_traits<graph_type>::edge_iterator edge_iterator;
-    typedef typename graph_traits<graph_type>::each_node_iterator each_node_iterator;
-    typedef typename graph_traits<graph_type>::in_edge_iterator in_edge_iterator;
-
-
-    graph_type& G;
-    node_iterator t;
-//    node_property_vector<graph_type, edge_iterator> pred;
-    node_property_vector<graph_type, int> distance;
-    
-
-  public :
-
-    /*
-      The distance of the nodes is n, except t for which it is 0.
-    */
-    reverse_bfs(graph_type& _G, node_iterator _t) : G(_G), t(_t), distance(G, number_of(G.first_node())) {
-      distance.put(t,0);
-    }
-    
-    void run() {
-
-      node_property_vector<graph_type, bool> reached(G, false); 
-      reached.put(t, true);
-
-      std::queue<node_iterator> bfs_queue;
-      bfs_queue.push(t);
-
-      while (!bfs_queue.empty()) {
-
-        node_iterator v=bfs_queue.front();	
-	bfs_queue.pop();
-
-	for(in_edge_iterator e=G.first_in_edge(v); e.valid(); ++e) {
-	  node_iterator w=G.tail(e);
-	  if (!reached.get(w)) {
-	    bfs_queue.push(w);
-	    distance.put(w, distance.get(v)+1);
-	    reached.put(w, true);
-	  }
-	}
-      }
-    }
-
-
-
-    int dist(node_iterator v) {
-      return distance.get(v);
-    }
-
-
-  };
-
-} // namespace marci
-
-#endif //REVERSE_BFS_HH
-
-