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

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


Author: marci
Date: Mon May 10 18:59:20 2004
New Revision: 782

Added:
   hugo/trunk/src/work/marci/bfs_dfs.h
      - copied, changed from r777, /hugo/trunk/src/work/marci/bfs_iterator.h
Removed:
   hugo/trunk/src/work/marci/bfs_iterator.h
Modified:
   hugo/trunk/src/work/jacint/max_flow.h
   hugo/trunk/src/work/marci/bfs_dfs_misc.h
   hugo/trunk/src/work/marci/bfsit_vs_byhand.cc
   hugo/trunk/src/work/marci/bipartite_graph_wrapper_test.cc
   hugo/trunk/src/work/marci/bipartite_matching_try.cc
   hugo/trunk/src/work/marci/bipartite_matching_try_2.cc
   hugo/trunk/src/work/marci/bipartite_matching_try_3.cc
   hugo/trunk/src/work/marci/iterator_bfs_demo.cc

Log:
bfs_iterator -> bfs_dfs.h, some docs


Modified: hugo/trunk/src/work/jacint/max_flow.h
==============================================================================
--- hugo/trunk/src/work/jacint/max_flow.h	(original)
+++ hugo/trunk/src/work/jacint/max_flow.h	Mon May 10 18:59:20 2004
@@ -44,7 +44,7 @@
 #include <stack>
 
 #include <hugo/graph_wrapper.h>
-#include <bfs_iterator.h>
+#include <bfs_dfs.h>
 #include <hugo/invalid.h>
 #include <hugo/maps.h>
 #include <for_each_macros.h>
@@ -55,7 +55,7 @@
 namespace hugo {
 
 
-//  ///\author Marton Makai, Jacint Szabo
+  //  ///\author Marton Makai, Jacint Szabo
   /// A class for computing max flows and related quantities.
   template <typename Graph, typename Num, 
 	    typename CapMap=typename Graph::template EdgeMap<Num>, 
@@ -88,20 +88,20 @@
     //In preflow, it shows levels of nodes.
     //typename Graph::template NodeMap<int> level;    
     typename Graph::template NodeMap<Num> excess; 
-//   protected:
-//     MaxFlow() { }
-//     void set(const Graph& _G, Node _s, Node _t, const CapMap& _capacity, 
-// 	     FlowMap& _flow) 
-//       {
-// 	g=&_G; 
-// 	s=_s; 
-// 	t=_t; 
-// 	capacity=&_capacity;
-// 	flow=&_flow;
-// 	n=_G.nodeNum;
-// 	level.set (_G); //kellene vmi ilyesmi fv 
-// 	excess(_G,0); //itt is
-//       }
+    //   protected:
+    //     MaxFlow() { }
+    //     void set(const Graph& _G, Node _s, Node _t, const CapMap& _capacity, 
+    // 	     FlowMap& _flow) 
+    //       {
+    // 	g=&_G; 
+    // 	s=_s; 
+    // 	t=_t; 
+    // 	capacity=&_capacity;
+    // 	flow=&_flow;
+    // 	n=_G.nodeNum;
+    // 	level.set (_G); //kellene vmi ilyesmi fv 
+    // 	excess(_G,0); //itt is
+    //       }
 
   public:
  
@@ -362,126 +362,127 @@
 
 
     void preflowPreproc ( flowEnum fe, VecStack& active, 
-			  VecNode& level_list, NNMap& left, NNMap& right ) {
+			  VecNode& level_list, NNMap& left, NNMap& right ) 
+    {
 
-			    std::queue<Node> bfs_queue;
+      std::queue<Node> bfs_queue;
       
-			    switch ( fe ) {
-			    case ZERO_FLOW: 
-			      {
-				//Reverse_bfs from t, to find the starting level.
-				level.set(t,0);
-				bfs_queue.push(t);
-	
-				while (!bfs_queue.empty()) {
-	    
-				  Node v=bfs_queue.front();	
-				  bfs_queue.pop();
-				  int l=level[v]+1;
-	    
-				  InEdgeIt e;
-				  for(g->first(e,v); g->valid(e); g->next(e)) {
-				    Node w=g->tail(e);
-				    if ( level[w] == n && w != s ) {
-				      bfs_queue.push(w);
-				      Node first=level_list[l];
-				      if ( g->valid(first) ) left.set(first,w);
-				      right.set(w,first);
-				      level_list[l]=w;
-				      level.set(w, l);
-				    }
-				  }
-				}
-	  
-				//the starting flow
-				OutEdgeIt e;
-				for(g->first(e,s); g->valid(e); g->next(e)) 
-				  {
-				    Num c=(*capacity)[e];
-				    if ( c <= 0 ) continue;
-				    Node w=g->head(e);
-				    if ( level[w] < n ) {	  
-				      if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
-				      flow->set(e, c); 
-				      excess.set(w, excess[w]+c);
-				    }
-				  }
-				break;
-			      }
-	
-			    case GEN_FLOW:
-			    case PREFLOW:
-			      {
-				//Reverse_bfs from t in the residual graph, 
-				//to find the starting level.
-				level.set(t,0);
-				bfs_queue.push(t);
-	  
-				while (!bfs_queue.empty()) {
-	    
-				  Node v=bfs_queue.front();	
-				  bfs_queue.pop();
-				  int l=level[v]+1;
-	    
-				  InEdgeIt e;
-				  for(g->first(e,v); g->valid(e); g->next(e)) {
-				    if ( (*capacity)[e] <= (*flow)[e] ) continue;
-				    Node w=g->tail(e);
-				    if ( level[w] == n && w != s ) {
-				      bfs_queue.push(w);
-				      Node first=level_list[l];
-				      if ( g->valid(first) ) left.set(first,w);
-				      right.set(w,first);
-				      level_list[l]=w;
-				      level.set(w, l);
-				    }
-				  }
-	    
-				  OutEdgeIt f;
-				  for(g->first(f,v); g->valid(f); g->next(f)) {
-				    if ( 0 >= (*flow)[f] ) continue;
-				    Node w=g->head(f);
-				    if ( level[w] == n && w != s ) {
-				      bfs_queue.push(w);
-				      Node first=level_list[l];
-				      if ( g->valid(first) ) left.set(first,w);
-				      right.set(w,first);
-				      level_list[l]=w;
-				      level.set(w, l);
-				    }
-				  }
-				}
-	  
-	  
-				//the starting flow
-				OutEdgeIt e;
-				for(g->first(e,s); g->valid(e); g->next(e)) 
-				  {
-				    Num rem=(*capacity)[e]-(*flow)[e];
-				    if ( rem <= 0 ) continue;
-				    Node w=g->head(e);
-				    if ( level[w] < n ) {	  
-				      if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
-				      flow->set(e, (*capacity)[e]); 
-				      excess.set(w, excess[w]+rem);
-				    }
-				  }
-	  
-				InEdgeIt f;
-				for(g->first(f,s); g->valid(f); g->next(f)) 
-				  {
-				    if ( (*flow)[f] <= 0 ) continue;
-				    Node w=g->tail(f);
-				    if ( level[w] < n ) {	  
-				      if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
-				      excess.set(w, excess[w]+(*flow)[f]);
-				      flow->set(f, 0); 
-				    }
-				  }  
-				break;
-			      } //case PREFLOW
-			    }
-			  } //preflowPreproc
+      switch ( fe ) {
+      case ZERO_FLOW: 
+	{
+	  //Reverse_bfs from t, to find the starting level.
+	  level.set(t,0);
+	  bfs_queue.push(t);
+	
+	  while (!bfs_queue.empty()) {
+	    
+	    Node v=bfs_queue.front();	
+	    bfs_queue.pop();
+	    int l=level[v]+1;
+	    
+	    InEdgeIt e;
+	    for(g->first(e,v); g->valid(e); g->next(e)) {
+	      Node w=g->tail(e);
+	      if ( level[w] == n && w != s ) {
+		bfs_queue.push(w);
+		Node first=level_list[l];
+		if ( g->valid(first) ) left.set(first,w);
+		right.set(w,first);
+		level_list[l]=w;
+		level.set(w, l);
+	      }
+	    }
+	  }
+	  
+	  //the starting flow
+	  OutEdgeIt e;
+	  for(g->first(e,s); g->valid(e); g->next(e)) 
+	    {
+	      Num c=(*capacity)[e];
+	      if ( c <= 0 ) continue;
+	      Node w=g->head(e);
+	      if ( level[w] < n ) {	  
+		if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
+		flow->set(e, c); 
+		excess.set(w, excess[w]+c);
+	      }
+	    }
+	  break;
+	}
+	
+      case GEN_FLOW:
+      case PREFLOW:
+	{
+	  //Reverse_bfs from t in the residual graph, 
+	  //to find the starting level.
+	  level.set(t,0);
+	  bfs_queue.push(t);
+	  
+	  while (!bfs_queue.empty()) {
+	    
+	    Node v=bfs_queue.front();	
+	    bfs_queue.pop();
+	    int l=level[v]+1;
+	    
+	    InEdgeIt e;
+	    for(g->first(e,v); g->valid(e); g->next(e)) {
+	      if ( (*capacity)[e] <= (*flow)[e] ) continue;
+	      Node w=g->tail(e);
+	      if ( level[w] == n && w != s ) {
+		bfs_queue.push(w);
+		Node first=level_list[l];
+		if ( g->valid(first) ) left.set(first,w);
+		right.set(w,first);
+		level_list[l]=w;
+		level.set(w, l);
+	      }
+	    }
+	    
+	    OutEdgeIt f;
+	    for(g->first(f,v); g->valid(f); g->next(f)) {
+	      if ( 0 >= (*flow)[f] ) continue;
+	      Node w=g->head(f);
+	      if ( level[w] == n && w != s ) {
+		bfs_queue.push(w);
+		Node first=level_list[l];
+		if ( g->valid(first) ) left.set(first,w);
+		right.set(w,first);
+		level_list[l]=w;
+		level.set(w, l);
+	      }
+	    }
+	  }
+	  
+	  
+	  //the starting flow
+	  OutEdgeIt e;
+	  for(g->first(e,s); g->valid(e); g->next(e)) 
+	    {
+	      Num rem=(*capacity)[e]-(*flow)[e];
+	      if ( rem <= 0 ) continue;
+	      Node w=g->head(e);
+	      if ( level[w] < n ) {	  
+		if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
+		flow->set(e, (*capacity)[e]); 
+		excess.set(w, excess[w]+rem);
+	      }
+	    }
+	  
+	  InEdgeIt f;
+	  for(g->first(f,s); g->valid(f); g->next(f)) 
+	    {
+	      if ( (*flow)[f] <= 0 ) continue;
+	      Node w=g->tail(f);
+	      if ( level[w] < n ) {	  
+		if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
+		excess.set(w, excess[w]+(*flow)[f]);
+		flow->set(f, 0); 
+	      }
+	    }  
+	  break;
+	} //case PREFLOW
+      }
+    } //preflowPreproc
 
 
 

Copied: hugo/trunk/src/work/marci/bfs_dfs.h (from r777, /hugo/trunk/src/work/marci/bfs_iterator.h)
==============================================================================
--- /hugo/trunk/src/work/marci/bfs_iterator.h	(original)
+++ hugo/trunk/src/work/marci/bfs_dfs.h	Mon May 10 18:59:20 2004
@@ -1,6 +1,6 @@
 // -*- c++ -*-
-#ifndef HUGO_BFS_ITERATOR_H
-#define HUGO_BFS_ITERATOR_H
+#ifndef HUGO_BFS_DFS_H
+#define HUGO_BFS_DFS_H
 
 #include <queue>
 #include <stack>
@@ -311,4 +311,4 @@
 
 } // namespace hugo
 
-#endif //HUGO_BFS_ITERATOR_H
+#endif //HUGO_BFS_DFS_H

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	Mon May 10 18:59:20 2004
@@ -2,7 +2,7 @@
 #ifndef HUGO_BFS_DFS_MISC_H
 #define HUGO_BFS_DFS_MISC_H
 
-#include <bfs_iterator.h>
+#include <bfs_dfs.h>
 #include <for_each_macros.h>
 
 namespace hugo {

Modified: hugo/trunk/src/work/marci/bfsit_vs_byhand.cc
==============================================================================
--- hugo/trunk/src/work/marci/bfsit_vs_byhand.cc	(original)
+++ hugo/trunk/src/work/marci/bfsit_vs_byhand.cc	Mon May 10 18:59:20 2004
@@ -7,7 +7,7 @@
 #include <hugo/dimacs.h>
 #include <hugo/time_measure.h>
 #include <for_each_macros.h>
-#include <bfs_iterator.h>
+#include <bfs_dfs.h>
 
 using namespace hugo;
 

Modified: hugo/trunk/src/work/marci/bipartite_graph_wrapper_test.cc
==============================================================================
--- hugo/trunk/src/work/marci/bipartite_graph_wrapper_test.cc	(original)
+++ hugo/trunk/src/work/marci/bipartite_graph_wrapper_test.cc	Mon May 10 18:59:20 2004
@@ -8,7 +8,7 @@
 //#include <dimacs.h>
 #include <hugo/time_measure.h>
 #include <for_each_macros.h>
-#include <bfs_iterator.h>
+#include <bfs_dfs.h>
 #include <hugo/graph_wrapper.h>
 #include <bipartite_graph_wrapper.h>
 #include <hugo/maps.h>

Modified: hugo/trunk/src/work/marci/bipartite_matching_try.cc
==============================================================================
--- hugo/trunk/src/work/marci/bipartite_matching_try.cc	(original)
+++ hugo/trunk/src/work/marci/bipartite_matching_try.cc	Mon May 10 18:59:20 2004
@@ -9,7 +9,7 @@
 //#include <dimacs.h>
 #include <hugo/time_measure.h>
 #include <for_each_macros.h>
-#include <bfs_iterator.h>
+#include <bfs_dfs.h>
 #include <hugo/graph_wrapper.h>
 #include <bipartite_graph_wrapper.h>
 #include <hugo/maps.h>

Modified: hugo/trunk/src/work/marci/bipartite_matching_try_2.cc
==============================================================================
--- hugo/trunk/src/work/marci/bipartite_matching_try_2.cc	(original)
+++ hugo/trunk/src/work/marci/bipartite_matching_try_2.cc	Mon May 10 18:59:20 2004
@@ -9,7 +9,7 @@
 //#include <dimacs.h>
 #include <hugo/time_measure.h>
 #include <for_each_macros.h>
-#include <bfs_iterator.h>
+#include <bfs_dfs.h>
 #include <bipartite_graph_wrapper.h>
 #include <hugo/maps.h>
 #include <max_flow.h>

Modified: hugo/trunk/src/work/marci/bipartite_matching_try_3.cc
==============================================================================
--- hugo/trunk/src/work/marci/bipartite_matching_try_3.cc	(original)
+++ hugo/trunk/src/work/marci/bipartite_matching_try_3.cc	Mon May 10 18:59:20 2004
@@ -8,7 +8,7 @@
 //#include <dimacs.h>
 #include <hugo/time_measure.h>
 #include <for_each_macros.h>
-#include <bfs_iterator.h>
+#include <bfs_dfs.h>
 #include <bipartite_graph_wrapper.h>
 #include <hugo/maps.h>
 #include <max_flow.h>

Modified: hugo/trunk/src/work/marci/iterator_bfs_demo.cc
==============================================================================
--- hugo/trunk/src/work/marci/iterator_bfs_demo.cc	(original)
+++ hugo/trunk/src/work/marci/iterator_bfs_demo.cc	Mon May 10 18:59:20 2004
@@ -5,7 +5,7 @@
 
 #include <list_graph.h>
 //#include <smart_graph.h>
-#include <bfs_iterator.h>
+#include <bfs_dfs.h>
 #include <hugo/graph_wrapper.h>
 
 using namespace hugo;



More information about the Lemon-commits mailing list