.
authormarci
Wed, 17 Mar 2004 15:09:48 +0000
changeset 194a1680b3c516c
parent 193 84c19824322a
child 195 19f8bd411014
.
src/work/edmonds_karp.h
src/work/marci/makefile
src/work/marci/max_bipartite_matching_demo.cc
     1.1 --- a/src/work/edmonds_karp.h	Wed Mar 17 15:01:04 2004 +0000
     1.2 +++ b/src/work/edmonds_karp.h	Wed Mar 17 15:09:48 2004 +0000
     1.3 @@ -532,6 +532,7 @@
     1.4    class MaxMatching {
     1.5    public:
     1.6      typedef typename Graph::Node Node;
     1.7 +    typedef typename Graph::NodeIt NodeIt;
     1.8      typedef typename Graph::Edge Edge;
     1.9      typedef typename Graph::EdgeIt EdgeIt;
    1.10      typedef typename Graph::OutEdgeIt OutEdgeIt;
    1.11 @@ -563,7 +564,7 @@
    1.12        typename AugGraph::NodeMap<AugEdge> pred(res_graph); 
    1.13        for(NodeIt s=G->template first<NodeIt>(); G->valid(s); G->next(s)) {
    1.14  	Number f=0;
    1.15 -	for(OutEdgeIt e=G->template first<OutEdgeIt>(); G->valid(e); G->next(e))
    1.16 +	for(OutEdgeIt e=G->template first<OutEdgeIt>(s); G->valid(e); G->next(e))
    1.17  	  f+=flow->get(e);
    1.18  	if (f<1) {
    1.19  	  res_bfs.pushAndSetReached(s);
    1.20 @@ -586,7 +587,7 @@
    1.21  	  } else {
    1.22  	    free.set(w, res_graph.free(e)); 
    1.23  	  }
    1.24 -	  if (TMap(res_graph.head(e))) { 
    1.25 +	  if (T->get(res_graph.head(e))) { 
    1.26  	    n=res_graph.head(e);
    1.27  	    _augment=true; 
    1.28  	    break; 
    1.29 @@ -598,7 +599,7 @@
    1.30  
    1.31        if (_augment) {
    1.32  	//Node n=t;
    1.33 -	Number augment_value=free.get(t);
    1.34 +	Number augment_value=free.get(n);
    1.35  	while (res_graph.valid(pred.get(n))) { 
    1.36  	  AugEdge e=pred.get(n);
    1.37  	  res_graph.augment(e, augment_value); 
    1.38 @@ -805,18 +806,18 @@
    1.39  	//std::cout<<std::endl;
    1.40        } 
    1.41      }
    1.42 -    template<typename MutableGraph> void run() {
    1.43 -      //int num_of_augmentations=0;
    1.44 -      //while (augmentOnShortestPath()) { 
    1.45 -	while (augmentOnBlockingFlow<MutableGraph>()) { 
    1.46 -	//std::cout << ++num_of_augmentations << " ";
    1.47 -	//std::cout<<std::endl;
    1.48 -      } 
    1.49 -    }
    1.50 +//     template<typename MutableGraph> void run() {
    1.51 +//       //int num_of_augmentations=0;
    1.52 +//       //while (augmentOnShortestPath()) { 
    1.53 +// 	while (augmentOnBlockingFlow<MutableGraph>()) { 
    1.54 +// 	//std::cout << ++num_of_augmentations << " ";
    1.55 +// 	//std::cout<<std::endl;
    1.56 +//       } 
    1.57 +//     } 
    1.58      Number flowValue() { 
    1.59        Number a=0;
    1.60 -      OutEdgeIt e;
    1.61 -      for(G->/*getF*/first(e, s); G->valid(e); G->next(e)) {
    1.62 +      EdgeIt e;
    1.63 +      for(G->/*getF*/first(e); G->valid(e); G->next(e)) {
    1.64  	a+=flow->get(e);
    1.65        }
    1.66        return a;
     2.1 --- a/src/work/marci/makefile	Wed Mar 17 15:01:04 2004 +0000
     2.2 +++ b/src/work/marci/makefile	Wed Mar 17 15:09:48 2004 +0000
     2.3 @@ -9,7 +9,7 @@
     2.4  CXXFLAGS = -g -O -W -Wall $(INCLUDEDIRS) -ansi -pedantic
     2.5  
     2.6  
     2.7 -BINARIES = edmonds_karp_demo preflow_demo_leda lg_vs_sg leda_graph_demo leda_bfs_dfs
     2.8 +BINARIES = edmonds_karp_demo preflow_demo_leda lg_vs_sg leda_graph_demo leda_bfs_dfs max_bipartite_matching_demo
     2.9  #preflow_demo_boost edmonds_karp_demo_boost preflow_demo_jacint preflow_demo_athos edmonds_karp_demo_alpar
    2.10  
    2.11  all: $(BINARIES)
    2.12 @@ -28,6 +28,12 @@
    2.13  leda_graph_demo: leda_graph_demo.o
    2.14  	$(CXX3) -Wall -O -L$(LEDAROOT) -o leda_graph_demo leda_graph_demo.o -lG -lL -lm
    2.15  
    2.16 +max_bipartite_matching_demo.o:
    2.17 +	$(CXX3) -Wall -O -I.. -I../alpar -I$(LEDAROOT)/incl -I. -c max_bipartite_matching_demo.cc
    2.18 +
    2.19 +max_bipartite_matching_demo: max_bipartite_matching_demo.o
    2.20 +	$(CXX3) -Wall -O -L$(LEDAROOT) -o max_bipartite_matching_demo max_bipartite_matching_demo.o -lG -lL -lm
    2.21 +
    2.22  leda_bfs_dfs.o:
    2.23  	$(CXX3) -Wall -O -I.. -I../alpar -I$(LEDAROOT)/incl -I. -c leda_bfs_dfs.cc
    2.24  
     3.1 --- a/src/work/marci/max_bipartite_matching_demo.cc	Wed Mar 17 15:01:04 2004 +0000
     3.2 +++ b/src/work/marci/max_bipartite_matching_demo.cc	Wed Mar 17 15:09:48 2004 +0000
     3.3 @@ -49,7 +49,7 @@
     3.4    typedef Graph::OutEdgeIt OutEdgeIt;
     3.5    typedef Graph::InEdgeIt InEdgeIt;
     3.6  
     3.7 -  Node s, t;
     3.8 +  //Node s, t;
     3.9    //Graph::EdgeMap<int> cap(G);
    3.10    //readDimacsMaxFlow(std::cin, G, s, t, cap);
    3.11    std::vector<Node> s_nodes;
    3.12 @@ -65,8 +65,8 @@
    3.13    for(int i=0; i<50; ++i) {
    3.14      G.addEdge(s_nodes[random(20)], t_nodes[random(20)]);
    3.15    }
    3.16 -  Graph::NodeMap<bool> s_map; //false
    3.17 -  Graph::NodeMap<bool> t_map; //false
    3.18 +  Graph::NodeMap<bool> s_map(G); //false
    3.19 +  Graph::NodeMap<bool> t_map(G); //false
    3.20    
    3.21    for(int i=0; i<20; ++i) {
    3.22      s_map.set(s_nodes[i], true);
    3.23 @@ -76,7 +76,7 @@
    3.24    {
    3.25      std::cout << "on-the-fly max bipartite matching demo on wrapped leda graph..." << std::endl;
    3.26      Graph::EdgeMap<int> flow(G); //0 flow
    3.27 -    Graph::EdgeMap<int> capacity(G, 1);
    3.28 +    Graph::EdgeMap<int> cap(G, 1);
    3.29  
    3.30      Timer ts;
    3.31      ts.reset();