src/work/jacint/preflow.h
author jacint
Sat, 21 Feb 2004 22:15:11 +0000
changeset 111 3a5ebcd91d37
child 113 cf7b01232d86
permissions -rw-r--r--
*** empty log message ***
jacint@109
     1
// -*- C++ -*-
jacint@109
     2
/*
jacint@109
     3
preflow.h
jacint@109
     4
by jacint. 
jacint@109
     5
Heuristics: 
jacint@109
     6
 2 phase
jacint@109
     7
 gap
jacint@109
     8
 list 'level_list' on the nodes on level i implemented by hand
jacint@109
     9
 stack 'active' on the active nodes on level i implemented by hand
jacint@109
    10
 runs heuristic 'highest label' for H1*n relabels
jacint@109
    11
 runs heuristic 'dound decrease' for H0*n relabels, starts with 'highest label'
jacint@109
    12
 
jacint@109
    13
Parameters H0 and H1 are initialized to 20 and 10.
jacint@109
    14
jacint@109
    15
The best preflow I could ever write.
jacint@109
    16
jacint@109
    17
The constructor runs the algorithm.
jacint@109
    18
jacint@109
    19
Members:
jacint@109
    20
jacint@109
    21
T maxFlow() : returns the value of a maximum flow
jacint@109
    22
jacint@109
    23
T flowOnEdge(EdgeIt e) : for a fixed maximum flow x it returns x(e) 
jacint@109
    24
jacint@109
    25
FlowMap Flow() : returns the fixed maximum flow x
jacint@109
    26
jacint@109
    27
void minMinCut(CutMap& M) : sets M to the characteristic vector of the 
jacint@109
    28
     minimum min cut. M should be a map of bools initialized to false.
jacint@109
    29
jacint@109
    30
void maxMinCut(CutMap& M) : sets M to the characteristic vector of the 
jacint@109
    31
     maximum min cut. M should be a map of bools initialized to false.
jacint@109
    32
jacint@109
    33
void minCut(CutMap& M) : sets M to the characteristic vector of 
jacint@109
    34
     a min cut. M should be a map of bools initialized to false.
jacint@109
    35
jacint@109
    36
*/
jacint@109
    37
jacint@109
    38
#ifndef PREFLOW_H
jacint@109
    39
#define PREFLOW_H
jacint@109
    40
jacint@109
    41
#define H0 20
jacint@109
    42
#define H1 1
jacint@109
    43
jacint@109
    44
#include <vector>
jacint@109
    45
#include <queue>
jacint@109
    46
jacint@109
    47
namespace hugo {
jacint@109
    48
jacint@109
    49
  template <typename Graph, typename T, 
jacint@109
    50
    typename FlowMap=typename Graph::EdgeMap<T>,
jacint@109
    51
    typename CapMap=typename Graph::EdgeMap<T> >
jacint@109
    52
  class preflow {
jacint@109
    53
    
jacint@109
    54
    typedef typename Graph::NodeIt NodeIt;
jacint@109
    55
    typedef typename Graph::EdgeIt EdgeIt;
jacint@109
    56
    typedef typename Graph::EachNodeIt EachNodeIt;
jacint@109
    57
    typedef typename Graph::OutEdgeIt OutEdgeIt;
jacint@109
    58
    typedef typename Graph::InEdgeIt InEdgeIt;
jacint@109
    59
    
jacint@109
    60
    Graph& G;
jacint@109
    61
    NodeIt s;
jacint@109
    62
    NodeIt t;
jacint@109
    63
    FlowMap flow;
jacint@109
    64
    CapMap& capacity;  
jacint@109
    65
    T value;
jacint@109
    66
jacint@109
    67
  public:
jacint@109
    68
    
jacint@109
    69
    preflow(Graph& _G, NodeIt _s, NodeIt _t, CapMap& _capacity ) :
jacint@109
    70
      G(_G), s(_s), t(_t), flow(_G, 0), capacity(_capacity)
jacint@109
    71
    {
jacint@109
    72
jacint@109
    73
      bool phase=0;        //phase 0 is the 1st phase, phase 1 is the 2nd
jacint@109
    74
      int n=G.nodeNum(); 
jacint@109
    75
      int heur0=(int)(H0*n);  //time while running 'bound decrease' 
jacint@109
    76
      int heur1=(int)(H1*n);  //time while running 'highest label'
jacint@109
    77
      int heur=heur1;         //starting time interval (#of relabels)
jacint@109
    78
      bool what_heur=1;       
jacint@109
    79
      /*
jacint@109
    80
	what_heur is 0 in case 'bound decrease' 
jacint@109
    81
	and 1 in case 'highest label'
jacint@109
    82
      */
jacint@109
    83
      bool end=false;     
jacint@109
    84
      /*
jacint@109
    85
	Needed for 'bound decrease', 'true'
jacint@109
    86
	means no active nodes are above bound b.
jacint@109
    87
      */
jacint@109
    88
      int relabel=0;
jacint@109
    89
      int k=n-2;  //bound on the highest level under n containing a node
jacint@109
    90
      int b=k;    //bound on the highest level under n of an active node
jacint@109
    91
      
jacint@109
    92
      typename Graph::NodeMap<int> level(G,n);      
jacint@109
    93
      typename Graph::NodeMap<T> excess(G); 
jacint@109
    94
jacint@109
    95
      std::vector<NodeIt> active(n);
jacint@109
    96
      typename Graph::NodeMap<NodeIt> next(G);
jacint@109
    97
      //Stack of the active nodes in level i < n.
jacint@109
    98
      //We use it in both phases.
jacint@109
    99
jacint@109
   100
      typename Graph::NodeMap<NodeIt> left(G);
jacint@109
   101
      typename Graph::NodeMap<NodeIt> right(G);
jacint@109
   102
      std::vector<NodeIt> level_list(n);
jacint@109
   103
      /*
jacint@109
   104
	List of the nodes in level i<n.
jacint@109
   105
      */
jacint@109
   106
jacint@109
   107
      /*Reverse_bfs from t, to find the starting level.*/
jacint@109
   108
      level.set(t,0);
jacint@109
   109
      std::queue<NodeIt> bfs_queue;
jacint@109
   110
      bfs_queue.push(t);
jacint@109
   111
jacint@109
   112
      while (!bfs_queue.empty()) {
jacint@109
   113
jacint@109
   114
	NodeIt v=bfs_queue.front();	
jacint@109
   115
	bfs_queue.pop();
jacint@109
   116
	int l=level.get(v)+1;
jacint@109
   117
jacint@109
   118
	for(InEdgeIt e=G.template first<InEdgeIt>(v); e.valid(); ++e) {
jacint@109
   119
	  NodeIt w=G.tail(e);
jacint@109
   120
	  if ( level.get(w) == n && w != s ) {
jacint@109
   121
	    bfs_queue.push(w);
jacint@109
   122
	    NodeIt first=level_list[l];
jacint@109
   123
	    if ( first != 0 ) left.set(first,w);
jacint@109
   124
	    right.set(w,first);
jacint@109
   125
	    level_list[l]=w;
jacint@109
   126
	    level.set(w, l);
jacint@109
   127
	  }
jacint@109
   128
	}
jacint@109
   129
      }
jacint@109
   130
      
jacint@109
   131
      level.set(s,n);
jacint@109
   132
      
jacint@109
   133
jacint@109
   134
      /* Starting flow. It is everywhere 0 at the moment. */     
jacint@109
   135
      for(OutEdgeIt e=G.template first<OutEdgeIt>(s); e.valid(); ++e) 
jacint@109
   136
	{
jacint@109
   137
	  T c=capacity.get(e);
jacint@109
   138
	  if ( c == 0 ) continue;
jacint@109
   139
	  NodeIt w=G.head(e);
jacint@109
   140
	  if ( level.get(w) < n ) {	  
jacint@109
   141
	    if ( excess.get(w) == 0 && w!=t ) {
jacint@109
   142
	      next.set(w,active[level.get(w)]);
jacint@109
   143
	      active[level.get(w)]=w;
jacint@109
   144
	    }
jacint@109
   145
	    flow.set(e, c); 
jacint@109
   146
	    excess.set(w, excess.get(w)+c);
jacint@109
   147
	  }
jacint@109
   148
	}
jacint@109
   149
jacint@109
   150
      /* 
jacint@109
   151
	 End of preprocessing 
jacint@109
   152
      */
jacint@109
   153
jacint@109
   154
jacint@109
   155
jacint@109
   156
      /*
jacint@109
   157
	Push/relabel on the highest level active nodes.
jacint@109
   158
      */	
jacint@109
   159
      while ( true ) {
jacint@109
   160
	
jacint@109
   161
	if ( b == 0 ) {
jacint@109
   162
	  if ( phase ) break;
jacint@109
   163
	  
jacint@109
   164
	  if ( !what_heur && !end && k > 0 ) {
jacint@109
   165
	    b=k;
jacint@109
   166
	    end=true;
jacint@109
   167
	  } else {
jacint@109
   168
	    phase=1;
jacint@109
   169
jacint@109
   170
	    level.set(s,0);
jacint@109
   171
	    std::queue<NodeIt> bfs_queue;
jacint@109
   172
	    bfs_queue.push(s);
jacint@109
   173
	    
jacint@109
   174
	    while (!bfs_queue.empty()) {
jacint@109
   175
	      
jacint@109
   176
	      NodeIt v=bfs_queue.front();	
jacint@109
   177
	      bfs_queue.pop();
jacint@109
   178
	      int l=level.get(v)+1;
jacint@109
   179
	      
jacint@109
   180
	      for(InEdgeIt e=G.template first<InEdgeIt>(v); e.valid(); ++e) {
jacint@109
   181
		if ( capacity.get(e) == flow.get(e) ) continue;
jacint@109
   182
		NodeIt u=G.tail(e);
jacint@109
   183
		if ( level.get(u) >= n ) { 
jacint@109
   184
		  bfs_queue.push(u);
jacint@109
   185
		  level.set(u, l);
jacint@109
   186
		  if ( excess.get(u) > 0 ) {
jacint@109
   187
		    next.set(u,active[l]);
jacint@109
   188
		    active[l]=u;
jacint@109
   189
		  }
jacint@109
   190
		}
jacint@109
   191
	      }
jacint@109
   192
	    
jacint@109
   193
	      for(OutEdgeIt e=G.template first<OutEdgeIt>(v); e.valid(); ++e) {
jacint@109
   194
		if ( 0 == flow.get(e) ) continue;
jacint@109
   195
		NodeIt u=G.head(e);
jacint@109
   196
		if ( level.get(u) >= n ) { 
jacint@109
   197
		  bfs_queue.push(u);
jacint@109
   198
		  level.set(u, l);
jacint@109
   199
		  if ( excess.get(u) > 0 ) {
jacint@109
   200
		    next.set(u,active[l]);
jacint@109
   201
		    active[l]=u;
jacint@109
   202
		  }
jacint@109
   203
		}
jacint@109
   204
	      }
jacint@109
   205
	    }
jacint@109
   206
	    b=n-2;
jacint@109
   207
	    }
jacint@109
   208
	    
jacint@109
   209
	}
jacint@109
   210
	  
jacint@109
   211
	  
jacint@109
   212
	if ( active[b] == 0 ) --b; 
jacint@109
   213
	else {
jacint@109
   214
	  end=false;  
jacint@109
   215
jacint@109
   216
	  NodeIt w=active[b];
jacint@109
   217
	  active[b]=next.get(w);
jacint@109
   218
	  int lev=level.get(w);
jacint@109
   219
	  T exc=excess.get(w);
jacint@109
   220
	  int newlevel=n;       //bound on the next level of w
jacint@109
   221
	  
jacint@109
   222
	  for(OutEdgeIt e=G.template first<OutEdgeIt>(w); e.valid(); ++e) {
jacint@109
   223
	    
jacint@109
   224
	    if ( flow.get(e) == capacity.get(e) ) continue; 
jacint@109
   225
	    NodeIt v=G.head(e);            
jacint@109
   226
	    //e=wv	    
jacint@109
   227
	    
jacint@109
   228
	    if( lev > level.get(v) ) {      
jacint@109
   229
	      /*Push is allowed now*/
jacint@109
   230
	      
jacint@109
   231
	      if ( excess.get(v)==0 && v!=t && v!=s ) {
jacint@109
   232
		int lev_v=level.get(v);
jacint@109
   233
		next.set(v,active[lev_v]);
jacint@109
   234
		active[lev_v]=v;
jacint@109
   235
	      }
jacint@109
   236
	      
jacint@109
   237
	      T cap=capacity.get(e);
jacint@109
   238
	      T flo=flow.get(e);
jacint@109
   239
	      T remcap=cap-flo;
jacint@109
   240
	      
jacint@109
   241
	      if ( remcap >= exc ) {       
jacint@109
   242
		/*A nonsaturating push.*/
jacint@109
   243
		
jacint@109
   244
		flow.set(e, flo+exc);
jacint@109
   245
		excess.set(v, excess.get(v)+exc);
jacint@109
   246
		exc=0;
jacint@109
   247
		break; 
jacint@109
   248
		
jacint@109
   249
	      } else { 
jacint@109
   250
		/*A saturating push.*/
jacint@109
   251
		
jacint@109
   252
		flow.set(e, cap);
jacint@109
   253
		excess.set(v, excess.get(v)+remcap);
jacint@109
   254
		exc-=remcap;
jacint@109
   255
	      }
jacint@109
   256
	    } else if ( newlevel > level.get(v) ){
jacint@109
   257
	      newlevel = level.get(v);
jacint@109
   258
	    }	    
jacint@109
   259
	    
jacint@109
   260
	  } //for out edges wv 
jacint@109
   261
	
jacint@109
   262
	
jacint@109
   263
	if ( exc > 0 ) {	
jacint@109
   264
	  for( InEdgeIt e=G.template first<InEdgeIt>(w); e.valid(); ++e) {
jacint@109
   265
	    
jacint@109
   266
	    if( flow.get(e) == 0 ) continue; 
jacint@109
   267
	    NodeIt v=G.tail(e);  
jacint@109
   268
	    //e=vw
jacint@109
   269
	    
jacint@109
   270
	    if( lev > level.get(v) ) {  
jacint@109
   271
	      /*Push is allowed now*/
jacint@109
   272
	      
jacint@109
   273
	      if ( excess.get(v)==0 && v!=t && v!=s ) {
jacint@109
   274
		int lev_v=level.get(v);
jacint@109
   275
		next.set(v,active[lev_v]);
jacint@109
   276
		active[lev_v]=v;
jacint@109
   277
	      }
jacint@109
   278
	      
jacint@109
   279
	      T flo=flow.get(e);
jacint@109
   280
	      
jacint@109
   281
	      if ( flo >= exc ) { 
jacint@109
   282
		/*A nonsaturating push.*/
jacint@109
   283
		
jacint@109
   284
		flow.set(e, flo-exc);
jacint@109
   285
		excess.set(v, excess.get(v)+exc);
jacint@109
   286
		exc=0;
jacint@109
   287
		break; 
jacint@109
   288
	      } else {                                               
jacint@109
   289
		/*A saturating push.*/
jacint@109
   290
		
jacint@109
   291
		excess.set(v, excess.get(v)+flo);
jacint@109
   292
		exc-=flo;
jacint@109
   293
		flow.set(e,0);
jacint@109
   294
	      }  
jacint@109
   295
	    } else if ( newlevel > level.get(v) ) {
jacint@109
   296
	      newlevel = level.get(v);
jacint@109
   297
	    }	    
jacint@109
   298
	  } //for in edges vw
jacint@109
   299
	  
jacint@109
   300
	} // if w still has excess after the out edge for cycle
jacint@109
   301
	
jacint@109
   302
	excess.set(w, exc);
jacint@109
   303
	 
jacint@109
   304
	/*
jacint@109
   305
	  Relabel
jacint@109
   306
	*/
jacint@109
   307
	
jacint@109
   308
jacint@109
   309
	if ( exc > 0 ) {
jacint@109
   310
	  //now 'lev' is the old level of w
jacint@109
   311
	
jacint@109
   312
	  if ( phase ) {
jacint@109
   313
	    level.set(w,++newlevel);
jacint@109
   314
	    next.set(w,active[newlevel]);
jacint@109
   315
	    active[newlevel]=w;
jacint@109
   316
	    b=newlevel;
jacint@109
   317
	  } else {
jacint@109
   318
	    //unlacing starts
jacint@109
   319
	    NodeIt right_n=right.get(w);
jacint@109
   320
	    NodeIt left_n=left.get(w);
jacint@109
   321
jacint@109
   322
	    if ( right_n != 0 ) {
jacint@109
   323
	      if ( left_n != 0 ) {
jacint@109
   324
		right.set(left_n, right_n);
jacint@109
   325
		left.set(right_n, left_n);
jacint@109
   326
	      } else {
jacint@109
   327
		level_list[lev]=right_n;   
jacint@109
   328
		left.set(right_n, 0);
jacint@109
   329
	      } 
jacint@109
   330
	    } else {
jacint@109
   331
	      if ( left_n != 0 ) {
jacint@109
   332
		right.set(left_n, 0);
jacint@109
   333
	      } else { 
jacint@109
   334
		level_list[lev]=0;   
jacint@109
   335
jacint@109
   336
	      } 
jacint@109
   337
	    } 
jacint@109
   338
	    //unlacing ends
jacint@109
   339
		
jacint@109
   340
	    //gapping starts
jacint@109
   341
	    if ( level_list[lev]==0 ) {
jacint@109
   342
	      
jacint@109
   343
	      for (int i=lev; i!=k ; ) {
jacint@109
   344
		NodeIt v=level_list[++i];
jacint@109
   345
		while ( v != 0 ) {
jacint@109
   346
		  level.set(v,n);
jacint@109
   347
		  v=right.get(v);
jacint@109
   348
		}
jacint@109
   349
		level_list[i]=0;
jacint@109
   350
		if ( !what_heur ) active[i]=0;
jacint@109
   351
	      }	     
jacint@109
   352
jacint@109
   353
	      level.set(w,n);
jacint@109
   354
	      b=lev-1;
jacint@109
   355
	      k=b;
jacint@109
   356
	      //gapping ends
jacint@109
   357
	    } else {
jacint@109
   358
	      
jacint@109
   359
	      if ( newlevel == n ) level.set(w,n); 
jacint@109
   360
	      else {
jacint@109
   361
		level.set(w,++newlevel);
jacint@109
   362
		next.set(w,active[newlevel]);
jacint@109
   363
		active[newlevel]=w;
jacint@109
   364
		if ( what_heur ) b=newlevel;
jacint@109
   365
		if ( k < newlevel ) ++k;
jacint@109
   366
		NodeIt first=level_list[newlevel];
jacint@109
   367
		if ( first != 0 ) left.set(first,w);
jacint@109
   368
		right.set(w,first);
jacint@109
   369
		left.set(w,0);
jacint@109
   370
		level_list[newlevel]=w;
jacint@109
   371
	      }
jacint@109
   372
	    }
jacint@109
   373
jacint@109
   374
jacint@109
   375
	    ++relabel; 
jacint@109
   376
	    if ( relabel >= heur ) {
jacint@109
   377
	      relabel=0;
jacint@109
   378
	      if ( what_heur ) {
jacint@109
   379
		what_heur=0;
jacint@109
   380
		heur=heur0;
jacint@109
   381
		end=false;
jacint@109
   382
	      } else {
jacint@109
   383
		what_heur=1;
jacint@109
   384
		heur=heur1;
jacint@109
   385
		b=k; 
jacint@109
   386
	      }
jacint@109
   387
	    }
jacint@109
   388
	  } //phase 0
jacint@109
   389
	  
jacint@109
   390
	  
jacint@109
   391
	} // if ( exc > 0 )
jacint@109
   392
	  
jacint@109
   393
	
jacint@109
   394
	}  // if stack[b] is nonempty
jacint@109
   395
	
jacint@109
   396
      } // while(true)
jacint@109
   397
jacint@109
   398
jacint@109
   399
      value = excess.get(t);
jacint@109
   400
      /*Max flow value.*/
jacint@109
   401
     
jacint@109
   402
    } //void run()
jacint@109
   403
jacint@109
   404
jacint@109
   405
jacint@109
   406
jacint@109
   407
jacint@109
   408
    /*
jacint@109
   409
      Returns the maximum value of a flow.
jacint@109
   410
     */
jacint@109
   411
jacint@109
   412
    T maxFlow() {
jacint@109
   413
      return value;
jacint@109
   414
    }
jacint@109
   415
jacint@109
   416
jacint@109
   417
jacint@109
   418
    /*
jacint@109
   419
      For the maximum flow x found by the algorithm, 
jacint@109
   420
      it returns the flow value on edge e, i.e. x(e). 
jacint@109
   421
    */
jacint@109
   422
   
jacint@109
   423
    T flowOnEdge(EdgeIt e) {
jacint@109
   424
      return flow.get(e);
jacint@109
   425
    }
jacint@109
   426
jacint@109
   427
jacint@109
   428
jacint@109
   429
    FlowMap Flow() {
jacint@109
   430
      return flow;
jacint@109
   431
      }
jacint@109
   432
jacint@109
   433
jacint@109
   434
    
jacint@109
   435
    void Flow(FlowMap& _flow ) {
jacint@109
   436
      for(EachNodeIt v=G.template first<EachNodeIt>() ; v.valid(); ++v)
jacint@109
   437
	_flow.set(v,flow.get(v));
jacint@109
   438
	}
jacint@109
   439
jacint@109
   440
jacint@109
   441
jacint@109
   442
    /*
jacint@109
   443
      Returns the minimum min cut, by a bfs from s in the residual graph.
jacint@109
   444
    */
jacint@109
   445
   
jacint@109
   446
    template<typename _CutMap>
jacint@109
   447
    void minMinCut(_CutMap& M) {
jacint@109
   448
    
jacint@109
   449
      std::queue<NodeIt> queue;
jacint@109
   450
      
jacint@109
   451
      M.set(s,true);      
jacint@109
   452
      queue.push(s);
jacint@109
   453
jacint@109
   454
      while (!queue.empty()) {
jacint@109
   455
        NodeIt w=queue.front();
jacint@109
   456
	queue.pop();
jacint@109
   457
jacint@109
   458
	for(OutEdgeIt e=G.template first<OutEdgeIt>(w) ; e.valid(); ++e) {
jacint@109
   459
	  NodeIt v=G.head(e);
jacint@109
   460
	  if (!M.get(v) && flow.get(e) < capacity.get(e) ) {
jacint@109
   461
	    queue.push(v);
jacint@109
   462
	    M.set(v, true);
jacint@109
   463
	  }
jacint@109
   464
	} 
jacint@109
   465
jacint@109
   466
	for(InEdgeIt e=G.template first<InEdgeIt>(w) ; e.valid(); ++e) {
jacint@109
   467
	  NodeIt v=G.tail(e);
jacint@109
   468
	  if (!M.get(v) && flow.get(e) > 0 ) {
jacint@109
   469
	    queue.push(v);
jacint@109
   470
	    M.set(v, true);
jacint@109
   471
	  }
jacint@109
   472
	} 
jacint@109
   473
      }
jacint@109
   474
    }
jacint@109
   475
jacint@109
   476
jacint@109
   477
  
jacint@109
   478
    /*
jacint@109
   479
      Returns the maximum min cut, by a reverse bfs 
jacint@109
   480
      from t in the residual graph.
jacint@109
   481
    */
jacint@109
   482
    
jacint@109
   483
    template<typename _CutMap>
jacint@109
   484
    void maxMinCut(_CutMap& M) {
jacint@109
   485
    
jacint@109
   486
      std::queue<NodeIt> queue;
jacint@109
   487
      
jacint@109
   488
      M.set(t,true);        
jacint@109
   489
      queue.push(t);
jacint@109
   490
jacint@109
   491
      while (!queue.empty()) {
jacint@109
   492
        NodeIt w=queue.front();
jacint@109
   493
	queue.pop();
jacint@109
   494
jacint@109
   495
	for(InEdgeIt e=G.template first<InEdgeIt>(w) ; e.valid(); ++e) {
jacint@109
   496
	  NodeIt v=G.tail(e);
jacint@109
   497
	  if (!M.get(v) && flow.get(e) < capacity.get(e) ) {
jacint@109
   498
	    queue.push(v);
jacint@109
   499
	    M.set(v, true);
jacint@109
   500
	  }
jacint@109
   501
	}
jacint@109
   502
jacint@109
   503
	for(OutEdgeIt e=G.template first<OutEdgeIt>(w) ; e.valid(); ++e) {
jacint@109
   504
	  NodeIt v=G.head(e);
jacint@109
   505
	  if (!M.get(v) && flow.get(e) > 0 ) {
jacint@109
   506
	    queue.push(v);
jacint@109
   507
	    M.set(v, true);
jacint@109
   508
	  }
jacint@109
   509
	}
jacint@109
   510
      }
jacint@109
   511
jacint@109
   512
      for(EachNodeIt v=G.template first<EachNodeIt>() ; v.valid(); ++v) {
jacint@109
   513
	M.set(v, !M.get(v));
jacint@109
   514
      }
jacint@109
   515
jacint@109
   516
    }
jacint@109
   517
jacint@109
   518
jacint@109
   519
jacint@109
   520
    template<typename CutMap>
jacint@109
   521
    void minCut(CutMap& M) {
jacint@109
   522
      minMinCut(M);
jacint@109
   523
    }
jacint@109
   524
jacint@109
   525
jacint@109
   526
  };
jacint@109
   527
}//namespace marci
jacint@109
   528
#endif 
jacint@109
   529
jacint@109
   530
jacint@109
   531
jacint@109
   532