Changeset 745:d976ba609099 in lemon-0.x
- Timestamp:
- 07/29/04 19:18:49 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1005
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/hugo/max_flow.h
r735 r745 141 141 /// 142 142 MaxFlow(const Graph& _G, Node _s, Node _t, 143 143 const CapMap& _capacity, FlowMap& _flow) : 144 144 g(&_G), s(_s), t(_t), capacity(&_capacity), 145 145 flow(&_flow), n(_G.nodeNum()), level(_G), excess(_G,0), … … 218 218 VecFirst first(n, INVALID); 219 219 NNMap next(*g, INVALID); //maybe INVALID is not needed 220 // VecStack active(n);221 220 222 221 NNMap left(*g, INVALID); … … 255 254 first[lev]=v; 256 255 } 257 // active[lev].push(v);258 256 } 259 257 break; … … 281 279 } 282 280 283 preflowPreproc(fe, next, first, /*active*/level_list, left, right);281 preflowPreproc(fe, next, first, level_list, left, right); 284 282 //End of preprocessing 285 283 … … 294 292 } 295 293 296 if ( !g->valid(first[b]) /*active[b].empty()*/) --b;294 if ( !g->valid(first[b]) ) --b; 297 295 else { 298 296 end=false; 299 297 Node w=first[b]; 300 298 first[b]=next[w]; 301 /* Node w=active[b].top(); 302 active[b].pop();*/ 303 int newlevel=push(w,/*active*/next, first); 304 if ( excess[w] > 0 ) relabel(w, newlevel, /*active*/next, first, level_list, 299 int newlevel=push(w, next, first); 300 if ( excess[w] > 0 ) relabel(w, newlevel, next, first, level_list, 305 301 left, right, b, k, what_heur); 306 302 … … 341 337 VecFirst first(n, INVALID); 342 338 NNMap next(*g, INVALID); //maybe INVALID is not needed 343 // VecStack active(n);344 339 level.set(s,0); 345 340 std::queue<Node> bfs_queue; … … 362 357 next.set(u,first[l]); 363 358 first[l]=u; 364 //active[l].push(u);365 359 } 366 360 } … … 377 371 next.set(u,first[l]); 378 372 first[l]=u; 379 //active[l].push(u);380 373 } 381 374 } … … 388 381 if ( b == 0 ) break; 389 382 390 if ( !g->valid(first[b]) /*active[b].empty()*/) --b;383 if ( !g->valid(first[b]) ) --b; 391 384 else { 392 385 393 386 Node w=first[b]; 394 387 first[b]=next[w]; 395 /* Node w=active[b].top();396 active[b].pop();*/397 388 int newlevel=push(w,next, first/*active*/); 398 389 … … 402 393 next.set(w,first[newlevel]); 403 394 first[newlevel]=w; 404 //active[newlevel].push(w);405 395 b=newlevel; 406 396 } … … 421 411 for(InEdgeIt e(*g,t);g->valid(e);g->next(e)) a+=(*flow)[e]; 422 412 for(OutEdgeIt e(*g,t);g->valid(e);g->next(e)) a-=(*flow)[e]; 423 413 return a; 424 414 //marci figyu: excess[t] epp ezt adja preflow 1. fazisa utan 415 } 416 Num flowValue2() const { 417 return excess[t]; 418 // Num a=0; 419 // for(InEdgeIt e(*g,t);g->valid(e);g->next(e)) a+=(*flow)[e]; 420 // for(OutEdgeIt e(*g,t);g->valid(e);g->next(e)) a-=(*flow)[e]; 421 // return a; 422 // //marci figyu: excess[t] epp ezt adja preflow 1. fazisa utan 423 425 424 } 426 425 … … 452 451 case AFTER_PRE_FLOW_PHASE_2: 453 452 case AFTER_NOTHING: 453 case AFTER_AUGMENTING: 454 case AFTER_FAST_AUGMENTING: 454 455 minMinCut(M); 455 456 break; … … 592 593 next.set(v,first[level[v]]); 593 594 first[level[v]]=v; 594 // int lev_v=level[v];595 //active[lev_v].push(v);596 595 } 597 596 … … 627 626 next.set(v,first[level[v]]); 628 627 first[level[v]]=v; 629 //int lev_v=level[v];630 //active[lev_v].push(v);631 628 } 632 629 … … 701 698 next.set(w,first[level[w]]); 702 699 first[level[w]]=w; 703 //active[level[w]].push(w);704 700 } 705 701 flow->set(e, c); … … 766 762 next.set(w,first[level[w]]); 767 763 first[level[w]]=w; 768 //active[level[w]].push(w);769 764 } 770 765 flow->set(e, (*capacity)[e]); … … 783 778 next.set(w,first[level[w]]); 784 779 first[level[w]]=w; 785 //active[level[w]].push(w);786 780 } 787 781 excess.set(w, excess[w]+(*flow)[f]); … … 835 829 level_list[i]=INVALID; 836 830 if ( !what_heur ) first[i]=INVALID; 837 /*{838 while ( !active[i].empty() ) {839 active[i].pop(); //FIXME: ezt szebben kene840 }841 }*/842 831 } 843 832 … … 854 843 next.set(w,first[newlevel]); 855 844 first[newlevel]=w; 856 // active[newlevel].push(w);857 845 if ( what_heur ) b=newlevel; 858 846 if ( k < newlevel ) ++k; //now k=newlevel
Note: See TracChangeset
for help on using the changeset viewer.