minlengthpaths_test.cc is already hugo++ comform and is compilable
authorhegyi
Tue, 31 Aug 2004 13:40:07 +0000
changeset 776f2994a2b10b2
parent 775 e46a1f0623a0
child 777 a82713ed19f3
minlengthpaths_test.cc is already hugo++ comform and is compilable
src/hugo/bin_heap.h
src/hugo/dijkstra.h
src/hugo/mincostflows.h
src/hugo/minlengthpaths.h
src/test/dijkstra_heap_test.cc
src/test/dijkstra_test.cc
     1.1 --- a/src/hugo/bin_heap.h	Tue Aug 31 11:26:59 2004 +0000
     1.2 +++ b/src/hugo/bin_heap.h	Tue Aug 31 13:40:07 2004 +0000
     1.3 @@ -33,7 +33,8 @@
     1.4   * csokkentettunk-e rajta, vagy noveltunk.
     1.5   * Ehhez nagyon fontos, hogy az atadott property map inicializalva legyen
     1.6   * minden szobajovo kulcs ertekre, -1 -es ertekkel!
     1.7 - * Es ilyen esetben a kulcsokrol lekerdezheto az allapotuk a state metodussal:
     1.8 + * Es ilyen esetben a kulcsokrol lekerdezheto az allapotuk a state
     1.9 + metodussal:
    1.10   * (nem jart meg a kupacban PRE_HEAP=-1, epp a kupacban van IN_HEAP=0,
    1.11   *  mar kikerult a kupacbol POST_HEAP=-2).
    1.12   * Szoval ebben a modban a kupac nagyjabol hasznalhato property_map-kent, csak
     2.1 --- a/src/hugo/dijkstra.h	Tue Aug 31 11:26:59 2004 +0000
     2.2 +++ b/src/hugo/dijkstra.h	Tue Aug 31 13:40:07 2004 +0000
     2.3 @@ -242,7 +242,6 @@
     2.4  	
     2.5  	for(OutEdgeIt e(*G,v); e!=INVALID; ++e) {
     2.6  	  Node w=G->head(e); 
     2.7 -	  
     2.8  	  switch(heap.state(w)) {
     2.9  	  case HeapType::PRE_HEAP:
    2.10  	    heap.push(w,oldvalue+(*length)[e]); 
     3.1 --- a/src/hugo/mincostflows.h	Tue Aug 31 11:26:59 2004 +0000
     3.2 +++ b/src/hugo/mincostflows.h	Tue Aug 31 13:40:07 2004 +0000
     3.3 @@ -116,12 +116,12 @@
     3.4        //Resetting variables from previous runs
     3.5        total_length = 0;
     3.6        
     3.7 -      FOR_EACH_LOC(typename Graph::EdgeIt, e, G){
     3.8 +      for(typename Graph::EdgeIt e=loopFirst(typename Graph::EdgeIt(), (G)); e!=INVALID; ++e){
     3.9  	flow.set(e,0);
    3.10        }
    3.11  
    3.12        //Initialize the potential to zero
    3.13 -      FOR_EACH_LOC(typename Graph::NodeIt, n, G){
    3.14 +      for(typename Graph::NodeIt n=loopFirst(typename Graph::NodeIt(), (G)); n!=INVALID; ++n){
    3.15  	potential.set(n,0);
    3.16        }
    3.17        
    3.18 @@ -144,7 +144,9 @@
    3.19  	};
    3.20  	
    3.21  	//We have to change the potential
    3.22 -	FOR_EACH_LOC(typename ResGraphType::NodeIt, n, res_graph){
    3.23 +        //#define FOR_EACH_LOC(Ittype, e, g) for(Ittype e=loopFirst(Ittype(), (g)); (g).valid(e); (g).next(e))
    3.24 +	//FOR_EACH_LOC(typename ResGraphType::NodeIt, n, res_graph){
    3.25 +        for(typename ResGraphType::NodeIt n=loopFirst(typename ResGraphType::NodeIt(), (res_graph)); n!=INVALID; ++n){
    3.26  	  potential[n] += dijkstra.distMap()[n];
    3.27  	}
    3.28  
    3.29 @@ -195,7 +197,9 @@
    3.30      bool checkComplementarySlackness(){
    3.31        Length mod_pot;
    3.32        Length fl_e;
    3.33 -      FOR_EACH_LOC(typename Graph::EdgeIt, e, G){
    3.34 +        //#define FOR_EACH_LOC(Ittype, e, g) for(Ittype e=loopFirst(Ittype(), (g)); (g).valid(e); (g).next(e))
    3.35 +        //FOR_EACH_LOC(typename Graph::EdgeIt, e, G){
    3.36 +        for(typename Graph::EdgeIt e=loopFirst(typename Graph::EdgeIt(), (G)); e!=INVALID; ++e){
    3.37  	//C^{\Pi}_{i,j}
    3.38  	mod_pot = length[e]-potential[G.head(e)]+potential[G.tail(e)];
    3.39  	fl_e = flow[e];
     4.1 --- a/src/hugo/minlengthpaths.h	Tue Aug 31 11:26:59 2004 +0000
     4.2 +++ b/src/hugo/minlengthpaths.h	Tue Aug 31 13:40:07 2004 +0000
     4.3 @@ -83,7 +83,8 @@
     4.4        //The name here suggests that the flow has only 0/1 values.
     4.5        EdgeIntMap reversed(G); 
     4.6  
     4.7 -      FOR_EACH_LOC(typename Graph::EdgeIt, e, G){
     4.8 +      //FOR_EACH_LOC(typename Graph::EdgeIt, e, G){
     4.9 +      for(typename Graph::EdgeIt e=loopFirst(typename Graph::EdgeIt(), (G)); e!=INVALID; ++e){
    4.10  	reversed[e] = mincost_flow.getFlow()[e];
    4.11        }
    4.12        
    4.13 @@ -100,7 +101,7 @@
    4.14  	  G.first(e,n);
    4.15  	  
    4.16  	  while (!reversed[e]){
    4.17 -	    G.next(e);
    4.18 +	    ++e;
    4.19  	  }
    4.20  	  n = G.head(e);
    4.21  	  paths[j].push_back(e);
     5.1 --- a/src/test/dijkstra_heap_test.cc	Tue Aug 31 11:26:59 2004 +0000
     5.2 +++ b/src/test/dijkstra_heap_test.cc	Tue Aug 31 13:40:07 2004 +0000
     5.3 @@ -56,7 +56,7 @@
     5.4    int error2=0;
     5.5  
     5.6    EdgeIt e;
     5.7 -  for(G.first(e); G.valid(e); G.next(e)) {
     5.8 +  for(G.first(e); e!=INVALID; ++e) {
     5.9      Node u=G.tail(e);
    5.10      Node v=G.head(e);
    5.11      if ( dijkstra_test.dist(v) - dijkstra_test.dist(u) > cap[e] )
    5.12 @@ -69,7 +69,7 @@
    5.13    }
    5.14  
    5.15    NodeIt v;
    5.16 -  for(G.first(v); G.valid(v); G.next(v)) {
    5.17 +  for(G.first(v); v!=INVALID; ++v) {
    5.18      if ( dijkstra_test.reached(v) ) {
    5.19        Edge e=dijkstra_test.pred(v);
    5.20        Node u=G.tail(e);
    5.21 @@ -105,7 +105,7 @@
    5.22    error1=0;
    5.23    error2=0;
    5.24  
    5.25 -  for(G.first(e); G.valid(e); G.next(e)) {
    5.26 +  for(G.first(e); e!=INVALID; ++e) {
    5.27      Node u=G.tail(e);
    5.28      Node v=G.head(e);
    5.29      if ( dijkstra_test2.dist(v) - dijkstra_test2.dist(u) > cap[e] )
    5.30 @@ -117,7 +117,7 @@
    5.31        }
    5.32    }
    5.33  
    5.34 -  for(G.first(v); G.valid(v); G.next(v)) {
    5.35 +  for(G.first(v); v!=INVALID; ++v) {
    5.36      if ( dijkstra_test2.reached(v) ) {
    5.37        Edge e=dijkstra_test2.pred(v);
    5.38        Node u=G.tail(e);
     6.1 --- a/src/test/dijkstra_test.cc	Tue Aug 31 11:26:59 2004 +0000
     6.2 +++ b/src/test/dijkstra_test.cc	Tue Aug 31 13:40:07 2004 +0000
     6.3 @@ -75,7 +75,7 @@
     6.4    check(dijkstra_test.dist(t)==13,"Dijkstra found a wrong path.");
     6.5  
     6.6  
     6.7 -  for(EdgeIt e(G); e==INVALID; ++e) {
     6.8 +  for(EdgeIt e(G); e!=INVALID; ++e) {
     6.9      Node u=G.tail(e);
    6.10      Node v=G.head(e);
    6.11      check( !dijkstra_test.reached(u) ||
    6.12 @@ -86,7 +86,7 @@
    6.13    }
    6.14  
    6.15    ///\bug This works only for integer lengths
    6.16 -  for(NodeIt v(G); v==INVALID; ++v)
    6.17 +  for(NodeIt v(G); v!=INVALID; ++v)
    6.18      if ( dijkstra_test.reached(v) ) {
    6.19        Edge e=dijkstra_test.pred(v);
    6.20        Node u=G.tail(e);