0
9
0
17
17
55
55
73
73
14
14
89
89
50
50
31
31
10
10
... | ... |
@@ -453,13 +453,13 @@ |
453 | 453 |
createStructures(); |
454 | 454 |
|
455 | 455 |
for(NodeIt n(_g);n!=INVALID;++n) { |
456 |
_excess |
|
456 |
(*_excess)[n] = (*_delta)[n]; |
|
457 | 457 |
} |
458 | 458 |
|
459 | 459 |
for (ArcIt e(_g);e!=INVALID;++e) { |
460 | 460 |
_flow->set(e, (*_lo)[e]); |
461 |
_excess->set(_g.target(e), (*_excess)[_g.target(e)] + (*_flow)[e]); |
|
462 |
_excess->set(_g.source(e), (*_excess)[_g.source(e)] - (*_flow)[e]); |
|
461 |
(*_excess)[_g.target(e)] += (*_flow)[e]; |
|
462 |
(*_excess)[_g.source(e)] -= (*_flow)[e]; |
|
463 | 463 |
} |
464 | 464 |
|
465 | 465 |
// global relabeling tested, but in general case it provides |
... | ... |
@@ -482,23 +482,23 @@ |
482 | 482 |
createStructures(); |
483 | 483 |
|
484 | 484 |
for(NodeIt n(_g);n!=INVALID;++n) { |
485 |
_excess |
|
485 |
(*_excess)[n] = (*_delta)[n]; |
|
486 | 486 |
} |
487 | 487 |
|
488 | 488 |
for (ArcIt e(_g);e!=INVALID;++e) { |
489 | 489 |
if (!_tol.positive((*_excess)[_g.target(e)] + (*_up)[e])) { |
490 | 490 |
_flow->set(e, (*_up)[e]); |
491 |
_excess->set(_g.target(e), (*_excess)[_g.target(e)] + (*_up)[e]); |
|
492 |
_excess->set(_g.source(e), (*_excess)[_g.source(e)] - (*_up)[e]); |
|
491 |
(*_excess)[_g.target(e)] += (*_up)[e]; |
|
492 |
(*_excess)[_g.source(e)] -= (*_up)[e]; |
|
493 | 493 |
} else if (_tol.positive((*_excess)[_g.target(e)] + (*_lo)[e])) { |
494 | 494 |
_flow->set(e, (*_lo)[e]); |
495 |
_excess->set(_g.target(e), (*_excess)[_g.target(e)] + (*_lo)[e]); |
|
496 |
_excess->set(_g.source(e), (*_excess)[_g.source(e)] - (*_lo)[e]); |
|
495 |
(*_excess)[_g.target(e)] += (*_lo)[e]; |
|
496 |
(*_excess)[_g.source(e)] -= (*_lo)[e]; |
|
497 | 497 |
} else { |
498 | 498 |
Value fc = -(*_excess)[_g.target(e)]; |
499 | 499 |
_flow->set(e, fc); |
500 |
_excess->set(_g.target(e), 0); |
|
501 |
_excess->set(_g.source(e), (*_excess)[_g.source(e)] - fc); |
|
500 |
(*_excess)[_g.target(e)] = 0; |
|
501 |
(*_excess)[_g.source(e)] -= fc; |
|
502 | 502 |
} |
503 | 503 |
} |
504 | 504 |
|
... | ... |
@@ -537,16 +537,16 @@ |
537 | 537 |
if((*_level)[v]<actlevel) { |
538 | 538 |
if(!_tol.less(fc, exc)) { |
539 | 539 |
_flow->set(e, (*_flow)[e] + exc); |
540 |
|
|
540 |
(*_excess)[v] += exc; |
|
541 | 541 |
if(!_level->active(v) && _tol.positive((*_excess)[v])) |
542 | 542 |
_level->activate(v); |
543 |
|
|
543 |
(*_excess)[act] = 0; |
|
544 | 544 |
_level->deactivate(act); |
545 | 545 |
goto next_l; |
546 | 546 |
} |
547 | 547 |
else { |
548 | 548 |
_flow->set(e, (*_up)[e]); |
549 |
|
|
549 |
(*_excess)[v] += fc; |
|
550 | 550 |
if(!_level->active(v) && _tol.positive((*_excess)[v])) |
551 | 551 |
_level->activate(v); |
552 | 552 |
exc-=fc; |
... | ... |
@@ -561,16 +561,16 @@ |
561 | 561 |
if((*_level)[v]<actlevel) { |
562 | 562 |
if(!_tol.less(fc, exc)) { |
563 | 563 |
_flow->set(e, (*_flow)[e] - exc); |
564 |
|
|
564 |
(*_excess)[v] += exc; |
|
565 | 565 |
if(!_level->active(v) && _tol.positive((*_excess)[v])) |
566 | 566 |
_level->activate(v); |
567 |
|
|
567 |
(*_excess)[act] = 0; |
|
568 | 568 |
_level->deactivate(act); |
569 | 569 |
goto next_l; |
570 | 570 |
} |
571 | 571 |
else { |
572 | 572 |
_flow->set(e, (*_lo)[e]); |
573 |
|
|
573 |
(*_excess)[v] += fc; |
|
574 | 574 |
if(!_level->active(v) && _tol.positive((*_excess)[v])) |
575 | 575 |
_level->activate(v); |
576 | 576 |
exc-=fc; |
... | ... |
@@ -579,7 +579,7 @@ |
579 | 579 |
else if((*_level)[v]<mlevel) mlevel=(*_level)[v]; |
580 | 580 |
} |
581 | 581 |
|
582 |
_excess |
|
582 |
(*_excess)[act] = exc; |
|
583 | 583 |
if(!_tol.positive(exc)) _level->deactivate(act); |
584 | 584 |
else if(mlevel==_node_num) { |
585 | 585 |
_level->liftHighestActiveToTop(); |
... | ... |
@@ -1315,27 +1315,27 @@ |
1315 | 1315 |
|
1316 | 1316 |
virtual void clear() { |
1317 | 1317 |
for(NodeIt n(_g);n!=INVALID;++n) { |
1318 |
_head |
|
1318 |
_head[n] = INVALID; |
|
1319 | 1319 |
} |
1320 | 1320 |
} |
1321 | 1321 |
|
1322 | 1322 |
void insert(Arc arc) { |
1323 | 1323 |
Node s = _g.source(arc); |
1324 | 1324 |
Node t = _g.target(arc); |
1325 |
_left.set(arc, INVALID); |
|
1326 |
_right.set(arc, INVALID); |
|
1325 |
_left[arc] = INVALID; |
|
1326 |
_right[arc] = INVALID; |
|
1327 | 1327 |
|
1328 | 1328 |
Arc e = _head[s]; |
1329 | 1329 |
if (e == INVALID) { |
1330 |
_head.set(s, arc); |
|
1331 |
_parent.set(arc, INVALID); |
|
1330 |
_head[s] = arc; |
|
1331 |
_parent[arc] = INVALID; |
|
1332 | 1332 |
return; |
1333 | 1333 |
} |
1334 | 1334 |
while (true) { |
1335 | 1335 |
if (t < _g.target(e)) { |
1336 | 1336 |
if (_left[e] == INVALID) { |
1337 |
_left.set(e, arc); |
|
1338 |
_parent.set(arc, e); |
|
1337 |
_left[e] = arc; |
|
1338 |
_parent[arc] = e; |
|
1339 | 1339 |
splay(arc); |
1340 | 1340 |
return; |
1341 | 1341 |
} else { |
... | ... |
@@ -1343,8 +1343,8 @@ |
1343 | 1343 |
} |
1344 | 1344 |
} else { |
1345 | 1345 |
if (_right[e] == INVALID) { |
1346 |
_right.set(e, arc); |
|
1347 |
_parent.set(arc, e); |
|
1346 |
_right[e] = arc; |
|
1347 |
_parent[arc] = e; |
|
1348 | 1348 |
splay(arc); |
1349 | 1349 |
return; |
1350 | 1350 |
} else { |
... | ... |
@@ -1357,27 +1357,27 @@ |
1357 | 1357 |
void remove(Arc arc) { |
1358 | 1358 |
if (_left[arc] == INVALID) { |
1359 | 1359 |
if (_right[arc] != INVALID) { |
1360 |
_parent |
|
1360 |
_parent[_right[arc]] = _parent[arc]; |
|
1361 | 1361 |
} |
1362 | 1362 |
if (_parent[arc] != INVALID) { |
1363 | 1363 |
if (_left[_parent[arc]] == arc) { |
1364 |
_left |
|
1364 |
_left[_parent[arc]] = _right[arc]; |
|
1365 | 1365 |
} else { |
1366 |
_right |
|
1366 |
_right[_parent[arc]] = _right[arc]; |
|
1367 | 1367 |
} |
1368 | 1368 |
} else { |
1369 |
_head |
|
1369 |
_head[_g.source(arc)] = _right[arc]; |
|
1370 | 1370 |
} |
1371 | 1371 |
} else if (_right[arc] == INVALID) { |
1372 |
_parent |
|
1372 |
_parent[_left[arc]] = _parent[arc]; |
|
1373 | 1373 |
if (_parent[arc] != INVALID) { |
1374 | 1374 |
if (_left[_parent[arc]] == arc) { |
1375 |
_left |
|
1375 |
_left[_parent[arc]] = _left[arc]; |
|
1376 | 1376 |
} else { |
1377 |
_right |
|
1377 |
_right[_parent[arc]] = _left[arc]; |
|
1378 | 1378 |
} |
1379 | 1379 |
} else { |
1380 |
_head |
|
1380 |
_head[_g.source(arc)] = _left[arc]; |
|
1381 | 1381 |
} |
1382 | 1382 |
} else { |
1383 | 1383 |
Arc e = _left[arc]; |
... | ... |
@@ -1387,38 +1387,38 @@ |
1387 | 1387 |
e = _right[e]; |
1388 | 1388 |
} |
1389 | 1389 |
Arc s = _parent[e]; |
1390 |
_right |
|
1390 |
_right[_parent[e]] = _left[e]; |
|
1391 | 1391 |
if (_left[e] != INVALID) { |
1392 |
_parent |
|
1392 |
_parent[_left[e]] = _parent[e]; |
|
1393 | 1393 |
} |
1394 | 1394 |
|
1395 |
_left.set(e, _left[arc]); |
|
1396 |
_parent.set(_left[arc], e); |
|
1397 |
_right.set(e, _right[arc]); |
|
1398 |
_parent.set(_right[arc], e); |
|
1395 |
_left[e] = _left[arc]; |
|
1396 |
_parent[_left[arc]] = e; |
|
1397 |
_right[e] = _right[arc]; |
|
1398 |
_parent[_right[arc]] = e; |
|
1399 | 1399 |
|
1400 |
_parent |
|
1400 |
_parent[e] = _parent[arc]; |
|
1401 | 1401 |
if (_parent[arc] != INVALID) { |
1402 | 1402 |
if (_left[_parent[arc]] == arc) { |
1403 |
_left |
|
1403 |
_left[_parent[arc]] = e; |
|
1404 | 1404 |
} else { |
1405 |
_right |
|
1405 |
_right[_parent[arc]] = e; |
|
1406 | 1406 |
} |
1407 | 1407 |
} |
1408 | 1408 |
splay(s); |
1409 | 1409 |
} else { |
1410 |
_right.set(e, _right[arc]); |
|
1411 |
_parent.set(_right[arc], e); |
|
1412 |
|
|
1410 |
_right[e] = _right[arc]; |
|
1411 |
_parent[_right[arc]] = e; |
|
1412 |
_parent[e] = _parent[arc]; |
|
1413 | 1413 |
|
1414 | 1414 |
if (_parent[arc] != INVALID) { |
1415 | 1415 |
if (_left[_parent[arc]] == arc) { |
1416 |
_left |
|
1416 |
_left[_parent[arc]] = e; |
|
1417 | 1417 |
} else { |
1418 |
_right |
|
1418 |
_right[_parent[arc]] = e; |
|
1419 | 1419 |
} |
1420 | 1420 |
} else { |
1421 |
_head |
|
1421 |
_head[_g.source(arc)] = e; |
|
1422 | 1422 |
} |
1423 | 1423 |
} |
1424 | 1424 |
} |
... | ... |
@@ -1430,17 +1430,17 @@ |
1430 | 1430 |
Arc me=v[m]; |
1431 | 1431 |
if (a < m) { |
1432 | 1432 |
Arc left = refreshRec(v,a,m-1); |
1433 |
_left.set(me, left); |
|
1434 |
_parent.set(left, me); |
|
1433 |
_left[me] = left; |
|
1434 |
_parent[left] = me; |
|
1435 | 1435 |
} else { |
1436 |
_left |
|
1436 |
_left[me] = INVALID; |
|
1437 | 1437 |
} |
1438 | 1438 |
if (m < b) { |
1439 | 1439 |
Arc right = refreshRec(v,m+1,b); |
1440 |
_right.set(me, right); |
|
1441 |
_parent.set(right, me); |
|
1440 |
_right[me] = right; |
|
1441 |
_parent[right] = me; |
|
1442 | 1442 |
} else { |
1443 |
_right |
|
1443 |
_right[me] = INVALID; |
|
1444 | 1444 |
} |
1445 | 1445 |
return me; |
1446 | 1446 |
} |
... | ... |
@@ -1452,46 +1452,46 @@ |
1452 | 1452 |
if (!v.empty()) { |
1453 | 1453 |
std::sort(v.begin(),v.end(),ArcLess(_g)); |
1454 | 1454 |
Arc head = refreshRec(v,0,v.size()-1); |
1455 |
_head.set(n, head); |
|
1456 |
_parent.set(head, INVALID); |
|
1455 |
_head[n] = head; |
|
1456 |
_parent[head] = INVALID; |
|
1457 | 1457 |
} |
1458 |
else _head |
|
1458 |
else _head[n] = INVALID; |
|
1459 | 1459 |
} |
1460 | 1460 |
} |
1461 | 1461 |
|
1462 | 1462 |
void zig(Arc v) { |
1463 | 1463 |
Arc w = _parent[v]; |
1464 |
_parent.set(v, _parent[w]); |
|
1465 |
_parent.set(w, v); |
|
1466 |
_left.set(w, _right[v]); |
|
1467 |
_right.set(v, w); |
|
1464 |
_parent[v] = _parent[w]; |
|
1465 |
_parent[w] = v; |
|
1466 |
_left[w] = _right[v]; |
|
1467 |
_right[v] = w; |
|
1468 | 1468 |
if (_parent[v] != INVALID) { |
1469 | 1469 |
if (_right[_parent[v]] == w) { |
1470 |
_right |
|
1470 |
_right[_parent[v]] = v; |
|
1471 | 1471 |
} else { |
1472 |
_left |
|
1472 |
_left[_parent[v]] = v; |
|
1473 | 1473 |
} |
1474 | 1474 |
} |
1475 | 1475 |
if (_left[w] != INVALID){ |
1476 |
_parent |
|
1476 |
_parent[_left[w]] = w; |
|
1477 | 1477 |
} |
1478 | 1478 |
} |
1479 | 1479 |
|
1480 | 1480 |
void zag(Arc v) { |
1481 | 1481 |
Arc w = _parent[v]; |
1482 |
_parent.set(v, _parent[w]); |
|
1483 |
_parent.set(w, v); |
|
1484 |
_right.set(w, _left[v]); |
|
1485 |
_left.set(v, w); |
|
1482 |
_parent[v] = _parent[w]; |
|
1483 |
_parent[w] = v; |
|
1484 |
_right[w] = _left[v]; |
|
1485 |
_left[v] = w; |
|
1486 | 1486 |
if (_parent[v] != INVALID){ |
1487 | 1487 |
if (_left[_parent[v]] == w) { |
1488 |
_left |
|
1488 |
_left[_parent[v]] = v; |
|
1489 | 1489 |
} else { |
1490 |
_right |
|
1490 |
_right[_parent[v]] = v; |
|
1491 | 1491 |
} |
1492 | 1492 |
} |
1493 | 1493 |
if (_right[w] != INVALID){ |
1494 |
_parent |
|
1494 |
_parent[_right[w]] = w; |
|
1495 | 1495 |
} |
1496 | 1496 |
} |
1497 | 1497 |
... | ... |
@@ -76,7 +76,7 @@ |
76 | 76 |
|
77 | 77 |
void copy(Item i, Vit p) |
78 | 78 |
{ |
79 |
_where |
|
79 |
_where[*p=i] = p; |
|
80 | 80 |
} |
81 | 81 |
void copy(Vit s, Vit p) |
82 | 82 |
{ |
... | ... |
@@ -84,15 +84,15 @@ |
84 | 84 |
{ |
85 | 85 |
Item i=*s; |
86 | 86 |
*p=i; |
87 |
_where |
|
87 |
_where[i] = p; |
|
88 | 88 |
} |
89 | 89 |
} |
90 | 90 |
void swap(Vit i, Vit j) |
91 | 91 |
{ |
92 | 92 |
Item ti=*i; |
93 | 93 |
Vit ct = _where[ti]; |
94 |
_where.set(ti,_where[*i=*j]); |
|
95 |
_where.set(*j,ct); |
|
94 |
_where[ti] = _where[*i=*j]; |
|
95 |
_where[*j] = ct; |
|
96 | 96 |
*j=ti; |
97 | 97 |
} |
98 | 98 |
|
... | ... |
@@ -226,7 +226,7 @@ |
226 | 226 |
void liftHighestActive() |
227 | 227 |
{ |
228 | 228 |
Item it = *_last_active[_highest_active]; |
229 |
|
|
229 |
++_level[it]; |
|
230 | 230 |
swap(_last_active[_highest_active]--,_last_active[_highest_active+1]); |
231 | 231 |
--_first[++_highest_active]; |
232 | 232 |
} |
... | ... |
@@ -249,7 +249,7 @@ |
249 | 249 |
--_last_active[l]; |
250 | 250 |
} |
251 | 251 |
copy(li,_first[new_level]); |
252 |
_level |
|
252 |
_level[li] = new_level; |
|
253 | 253 |
_highest_active=new_level; |
254 | 254 |
} |
255 | 255 |
|
... | ... |
@@ -269,7 +269,7 @@ |
269 | 269 |
} |
270 | 270 |
copy(li,_first[_max_level]); |
271 | 271 |
--_last_active[_max_level]; |
272 |
_level |
|
272 |
_level[li] = _max_level; |
|
273 | 273 |
|
274 | 274 |
while(_highest_active>=0 && |
275 | 275 |
_last_active[_highest_active]<_first[_highest_active]) |
... | ... |
@@ -299,7 +299,7 @@ |
299 | 299 |
Item liftActiveOn(int level) |
300 | 300 |
{ |
301 | 301 |
Item it =*_last_active[level]; |
302 |
|
|
302 |
++_level[it]; |
|
303 | 303 |
swap(_last_active[level]--, --_first[level+1]); |
304 | 304 |
if (level+1>_highest_active) ++_highest_active; |
305 | 305 |
} |
... | ... |
@@ -319,7 +319,7 @@ |
319 | 319 |
copy(--_first[l+1], _last_active[l]--); |
320 | 320 |
} |
321 | 321 |
copy(ai,_first[new_level]); |
322 |
_level |
|
322 |
_level[ai] = new_level; |
|
323 | 323 |
if (new_level>_highest_active) _highest_active=new_level; |
324 | 324 |
} |
325 | 325 |
|
... | ... |
@@ -339,7 +339,7 @@ |
339 | 339 |
} |
340 | 340 |
copy(ai,_first[_max_level]); |
341 | 341 |
--_last_active[_max_level]; |
342 |
_level |
|
342 |
_level[ai] = _max_level; |
|
343 | 343 |
|
344 | 344 |
if (_highest_active==level) { |
345 | 345 |
while(_highest_active>=0 && |
... | ... |
@@ -370,7 +370,7 @@ |
370 | 370 |
copy(--_first[l+1],_last_active[l]--); |
371 | 371 |
} |
372 | 372 |
copy(i,_first[new_level]); |
373 |
_level |
|
373 |
_level[i] = new_level; |
|
374 | 374 |
if(new_level>_highest_active) _highest_active=new_level; |
375 | 375 |
} |
376 | 376 |
|
... | ... |
@@ -382,7 +382,7 @@ |
382 | 382 |
///only if you really know what it is for. |
383 | 383 |
///\pre The item is on the top level. |
384 | 384 |
void dirtyTopButOne(Item i) { |
385 |
_level |
|
385 |
_level[i] = _max_level - 1; |
|
386 | 386 |
} |
387 | 387 |
|
388 | 388 |
///Lift all items on and above the given level to the top level. |
... | ... |
@@ -394,7 +394,7 @@ |
394 | 394 |
const Vit f=_first[l]; |
395 | 395 |
const Vit tl=_first[_max_level]; |
396 | 396 |
for(Vit i=f;i!=tl;++i) |
397 |
_level |
|
397 |
_level[*i] = _max_level; |
|
398 | 398 |
for(int i=l;i<=_max_level;i++) |
399 | 399 |
{ |
400 | 400 |
_first[i]=f; |
... | ... |
@@ -433,8 +433,8 @@ |
433 | 433 |
for(typename ItemSetTraits<GR,Item>::ItemIt i(_g);i!=INVALID;++i) |
434 | 434 |
{ |
435 | 435 |
*n=i; |
436 |
_where.set(i,n); |
|
437 |
_level.set(i,_max_level); |
|
436 |
_where[i] = n; |
|
437 |
_level[i] = _max_level; |
|
438 | 438 |
++n; |
439 | 439 |
} |
440 | 440 |
} |
... | ... |
@@ -443,7 +443,7 @@ |
443 | 443 |
void initAddItem(Item i) |
444 | 444 |
{ |
445 | 445 |
swap(_where[i],_init_num); |
446 |
_level |
|
446 |
_level[i] = _init_lev; |
|
447 | 447 |
++_init_num; |
448 | 448 |
} |
449 | 449 |
|
... | ... |
@@ -551,7 +551,7 @@ |
551 | 551 |
///Activate item \c i. |
552 | 552 |
///\pre Item \c i shouldn't be active before. |
553 | 553 |
void activate(Item i) { |
554 |
_active |
|
554 |
_active[i] = true; |
|
555 | 555 |
|
556 | 556 |
int level = _level[i]; |
557 | 557 |
if (level > _highest_active) { |
... | ... |
@@ -560,16 +560,16 @@ |
560 | 560 |
|
561 | 561 |
if (_prev[i] == INVALID || _active[_prev[i]]) return; |
562 | 562 |
//unlace |
563 |
_next |
|
563 |
_next[_prev[i]] = _next[i]; |
|
564 | 564 |
if (_next[i] != INVALID) { |
565 |
_prev |
|
565 |
_prev[_next[i]] = _prev[i]; |
|
566 | 566 |
} else { |
567 | 567 |
_last[level] = _prev[i]; |
568 | 568 |
} |
569 | 569 |
//lace |
570 |
_next.set(i, _first[level]); |
|
571 |
_prev.set(_first[level], i); |
|
572 |
|
|
570 |
_next[i] = _first[level]; |
|
571 |
_prev[_first[level]] = i; |
|
572 |
_prev[i] = INVALID; |
|
573 | 573 |
_first[level] = i; |
574 | 574 |
|
575 | 575 |
} |
... | ... |
@@ -579,23 +579,23 @@ |
579 | 579 |
///Deactivate item \c i. |
580 | 580 |
///\pre Item \c i must be active before. |
581 | 581 |
void deactivate(Item i) { |
582 |
_active |
|
582 |
_active[i] = false; |
|
583 | 583 |
int level = _level[i]; |
584 | 584 |
|
585 | 585 |
if (_next[i] == INVALID || !_active[_next[i]]) |
586 | 586 |
goto find_highest_level; |
587 | 587 |
|
588 | 588 |
//unlace |
589 |
_prev |
|
589 |
_prev[_next[i]] = _prev[i]; |
|
590 | 590 |
if (_prev[i] != INVALID) { |
591 |
_next |
|
591 |
_next[_prev[i]] = _next[i]; |
|
592 | 592 |
} else { |
593 | 593 |
_first[_level[i]] = _next[i]; |
594 | 594 |
} |
595 | 595 |
//lace |
596 |
_prev.set(i, _last[level]); |
|
597 |
_next.set(_last[level], i); |
|
598 |
|
|
596 |
_prev[i] = _last[level]; |
|
597 |
_next[_last[level]] = i; |
|
598 |
_next[i] = INVALID; |
|
599 | 599 |
_last[level] = i; |
600 | 600 |
|
601 | 601 |
find_highest_level: |
... | ... |
@@ -685,21 +685,21 @@ |
685 | 685 |
void liftHighestActive() { |
686 | 686 |
Item i = _first[_highest_active]; |
687 | 687 |
if (_next[i] != INVALID) { |
688 |
_prev |
|
688 |
_prev[_next[i]] = INVALID; |
|
689 | 689 |
_first[_highest_active] = _next[i]; |
690 | 690 |
} else { |
691 | 691 |
_first[_highest_active] = INVALID; |
692 | 692 |
_last[_highest_active] = INVALID; |
693 | 693 |
} |
694 |
_level |
|
694 |
_level[i] = ++_highest_active; |
|
695 | 695 |
if (_first[_highest_active] == INVALID) { |
696 | 696 |
_first[_highest_active] = i; |
697 | 697 |
_last[_highest_active] = i; |
698 |
_prev.set(i, INVALID); |
|
699 |
_next.set(i, INVALID); |
|
698 |
_prev[i] = INVALID; |
|
699 |
_next[i] = INVALID; |
|
700 | 700 |
} else { |
701 |
_prev.set(_first[_highest_active], i); |
|
702 |
_next.set(i, _first[_highest_active]); |
|
701 |
_prev[_first[_highest_active]] = i; |
|
702 |
_next[i] = _first[_highest_active]; |
|
703 | 703 |
_first[_highest_active] = i; |
704 | 704 |
} |
705 | 705 |
} |
... | ... |
@@ -714,20 +714,20 @@ |
714 | 714 |
void liftHighestActive(int new_level) { |
715 | 715 |
Item i = _first[_highest_active]; |
716 | 716 |
if (_next[i] != INVALID) { |
717 |
_prev |
|
717 |
_prev[_next[i]] = INVALID; |
|
718 | 718 |
_first[_highest_active] = _next[i]; |
719 | 719 |
} else { |
720 | 720 |
_first[_highest_active] = INVALID; |
721 | 721 |
_last[_highest_active] = INVALID; |
722 | 722 |
} |
723 |
_level |
|
723 |
_level[i] = _highest_active = new_level; |
|
724 | 724 |
if (_first[_highest_active] == INVALID) { |
725 | 725 |
_first[_highest_active] = _last[_highest_active] = i; |
726 |
_prev.set(i, INVALID); |
|
727 |
_next.set(i, INVALID); |
|
726 |
_prev[i] = INVALID; |
|
727 |
_next[i] = INVALID; |
|
728 | 728 |
} else { |
729 |
_prev.set(_first[_highest_active], i); |
|
730 |
_next.set(i, _first[_highest_active]); |
|
729 |
_prev[_first[_highest_active]] = i; |
|
730 |
_next[i] = _first[_highest_active]; |
|
731 | 731 |
_first[_highest_active] = i; |
732 | 732 |
} |
733 | 733 |
} |
... | ... |
@@ -738,9 +738,9 @@ |
738 | 738 |
///deactivate it. |
739 | 739 |
void liftHighestActiveToTop() { |
740 | 740 |
Item i = _first[_highest_active]; |
741 |
_level |
|
741 |
_level[i] = _max_level; |
|
742 | 742 |
if (_next[i] != INVALID) { |
743 |
_prev |
|
743 |
_prev[_next[i]] = INVALID; |
|
744 | 744 |
_first[_highest_active] = _next[i]; |
745 | 745 |
} else { |
746 | 746 |
_first[_highest_active] = INVALID; |
... | ... |
@@ -774,20 +774,20 @@ |
774 | 774 |
{ |
775 | 775 |
Item i = _first[l]; |
776 | 776 |
if (_next[i] != INVALID) { |
777 |
_prev |
|
777 |
_prev[_next[i]] = INVALID; |
|
778 | 778 |
_first[l] = _next[i]; |
779 | 779 |
} else { |
780 | 780 |
_first[l] = INVALID; |
781 | 781 |
_last[l] = INVALID; |
782 | 782 |
} |
783 |
_level |
|
783 |
_level[i] = ++l; |
|
784 | 784 |
if (_first[l] == INVALID) { |
785 | 785 |
_first[l] = _last[l] = i; |
786 |
_prev.set(i, INVALID); |
|
787 |
_next.set(i, INVALID); |
|
786 |
_prev[i] = INVALID; |
|
787 |
_next[i] = INVALID; |
|
788 | 788 |
} else { |
789 |
_prev.set(_first[l], i); |
|
790 |
_next.set(i, _first[l]); |
|
789 |
_prev[_first[l]] = i; |
|
790 |
_next[i] = _first[l]; |
|
791 | 791 |
_first[l] = i; |
792 | 792 |
} |
793 | 793 |
if (_highest_active < l) { |
... | ... |
@@ -803,20 +803,20 @@ |
803 | 803 |
{ |
804 | 804 |
Item i = _first[l]; |
805 | 805 |
if (_next[i] != INVALID) { |
806 |
_prev |
|
806 |
_prev[_next[i]] = INVALID; |
|
807 | 807 |
_first[l] = _next[i]; |
808 | 808 |
} else { |
809 | 809 |
_first[l] = INVALID; |
810 | 810 |
_last[l] = INVALID; |
811 | 811 |
} |
812 |
_level |
|
812 |
_level[i] = l = new_level; |
|
813 | 813 |
if (_first[l] == INVALID) { |
814 | 814 |
_first[l] = _last[l] = i; |
815 |
_prev.set(i, INVALID); |
|
816 |
_next.set(i, INVALID); |
|
815 |
_prev[i] = INVALID; |
|
816 |
_next[i] = INVALID; |
|
817 | 817 |
} else { |
818 |
_prev.set(_first[l], i); |
|
819 |
_next.set(i, _first[l]); |
|
818 |
_prev[_first[l]] = i; |
|
819 |
_next[i] = _first[l]; |
|
820 | 820 |
_first[l] = i; |
821 | 821 |
} |
822 | 822 |
if (_highest_active < l) { |
... | ... |
@@ -832,13 +832,13 @@ |
832 | 832 |
{ |
833 | 833 |
Item i = _first[l]; |
834 | 834 |
if (_next[i] != INVALID) { |
835 |
_prev |
|
835 |
_prev[_next[i]] = INVALID; |
|
836 | 836 |
_first[l] = _next[i]; |
837 | 837 |
} else { |
838 | 838 |
_first[l] = INVALID; |
839 | 839 |
_last[l] = INVALID; |
840 | 840 |
} |
841 |
_level |
|
841 |
_level[i] = _max_level; |
|
842 | 842 |
if (l == _highest_active) { |
843 | 843 |
while (_highest_active >= 0 && activeFree(_highest_active)) |
844 | 844 |
--_highest_active; |
... | ... |
@@ -856,23 +856,23 @@ |
856 | 856 |
/// |
857 | 857 |
void lift(Item i, int new_level) { |
858 | 858 |
if (_next[i] != INVALID) { |
859 |
_prev |
|
859 |
_prev[_next[i]] = _prev[i]; |
|
860 | 860 |
} else { |
861 | 861 |
_last[new_level] = _prev[i]; |
862 | 862 |
} |
863 | 863 |
if (_prev[i] != INVALID) { |
864 |
_next |
|
864 |
_next[_prev[i]] = _next[i]; |
|
865 | 865 |
} else { |
866 | 866 |
_first[new_level] = _next[i]; |
867 | 867 |
} |
868 |
_level |
|
868 |
_level[i] = new_level; |
|
869 | 869 |
if (_first[new_level] == INVALID) { |
870 | 870 |
_first[new_level] = _last[new_level] = i; |
871 |
_prev.set(i, INVALID); |
|
872 |
_next.set(i, INVALID); |
|
871 |
_prev[i] = INVALID; |
|
872 |
_next[i] = INVALID; |
|
873 | 873 |
} else { |
874 |
_prev.set(_first[new_level], i); |
|
875 |
_next.set(i, _first[new_level]); |
|
874 |
_prev[_first[new_level]] = i; |
|
875 |
_next[i] = _first[new_level]; |
|
876 | 876 |
_first[new_level] = i; |
877 | 877 |
} |
878 | 878 |
if (_highest_active < new_level) { |
... | ... |
@@ -888,7 +888,7 @@ |
888 | 888 |
///only if you really know what it is for. |
889 | 889 |
///\pre The item is on the top level. |
890 | 890 |
void dirtyTopButOne(Item i) { |
891 |
_level |
|
891 |
_level[i] = _max_level - 1; |
|
892 | 892 |
} |
893 | 893 |
|
894 | 894 |
///Lift all items on and above the given level to the top level. |
... | ... |
@@ -899,7 +899,7 @@ |
899 | 899 |
for (int i = l + 1; _first[i] != INVALID; ++i) { |
900 | 900 |
Item n = _first[i]; |
901 | 901 |
while (n != INVALID) { |
902 |
_level |
|
902 |
_level[n] = _max_level; |
|
903 | 903 |
n = _next[n]; |
904 | 904 |
} |
905 | 905 |
_first[i] = INVALID; |
... | ... |
@@ -937,23 +937,23 @@ |
937 | 937 |
_init_level = 0; |
938 | 938 |
for(typename ItemSetTraits<GR,Item>::ItemIt i(_graph); |
939 | 939 |
i != INVALID; ++i) { |
940 |
_level.set(i, _max_level); |
|
941 |
_active.set(i, false); |
|
940 |
_level[i] = _max_level; |
|
941 |
_active[i] = false; |
|
942 | 942 |
} |
943 | 943 |
} |
944 | 944 |
|
945 | 945 |
///Add an item to the current level. |
946 | 946 |
void initAddItem(Item i) { |
947 |
_level |
|
947 |
_level[i] = _init_level; |
|
948 | 948 |
if (_last[_init_level] == INVALID) { |
949 | 949 |
_first[_init_level] = i; |
950 | 950 |
_last[_init_level] = i; |
951 |
_prev.set(i, INVALID); |
|
952 |
_next.set(i, INVALID); |
|
951 |
_prev[i] = INVALID; |
|
952 |
_next[i] = INVALID; |
|
953 | 953 |
} else { |
954 |
_prev.set(i, _last[_init_level]); |
|
955 |
_next.set(i, INVALID); |
|
956 |
|
|
954 |
_prev[i] = _last[_init_level]; |
|
955 |
_next[i] = INVALID; |
|
956 |
_next[_last[_init_level]] = i; |
|
957 | 957 |
_last[_init_level] = i; |
958 | 958 |
} |
959 | 959 |
} |
... | ... |
@@ -143,11 +143,11 @@ |
143 | 143 |
|
144 | 144 |
_root = NodeIt(_graph); |
145 | 145 |
for (NodeIt n(_graph); n != INVALID; ++n) { |
146 |
_pred->set(n, _root); |
|
147 |
_order->set(n, -1); |
|
146 |
(*_pred)[n] = _root; |
|
147 |
(*_order)[n] = -1; |
|
148 | 148 |
} |
149 |
_pred->set(_root, INVALID); |
|
150 |
_weight->set(_root, std::numeric_limits<Value>::max()); |
|
149 |
(*_pred)[_root] = INVALID; |
|
150 |
(*_weight)[_root] = std::numeric_limits<Value>::max(); |
|
151 | 151 |
} |
152 | 152 |
|
153 | 153 |
|
... | ... |
@@ -164,22 +164,22 @@ |
164 | 164 |
|
165 | 165 |
fa.runMinCut(); |
166 | 166 |
|
167 |
_weight |
|
167 |
(*_weight)[n] = fa.flowValue(); |
|
168 | 168 |
|
169 | 169 |
for (NodeIt nn(_graph); nn != INVALID; ++nn) { |
170 | 170 |
if (nn != n && fa.minCut(nn) && (*_pred)[nn] == pn) { |
171 |
_pred |
|
171 |
(*_pred)[nn] = n; |
|
172 | 172 |
} |
173 | 173 |
} |
174 | 174 |
if ((*_pred)[pn] != INVALID && fa.minCut((*_pred)[pn])) { |
175 |
_pred->set(n, (*_pred)[pn]); |
|
176 |
_pred->set(pn, n); |
|
177 |
_weight->set(n, (*_weight)[pn]); |
|
178 |
_weight->set(pn, fa.flowValue()); |
|
175 |
(*_pred)[n] = (*_pred)[pn]; |
|
176 |
(*_pred)[pn] = n; |
|
177 |
(*_weight)[n] = (*_weight)[pn]; |
|
178 |
(*_weight)[pn] = fa.flowValue(); |
|
179 | 179 |
} |
180 | 180 |
} |
181 | 181 |
|
182 |
_order |
|
182 |
(*_order)[_root] = 0; |
|
183 | 183 |
int index = 1; |
184 | 184 |
|
185 | 185 |
for (NodeIt n(_graph); n != INVALID; ++n) { |
... | ... |
@@ -190,7 +190,7 @@ |
190 | 190 |
nn = (*_pred)[nn]; |
191 | 191 |
} |
192 | 192 |
while (!st.empty()) { |
193 |
_order |
|
193 |
(*_order)[st.back()] = index++; |
|
194 | 194 |
st.pop_back(); |
195 | 195 |
} |
196 | 196 |
} |
... | ... |
@@ -309,9 +309,9 @@ |
309 | 309 |
} |
310 | 310 |
|
311 | 311 |
typename Graph::template NodeMap<bool> reached(_graph, false); |
312 |
reached |
|
312 |
reached[_root] = true; |
|
313 | 313 |
cutMap.set(_root, !s_root); |
314 |
reached |
|
314 |
reached[rn] = true; |
|
315 | 315 |
cutMap.set(rn, s_root); |
316 | 316 |
|
317 | 317 |
std::vector<Node> st; |
... | ... |
@@ -161,56 +161,56 @@ |
161 | 161 |
private: |
162 | 162 |
|
163 | 163 |
void activate(const Node& i) { |
164 |
_active |
|
164 |
(*_active)[i] = true; |
|
165 | 165 |
|
166 | 166 |
int bucket = (*_bucket)[i]; |
167 | 167 |
|
168 | 168 |
if ((*_prev)[i] == INVALID || (*_active)[(*_prev)[i]]) return; |
169 | 169 |
//unlace |
170 |
_next |
|
170 |
(*_next)[(*_prev)[i]] = (*_next)[i]; |
|
171 | 171 |
if ((*_next)[i] != INVALID) { |
172 |
_prev |
|
172 |
(*_prev)[(*_next)[i]] = (*_prev)[i]; |
|
173 | 173 |
} else { |
174 | 174 |
_last[bucket] = (*_prev)[i]; |
175 | 175 |
} |
176 | 176 |
//lace |
177 |
_next->set(i, _first[bucket]); |
|
178 |
_prev->set(_first[bucket], i); |
|
179 |
|
|
177 |
(*_next)[i] = _first[bucket]; |
|
178 |
(*_prev)[_first[bucket]] = i; |
|
179 |
(*_prev)[i] = INVALID; |
|
180 | 180 |
_first[bucket] = i; |
181 | 181 |
} |
182 | 182 |
|
183 | 183 |
void deactivate(const Node& i) { |
184 |
_active |
|
184 |
(*_active)[i] = false; |
|
185 | 185 |
int bucket = (*_bucket)[i]; |
186 | 186 |
|
187 | 187 |
if ((*_next)[i] == INVALID || !(*_active)[(*_next)[i]]) return; |
188 | 188 |
|
189 | 189 |
//unlace |
190 |
_prev |
|
190 |
(*_prev)[(*_next)[i]] = (*_prev)[i]; |
|
191 | 191 |
if ((*_prev)[i] != INVALID) { |
192 |
_next |
|
192 |
(*_next)[(*_prev)[i]] = (*_next)[i]; |
|
193 | 193 |
} else { |
194 | 194 |
_first[bucket] = (*_next)[i]; |
195 | 195 |
} |
196 | 196 |
//lace |
197 |
_prev->set(i, _last[bucket]); |
|
198 |
_next->set(_last[bucket], i); |
|
199 |
|
|
197 |
(*_prev)[i] = _last[bucket]; |
|
198 |
(*_next)[_last[bucket]] = i; |
|
199 |
(*_next)[i] = INVALID; |
|
200 | 200 |
_last[bucket] = i; |
201 | 201 |
} |
202 | 202 |
|
203 | 203 |
void addItem(const Node& i, int bucket) { |
204 | 204 |
(*_bucket)[i] = bucket; |
205 | 205 |
if (_last[bucket] != INVALID) { |
206 |
_prev->set(i, _last[bucket]); |
|
207 |
_next->set(_last[bucket], i); |
|
208 |
|
|
206 |
(*_prev)[i] = _last[bucket]; |
|
207 |
(*_next)[_last[bucket]] = i; |
|
208 |
(*_next)[i] = INVALID; |
|
209 | 209 |
_last[bucket] = i; |
210 | 210 |
} else { |
211 |
_prev |
|
211 |
(*_prev)[i] = INVALID; |
|
212 | 212 |
_first[bucket] = i; |
213 |
_next |
|
213 |
(*_next)[i] = INVALID; |
|
214 | 214 |
_last[bucket] = i; |
215 | 215 |
} |
216 | 216 |
} |
... | ... |
@@ -218,11 +218,11 @@ |
218 | 218 |
void findMinCutOut() { |
219 | 219 |
|
220 | 220 |
for (NodeIt n(_graph); n != INVALID; ++n) { |
221 |
_excess |
|
221 |
(*_excess)[n] = 0; |
|
222 | 222 |
} |
223 | 223 |
|
224 | 224 |
for (ArcIt a(_graph); a != INVALID; ++a) { |
225 |
_flow |
|
225 |
(*_flow)[a] = 0; |
|
226 | 226 |
} |
227 | 227 |
|
228 | 228 |
int bucket_num = 0; |
... | ... |
@@ -232,7 +232,7 @@ |
232 | 232 |
{ |
233 | 233 |
typename Digraph::template NodeMap<bool> reached(_graph, false); |
234 | 234 |
|
235 |
reached |
|
235 |
reached[_source] = true; |
|
236 | 236 |
bool first_set = true; |
237 | 237 |
|
238 | 238 |
for (NodeIt t(_graph); t != INVALID; ++t) { |
... | ... |
@@ -240,7 +240,7 @@ |
240 | 240 |
_sets.push_front(std::list<int>()); |
241 | 241 |
|
242 | 242 |
queue[qlast++] = t; |
243 |
reached |
|
243 |
reached[t] = true; |
|
244 | 244 |
|
245 | 245 |
while (qfirst != qlast) { |
246 | 246 |
if (qsep == qfirst) { |
... | ... |
@@ -257,7 +257,7 @@ |
257 | 257 |
for (InArcIt a(_graph, n); a != INVALID; ++a) { |
258 | 258 |
Node u = _graph.source(a); |
259 | 259 |
if (!reached[u] && _tolerance.positive((*_capacity)[a])) { |
260 |
reached |
|
260 |
reached[u] = true; |
|
261 | 261 |
queue[qlast++] = u; |
262 | 262 |
} |
263 | 263 |
} |
... | ... |
@@ -266,18 +266,18 @@ |
266 | 266 |
} |
267 | 267 |
|
268 | 268 |
++bucket_num; |
269 |
_bucket |
|
269 |
(*_bucket)[_source] = 0; |
|
270 | 270 |
_dormant[0] = true; |
271 | 271 |
} |
272 |
_source_set |
|
272 |
(*_source_set)[_source] = true; |
|
273 | 273 |
|
274 | 274 |
Node target = _last[_sets.back().back()]; |
275 | 275 |
{ |
276 | 276 |
for (OutArcIt a(_graph, _source); a != INVALID; ++a) { |
277 | 277 |
if (_tolerance.positive((*_capacity)[a])) { |
278 | 278 |
Node u = _graph.target(a); |
279 |
_flow->set(a, (*_capacity)[a]); |
|
280 |
_excess->set(u, (*_excess)[u] + (*_capacity)[a]); |
|
279 |
(*_flow)[a] = (*_capacity)[a]; |
|
280 |
(*_excess)[u] += (*_capacity)[a]; |
|
281 | 281 |
if (!(*_active)[u] && u != _source) { |
282 | 282 |
activate(u); |
283 | 283 |
} |
... | ... |
@@ -318,14 +318,14 @@ |
318 | 318 |
activate(v); |
319 | 319 |
} |
320 | 320 |
if (!_tolerance.less(rem, excess)) { |
321 |
_flow->set(a, (*_flow)[a] + excess); |
|
322 |
_excess->set(v, (*_excess)[v] + excess); |
|
321 |
(*_flow)[a] += excess; |
|
322 |
(*_excess)[v] += excess; |
|
323 | 323 |
excess = 0; |
324 | 324 |
goto no_more_push; |
325 | 325 |
} else { |
326 | 326 |
excess -= rem; |
327 |
_excess->set(v, (*_excess)[v] + rem); |
|
328 |
_flow->set(a, (*_capacity)[a]); |
|
327 |
(*_excess)[v] += rem; |
|
328 |
(*_flow)[a] = (*_capacity)[a]; |
|
329 | 329 |
} |
330 | 330 |
} else if (next_bucket > (*_bucket)[v]) { |
331 | 331 |
next_bucket = (*_bucket)[v]; |
... | ... |
@@ -342,14 +342,14 @@ |
342 | 342 |
activate(v); |
343 | 343 |
} |
344 | 344 |
if (!_tolerance.less(rem, excess)) { |
345 |
_flow->set(a, (*_flow)[a] - excess); |
|
346 |
_excess->set(v, (*_excess)[v] + excess); |
|
345 |
(*_flow)[a] -= excess; |
|
346 |
(*_excess)[v] += excess; |
|
347 | 347 |
excess = 0; |
348 | 348 |
goto no_more_push; |
349 | 349 |
} else { |
350 | 350 |
excess -= rem; |
351 |
_excess->set(v, (*_excess)[v] + rem); |
|
352 |
_flow->set(a, 0); |
|
351 |
(*_excess)[v] += rem; |
|
352 |
(*_flow)[a] = 0; |
|
353 | 353 |
} |
354 | 354 |
} else if (next_bucket > (*_bucket)[v]) { |
355 | 355 |
next_bucket = (*_bucket)[v]; |
... | ... |
@@ -358,7 +358,7 @@ |
358 | 358 |
|
359 | 359 |
no_more_push: |
360 | 360 |
|
361 |
_excess |
|
361 |
(*_excess)[n] = excess; |
|
362 | 362 |
|
363 | 363 |
if (excess != 0) { |
364 | 364 |
if ((*_next)[n] == INVALID) { |
... | ... |
@@ -376,16 +376,16 @@ |
376 | 376 |
} |
377 | 377 |
} else if (next_bucket == _node_num) { |
378 | 378 |
_first[(*_bucket)[n]] = (*_next)[n]; |
379 |
_prev |
|
379 |
(*_prev)[(*_next)[n]] = INVALID; |
|
380 | 380 |
|
381 | 381 |
std::list<std::list<int> >::iterator new_set = |
382 | 382 |
_sets.insert(--_sets.end(), std::list<int>()); |
383 | 383 |
|
384 | 384 |
new_set->push_front(bucket_num); |
385 |
_bucket |
|
385 |
(*_bucket)[n] = bucket_num; |
|
386 | 386 |
_first[bucket_num] = _last[bucket_num] = n; |
387 |
_next->set(n, INVALID); |
|
388 |
_prev->set(n, INVALID); |
|
387 |
(*_next)[n] = INVALID; |
|
388 |
(*_prev)[n] = INVALID; |
|
389 | 389 |
_dormant[bucket_num] = true; |
390 | 390 |
++bucket_num; |
391 | 391 |
|
... | ... |
@@ -395,7 +395,7 @@ |
395 | 395 |
} |
396 | 396 |
} else { |
397 | 397 |
_first[*_highest] = (*_next)[n]; |
398 |
_prev |
|
398 |
(*_prev)[(*_next)[n]] = INVALID; |
|
399 | 399 |
|
400 | 400 |
while (next_bucket != *_highest) { |
401 | 401 |
--_highest; |
... | ... |
@@ -409,10 +409,10 @@ |
409 | 409 |
} |
410 | 410 |
--_highest; |
411 | 411 |
|
412 |
_bucket->set(n, *_highest); |
|
413 |
_next->set(n, _first[*_highest]); |
|
412 |
(*_bucket)[n] = *_highest; |
|
413 |
(*_next)[n] = _first[*_highest]; |
|
414 | 414 |
if (_first[*_highest] != INVALID) { |
415 |
_prev |
|
415 |
(*_prev)[_first[*_highest]] = n; |
|
416 | 416 |
} else { |
417 | 417 |
_last[*_highest] = n; |
418 | 418 |
} |
... | ... |
@@ -434,13 +434,13 @@ |
434 | 434 |
if ((*_excess)[target] < _min_cut) { |
435 | 435 |
_min_cut = (*_excess)[target]; |
436 | 436 |
for (NodeIt i(_graph); i != INVALID; ++i) { |
437 |
_min_cut_map |
|
437 |
(*_min_cut_map)[i] = true; |
|
438 | 438 |
} |
439 | 439 |
for (std::list<int>::iterator it = _sets.back().begin(); |
440 | 440 |
it != _sets.back().end(); ++it) { |
441 | 441 |
Node n = _first[*it]; |
442 | 442 |
while (n != INVALID) { |
443 |
_min_cut_map |
|
443 |
(*_min_cut_map)[n] = false; |
|
444 | 444 |
n = (*_next)[n]; |
445 | 445 |
} |
446 | 446 |
} |
... | ... |
@@ -453,13 +453,13 @@ |
453 | 453 |
_last[(*_bucket)[target]] = (*_prev)[target]; |
454 | 454 |
new_target = (*_prev)[target]; |
455 | 455 |
} else { |
456 |
_prev |
|
456 |
(*_prev)[(*_next)[target]] = (*_prev)[target]; |
|
457 | 457 |
new_target = (*_next)[target]; |
458 | 458 |
} |
459 | 459 |
if ((*_prev)[target] == INVALID) { |
460 | 460 |
_first[(*_bucket)[target]] = (*_next)[target]; |
461 | 461 |
} else { |
462 |
_next |
|
462 |
(*_next)[(*_prev)[target]] = (*_next)[target]; |
|
463 | 463 |
} |
464 | 464 |
} else { |
465 | 465 |
_sets.back().pop_back(); |
... | ... |
@@ -475,9 +475,9 @@ |
475 | 475 |
new_target = _last[_sets.back().back()]; |
476 | 476 |
} |
477 | 477 |
|
478 |
_bucket |
|
478 |
(*_bucket)[target] = 0; |
|
479 | 479 |
|
480 |
_source_set |
|
480 |
(*_source_set)[target] = true; |
|
481 | 481 |
for (OutArcIt a(_graph, target); a != INVALID; ++a) { |
482 | 482 |
Value rem = (*_capacity)[a] - (*_flow)[a]; |
483 | 483 |
if (!_tolerance.positive(rem)) continue; |
... | ... |
@@ -485,8 +485,8 @@ |
485 | 485 |
if (!(*_active)[v] && !(*_source_set)[v]) { |
486 | 486 |
activate(v); |
487 | 487 |
} |
488 |
_excess->set(v, (*_excess)[v] + rem); |
|
489 |
_flow->set(a, (*_capacity)[a]); |
|
488 |
(*_excess)[v] += rem; |
|
489 |
(*_flow)[a] = (*_capacity)[a]; |
|
490 | 490 |
} |
491 | 491 |
|
492 | 492 |
for (InArcIt a(_graph, target); a != INVALID; ++a) { |
... | ... |
@@ -496,8 +496,8 @@ |
496 | 496 |
if (!(*_active)[v] && !(*_source_set)[v]) { |
497 | 497 |
activate(v); |
498 | 498 |
} |
499 |
_excess->set(v, (*_excess)[v] + rem); |
|
500 |
_flow->set(a, 0); |
|
499 |
(*_excess)[v] += rem; |
|
500 |
(*_flow)[a] = 0; |
|
501 | 501 |
} |
502 | 502 |
|
503 | 503 |
target = new_target; |
... | ... |
@@ -517,11 +517,11 @@ |
517 | 517 |
void findMinCutIn() { |
518 | 518 |
|
519 | 519 |
for (NodeIt n(_graph); n != INVALID; ++n) { |
520 |
_excess |
|
520 |
(*_excess)[n] = 0; |
|
521 | 521 |
} |
522 | 522 |
|
523 | 523 |
for (ArcIt a(_graph); a != INVALID; ++a) { |
524 |
_flow |
|
524 |
(*_flow)[a] = 0; |
|
525 | 525 |
} |
526 | 526 |
|
527 | 527 |
int bucket_num = 0; |
... | ... |
@@ -531,7 +531,7 @@ |
531 | 531 |
{ |
532 | 532 |
typename Digraph::template NodeMap<bool> reached(_graph, false); |
533 | 533 |
|
534 |
reached |
|
534 |
reached[_source] = true; |
|
535 | 535 |
|
536 | 536 |
bool first_set = true; |
537 | 537 |
|
... | ... |
@@ -540,7 +540,7 @@ |
540 | 540 |
_sets.push_front(std::list<int>()); |
541 | 541 |
|
542 | 542 |
queue[qlast++] = t; |
543 |
reached |
|
543 |
reached[t] = true; |
|
544 | 544 |
|
545 | 545 |
while (qfirst != qlast) { |
546 | 546 |
if (qsep == qfirst) { |
... | ... |
@@ -557,7 +557,7 @@ |
557 | 557 |
for (OutArcIt a(_graph, n); a != INVALID; ++a) { |
558 | 558 |
Node u = _graph.target(a); |
559 | 559 |
if (!reached[u] && _tolerance.positive((*_capacity)[a])) { |
560 |
reached |
|
560 |
reached[u] = true; |
|
561 | 561 |
queue[qlast++] = u; |
562 | 562 |
} |
563 | 563 |
} |
... | ... |
@@ -566,18 +566,18 @@ |
566 | 566 |
} |
567 | 567 |
|
568 | 568 |
++bucket_num; |
569 |
_bucket |
|
569 |
(*_bucket)[_source] = 0; |
|
570 | 570 |
_dormant[0] = true; |
571 | 571 |
} |
572 |
_source_set |
|
572 |
(*_source_set)[_source] = true; |
|
573 | 573 |
|
574 | 574 |
Node target = _last[_sets.back().back()]; |
575 | 575 |
{ |
576 | 576 |
for (InArcIt a(_graph, _source); a != INVALID; ++a) { |
577 | 577 |
if (_tolerance.positive((*_capacity)[a])) { |
578 | 578 |
Node u = _graph.source(a); |
579 |
_flow->set(a, (*_capacity)[a]); |
|
580 |
_excess->set(u, (*_excess)[u] + (*_capacity)[a]); |
|
579 |
(*_flow)[a] = (*_capacity)[a]; |
|
580 |
(*_excess)[u] += (*_capacity)[a]; |
|
581 | 581 |
if (!(*_active)[u] && u != _source) { |
582 | 582 |
activate(u); |
583 | 583 |
} |
... | ... |
@@ -618,14 +618,14 @@ |
618 | 618 |
activate(v); |
619 | 619 |
} |
620 | 620 |
if (!_tolerance.less(rem, excess)) { |
621 |
_flow->set(a, (*_flow)[a] + excess); |
|
622 |
_excess->set(v, (*_excess)[v] + excess); |
|
621 |
(*_flow)[a] += excess; |
|
622 |
(*_excess)[v] += excess; |
|
623 | 623 |
excess = 0; |
624 | 624 |
goto no_more_push; |
625 | 625 |
} else { |
626 | 626 |
excess -= rem; |
627 |
_excess->set(v, (*_excess)[v] + rem); |
|
628 |
_flow->set(a, (*_capacity)[a]); |
|
627 |
(*_excess)[v] += rem; |
|
628 |
(*_flow)[a] = (*_capacity)[a]; |
|
629 | 629 |
} |
630 | 630 |
} else if (next_bucket > (*_bucket)[v]) { |
631 | 631 |
next_bucket = (*_bucket)[v]; |
... | ... |
@@ -642,14 +642,14 @@ |
642 | 642 |
activate(v); |
643 | 643 |
} |
644 | 644 |
if (!_tolerance.less(rem, excess)) { |
645 |
_flow->set(a, (*_flow)[a] - excess); |
|
646 |
_excess->set(v, (*_excess)[v] + excess); |
|
645 |
(*_flow)[a] -= excess; |
|
646 |
(*_excess)[v] += excess; |
|
647 | 647 |
excess = 0; |
648 | 648 |
goto no_more_push; |
649 | 649 |
} else { |
650 | 650 |
excess -= rem; |
651 |
_excess->set(v, (*_excess)[v] + rem); |
|
652 |
_flow->set(a, 0); |
|
651 |
(*_excess)[v] += rem; |
|
652 |
(*_flow)[a] = 0; |
|
653 | 653 |
} |
654 | 654 |
} else if (next_bucket > (*_bucket)[v]) { |
655 | 655 |
next_bucket = (*_bucket)[v]; |
... | ... |
@@ -658,7 +658,7 @@ |
658 | 658 |
|
659 | 659 |
no_more_push: |
660 | 660 |
|
661 |
_excess |
|
661 |
(*_excess)[n] = excess; |
|
662 | 662 |
|
663 | 663 |
if (excess != 0) { |
664 | 664 |
if ((*_next)[n] == INVALID) { |
... | ... |
@@ -676,16 +676,16 @@ |
676 | 676 |
} |
677 | 677 |
} else if (next_bucket == _node_num) { |
678 | 678 |
_first[(*_bucket)[n]] = (*_next)[n]; |
679 |
_prev |
|
679 |
(*_prev)[(*_next)[n]] = INVALID; |
|
680 | 680 |
|
681 | 681 |
std::list<std::list<int> >::iterator new_set = |
682 | 682 |
_sets.insert(--_sets.end(), std::list<int>()); |
683 | 683 |
|
684 | 684 |
new_set->push_front(bucket_num); |
685 |
_bucket |
|
685 |
(*_bucket)[n] = bucket_num; |
|
686 | 686 |
_first[bucket_num] = _last[bucket_num] = n; |
687 |
_next->set(n, INVALID); |
|
688 |
_prev->set(n, INVALID); |
|
687 |
(*_next)[n] = INVALID; |
|
688 |
(*_prev)[n] = INVALID; |
|
689 | 689 |
_dormant[bucket_num] = true; |
690 | 690 |
++bucket_num; |
691 | 691 |
|
... | ... |
@@ -695,7 +695,7 @@ |
695 | 695 |
} |
696 | 696 |
} else { |
697 | 697 |
_first[*_highest] = (*_next)[n]; |
698 |
_prev |
|
698 |
(*_prev)[(*_next)[n]] = INVALID; |
|
699 | 699 |
|
700 | 700 |
while (next_bucket != *_highest) { |
701 | 701 |
--_highest; |
... | ... |
@@ -708,10 +708,10 @@ |
708 | 708 |
} |
709 | 709 |
--_highest; |
710 | 710 |
|
711 |
_bucket->set(n, *_highest); |
|
712 |
_next->set(n, _first[*_highest]); |
|
711 |
(*_bucket)[n] = *_highest; |
|
712 |
(*_next)[n] = _first[*_highest]; |
|
713 | 713 |
if (_first[*_highest] != INVALID) { |
714 |
_prev |
|
714 |
(*_prev)[_first[*_highest]] = n; |
|
715 | 715 |
} else { |
716 | 716 |
_last[*_highest] = n; |
717 | 717 |
} |
... | ... |
@@ -733,13 +733,13 @@ |
733 | 733 |
if ((*_excess)[target] < _min_cut) { |
734 | 734 |
_min_cut = (*_excess)[target]; |
735 | 735 |
for (NodeIt i(_graph); i != INVALID; ++i) { |
736 |
_min_cut_map |
|
736 |
(*_min_cut_map)[i] = false; |
|
737 | 737 |
} |
738 | 738 |
for (std::list<int>::iterator it = _sets.back().begin(); |
739 | 739 |
it != _sets.back().end(); ++it) { |
740 | 740 |
Node n = _first[*it]; |
741 | 741 |
while (n != INVALID) { |
742 |
_min_cut_map |
|
742 |
(*_min_cut_map)[n] = true; |
|
743 | 743 |
n = (*_next)[n]; |
744 | 744 |
} |
745 | 745 |
} |
... | ... |
@@ -752,13 +752,13 @@ |
752 | 752 |
_last[(*_bucket)[target]] = (*_prev)[target]; |
753 | 753 |
new_target = (*_prev)[target]; |
754 | 754 |
} else { |
755 |
_prev |
|
755 |
(*_prev)[(*_next)[target]] = (*_prev)[target]; |
|
756 | 756 |
new_target = (*_next)[target]; |
757 | 757 |
} |
758 | 758 |
if ((*_prev)[target] == INVALID) { |
759 | 759 |
_first[(*_bucket)[target]] = (*_next)[target]; |
760 | 760 |
} else { |
761 |
_next |
|
761 |
(*_next)[(*_prev)[target]] = (*_next)[target]; |
|
762 | 762 |
} |
763 | 763 |
} else { |
764 | 764 |
_sets.back().pop_back(); |
... | ... |
@@ -774,9 +774,9 @@ |
774 | 774 |
new_target = _last[_sets.back().back()]; |
775 | 775 |
} |
776 | 776 |
|
777 |
_bucket |
|
777 |
(*_bucket)[target] = 0; |
|
778 | 778 |
|
779 |
_source_set |
|
779 |
(*_source_set)[target] = true; |
|
780 | 780 |
for (InArcIt a(_graph, target); a != INVALID; ++a) { |
781 | 781 |
Value rem = (*_capacity)[a] - (*_flow)[a]; |
782 | 782 |
if (!_tolerance.positive(rem)) continue; |
... | ... |
@@ -784,8 +784,8 @@ |
784 | 784 |
if (!(*_active)[v] && !(*_source_set)[v]) { |
785 | 785 |
activate(v); |
786 | 786 |
} |
787 |
_excess->set(v, (*_excess)[v] + rem); |
|
788 |
_flow->set(a, (*_capacity)[a]); |
|
787 |
(*_excess)[v] += rem; |
|
788 |
(*_flow)[a] = (*_capacity)[a]; |
|
789 | 789 |
} |
790 | 790 |
|
791 | 791 |
for (OutArcIt a(_graph, target); a != INVALID; ++a) { |
... | ... |
@@ -795,8 +795,8 @@ |
795 | 795 |
if (!(*_active)[v] && !(*_source_set)[v]) { |
796 | 796 |
activate(v); |
797 | 797 |
} |
798 |
_excess->set(v, (*_excess)[v] + rem); |
|
799 |
_flow->set(a, 0); |
|
798 |
(*_excess)[v] += rem; |
|
799 |
(*_flow)[a] = 0; |
|
800 | 800 |
} |
801 | 801 |
|
802 | 802 |
target = new_target; |
... | ... |
@@ -282,20 +282,20 @@ |
282 | 282 |
Node base = (*_blossom_rep)[_blossom_set->find(node)]; |
283 | 283 |
|
284 | 284 |
while (base != nca) { |
285 |
_ear |
|
285 |
(*_ear)[node] = arc; |
|
286 | 286 |
|
287 | 287 |
Node n = node; |
288 | 288 |
while (n != base) { |
289 | 289 |
n = _graph.target((*_matching)[n]); |
290 | 290 |
Arc a = (*_ear)[n]; |
291 | 291 |
n = _graph.target(a); |
292 |
_ear |
|
292 |
(*_ear)[n] = _graph.oppositeArc(a); |
|
293 | 293 |
} |
294 | 294 |
node = _graph.target((*_matching)[base]); |
295 | 295 |
_tree_set->erase(base); |
296 | 296 |
_tree_set->erase(node); |
297 | 297 |
_blossom_set->insert(node, _blossom_set->find(base)); |
298 |
_status |
|
298 |
(*_status)[node] = EVEN; |
|
299 | 299 |
_node_queue[_last++] = node; |
300 | 300 |
arc = _graph.oppositeArc((*_ear)[node]); |
301 | 301 |
node = _graph.target((*_ear)[node]); |
... | ... |
@@ -304,7 +304,7 @@ |
304 | 304 |
} |
305 | 305 |
} |
306 | 306 |
|
307 |
_blossom_rep |
|
307 |
(*_blossom_rep)[_blossom_set->find(nca)] = nca; |
|
308 | 308 |
|
309 | 309 |
{ |
310 | 310 |
|
... | ... |
@@ -313,20 +313,20 @@ |
313 | 313 |
Node base = (*_blossom_rep)[_blossom_set->find(node)]; |
314 | 314 |
|
315 | 315 |
while (base != nca) { |
316 |
_ear |
|
316 |
(*_ear)[node] = arc; |
|
317 | 317 |
|
318 | 318 |
Node n = node; |
319 | 319 |
while (n != base) { |
320 | 320 |
n = _graph.target((*_matching)[n]); |
321 | 321 |
Arc a = (*_ear)[n]; |
322 | 322 |
n = _graph.target(a); |
323 |
_ear |
|
323 |
(*_ear)[n] = _graph.oppositeArc(a); |
|
324 | 324 |
} |
325 | 325 |
node = _graph.target((*_matching)[base]); |
326 | 326 |
_tree_set->erase(base); |
327 | 327 |
_tree_set->erase(node); |
328 | 328 |
_blossom_set->insert(node, _blossom_set->find(base)); |
329 |
_status |
|
329 |
(*_status)[node] = EVEN; |
|
330 | 330 |
_node_queue[_last++] = node; |
331 | 331 |
arc = _graph.oppositeArc((*_ear)[node]); |
332 | 332 |
node = _graph.target((*_ear)[node]); |
... | ... |
@@ -335,7 +335,7 @@ |
335 | 335 |
} |
336 | 336 |
} |
337 | 337 |
|
338 |
_blossom_rep |
|
338 |
(*_blossom_rep)[_blossom_set->find(nca)] = nca; |
|
339 | 339 |
} |
340 | 340 |
|
341 | 341 |
|
... | ... |
@@ -344,11 +344,11 @@ |
344 | 344 |
Node base = _graph.source(a); |
345 | 345 |
Node odd = _graph.target(a); |
346 | 346 |
|
347 |
_ear |
|
347 |
(*_ear)[odd] = _graph.oppositeArc(a); |
|
348 | 348 |
Node even = _graph.target((*_matching)[odd]); |
349 |
_blossom_rep->set(_blossom_set->insert(even), even); |
|
350 |
_status->set(odd, ODD); |
|
351 |
|
|
349 |
(*_blossom_rep)[_blossom_set->insert(even)] = even; |
|
350 |
(*_status)[odd] = ODD; |
|
351 |
(*_status)[even] = EVEN; |
|
352 | 352 |
int tree = _tree_set->find((*_blossom_rep)[_blossom_set->find(base)]); |
353 | 353 |
_tree_set->insert(odd, tree); |
354 | 354 |
_tree_set->insert(even, tree); |
... | ... |
@@ -362,30 +362,30 @@ |
362 | 362 |
|
363 | 363 |
int tree = _tree_set->find((*_blossom_rep)[_blossom_set->find(even)]); |
364 | 364 |
|
365 |
_matching->set(odd, _graph.oppositeArc(a)); |
|
366 |
_status->set(odd, MATCHED); |
|
365 |
(*_matching)[odd] = _graph.oppositeArc(a); |
|
366 |
(*_status)[odd] = MATCHED; |
|
367 | 367 |
|
368 | 368 |
Arc arc = (*_matching)[even]; |
369 |
_matching |
|
369 |
(*_matching)[even] = a; |
|
370 | 370 |
|
371 | 371 |
while (arc != INVALID) { |
372 | 372 |
odd = _graph.target(arc); |
373 | 373 |
arc = (*_ear)[odd]; |
374 | 374 |
even = _graph.target(arc); |
375 |
_matching |
|
375 |
(*_matching)[odd] = arc; |
|
376 | 376 |
arc = (*_matching)[even]; |
377 |
_matching |
|
377 |
(*_matching)[even] = _graph.oppositeArc((*_matching)[odd]); |
|
378 | 378 |
} |
379 | 379 |
|
380 | 380 |
for (typename TreeSet::ItemIt it(*_tree_set, tree); |
381 | 381 |
it != INVALID; ++it) { |
382 | 382 |
if ((*_status)[it] == ODD) { |
383 |
_status |
|
383 |
(*_status)[it] = MATCHED; |
|
384 | 384 |
} else { |
385 | 385 |
int blossom = _blossom_set->find(it); |
386 | 386 |
for (typename BlossomSet::ItemIt jt(*_blossom_set, blossom); |
387 | 387 |
jt != INVALID; ++jt) { |
388 |
_status |
|
388 |
(*_status)[jt] = MATCHED; |
|
389 | 389 |
} |
390 | 390 |
_blossom_set->eraseClass(blossom); |
391 | 391 |
} |
... | ... |
@@ -427,8 +427,8 @@ |
427 | 427 |
void init() { |
428 | 428 |
createStructures(); |
429 | 429 |
for(NodeIt n(_graph); n != INVALID; ++n) { |
430 |
_matching->set(n, INVALID); |
|
431 |
_status->set(n, UNMATCHED); |
|
430 |
(*_matching)[n] = INVALID; |
|
431 |
(*_status)[n] = UNMATCHED; |
|
432 | 432 |
} |
433 | 433 |
} |
434 | 434 |
|
... | ... |
@@ -438,18 +438,18 @@ |
438 | 438 |
void greedyInit() { |
439 | 439 |
createStructures(); |
440 | 440 |
for (NodeIt n(_graph); n != INVALID; ++n) { |
441 |
_matching->set(n, INVALID); |
|
442 |
_status->set(n, UNMATCHED); |
|
441 |
(*_matching)[n] = INVALID; |
|
442 |
(*_status)[n] = UNMATCHED; |
|
443 | 443 |
} |
444 | 444 |
for (NodeIt n(_graph); n != INVALID; ++n) { |
445 | 445 |
if ((*_matching)[n] == INVALID) { |
446 | 446 |
for (OutArcIt a(_graph, n); a != INVALID ; ++a) { |
447 | 447 |
Node v = _graph.target(a); |
448 | 448 |
if ((*_matching)[v] == INVALID && v != n) { |
449 |
_matching->set(n, a); |
|
450 |
_status->set(n, MATCHED); |
|
451 |
_matching->set(v, _graph.oppositeArc(a)); |
|
452 |
_status->set(v, MATCHED); |
|
449 |
(*_matching)[n] = a; |
|
450 |
(*_status)[n] = MATCHED; |
|
451 |
(*_matching)[v] = _graph.oppositeArc(a); |
|
452 |
(*_status)[v] = MATCHED; |
|
453 | 453 |
break; |
454 | 454 |
} |
455 | 455 |
} |
... | ... |
@@ -469,21 +469,21 @@ |
469 | 469 |
createStructures(); |
470 | 470 |
|
471 | 471 |
for (NodeIt n(_graph); n != INVALID; ++n) { |
472 |
_matching->set(n, INVALID); |
|
473 |
_status->set(n, UNMATCHED); |
|
472 |
(*_matching)[n] = INVALID; |
|
473 |
(*_status)[n] = UNMATCHED; |
|
474 | 474 |
} |
475 | 475 |
for(EdgeIt e(_graph); e!=INVALID; ++e) { |
476 | 476 |
if (matching[e]) { |
477 | 477 |
|
478 | 478 |
Node u = _graph.u(e); |
479 | 479 |
if ((*_matching)[u] != INVALID) return false; |
480 |
_matching->set(u, _graph.direct(e, true)); |
|
481 |
_status->set(u, MATCHED); |
|
480 |
(*_matching)[u] = _graph.direct(e, true); |
|
481 |
(*_status)[u] = MATCHED; |
|
482 | 482 |
|
483 | 483 |
Node v = _graph.v(e); |
484 | 484 |
if ((*_matching)[v] != INVALID) return false; |
485 |
_matching->set(v, _graph.direct(e, false)); |
|
486 |
_status->set(v, MATCHED); |
|
485 |
(*_matching)[v] = _graph.direct(e, false); |
|
486 |
(*_status)[v] = MATCHED; |
|
487 | 487 |
} |
488 | 488 |
} |
489 | 489 |
return true; |
... | ... |
@@ -497,7 +497,7 @@ |
497 | 497 |
if ((*_status)[n] == UNMATCHED) { |
498 | 498 |
(*_blossom_rep)[_blossom_set->insert(n)] = n; |
499 | 499 |
_tree_set->insert(n); |
500 |
_status |
|
500 |
(*_status)[n] = EVEN; |
|
501 | 501 |
processSparse(n); |
502 | 502 |
} |
503 | 503 |
} |
... | ... |
@@ -512,7 +512,7 @@ |
512 | 512 |
if ((*_status)[n] == UNMATCHED) { |
513 | 513 |
(*_blossom_rep)[_blossom_set->insert(n)] = n; |
514 | 514 |
_tree_set->insert(n); |
515 |
_status |
|
515 |
(*_status)[n] = EVEN; |
|
516 | 516 |
processDense(n); |
517 | 517 |
} |
518 | 518 |
} |
... | ... |
@@ -1548,9 +1548,9 @@ |
1548 | 1548 |
int bi = (*_node_index)[base]; |
1549 | 1549 |
Value pot = (*_node_data)[bi].pot; |
1550 | 1550 |
|
1551 |
_matching |
|
1551 |
(*_matching)[base] = matching; |
|
1552 | 1552 |
_blossom_node_list.push_back(base); |
1553 |
_node_potential |
|
1553 |
(*_node_potential)[base] = pot; |
|
1554 | 1554 |
} else { |
1555 | 1555 |
|
1556 | 1556 |
Value pot = (*_blossom_data)[blossom].pot; |
... | ... |
@@ -1644,17 +1644,17 @@ |
1644 | 1644 |
createStructures(); |
1645 | 1645 |
|
1646 | 1646 |
for (ArcIt e(_graph); e != INVALID; ++e) { |
1647 |
_node_heap_index |
|
1647 |
(*_node_heap_index)[e] = BinHeap<Value, IntArcMap>::PRE_HEAP; |
|
1648 | 1648 |
} |
1649 | 1649 |
for (NodeIt n(_graph); n != INVALID; ++n) { |
1650 |
_delta1_index |
|
1650 |
(*_delta1_index)[n] = _delta1->PRE_HEAP; |
|
1651 | 1651 |
} |
1652 | 1652 |
for (EdgeIt e(_graph); e != INVALID; ++e) { |
1653 |
_delta3_index |
|
1653 |
(*_delta3_index)[e] = _delta3->PRE_HEAP; |
|
1654 | 1654 |
} |
1655 | 1655 |
for (int i = 0; i < _blossom_num; ++i) { |
1656 |
_delta2_index->set(i, _delta2->PRE_HEAP); |
|
1657 |
_delta4_index->set(i, _delta4->PRE_HEAP); |
|
1656 |
(*_delta2_index)[i] = _delta2->PRE_HEAP; |
|
1657 |
(*_delta4_index)[i] = _delta4->PRE_HEAP; |
|
1658 | 1658 |
} |
1659 | 1659 |
|
1660 | 1660 |
int index = 0; |
... | ... |
@@ -1666,7 +1666,7 @@ |
1666 | 1666 |
max = (dualScale * _weight[e]) / 2; |
1667 | 1667 |
} |
1668 | 1668 |
} |
1669 |
_node_index |
|
1669 |
(*_node_index)[n] = index; |
|
1670 | 1670 |
(*_node_data)[index].pot = max; |
1671 | 1671 |
_delta1->push(n, max); |
1672 | 1672 |
int blossom = |
... | ... |
@@ -2741,9 +2741,9 @@ |
2741 | 2741 |
int bi = (*_node_index)[base]; |
2742 | 2742 |
Value pot = (*_node_data)[bi].pot; |
2743 | 2743 |
|
2744 |
_matching |
|
2744 |
(*_matching)[base] = matching; |
|
2745 | 2745 |
_blossom_node_list.push_back(base); |
2746 |
_node_potential |
|
2746 |
(*_node_potential)[base] = pot; |
|
2747 | 2747 |
} else { |
2748 | 2748 |
|
2749 | 2749 |
Value pot = (*_blossom_data)[blossom].pot; |
... | ... |
@@ -2831,14 +2831,14 @@ |
2831 | 2831 |
createStructures(); |
2832 | 2832 |
|
2833 | 2833 |
for (ArcIt e(_graph); e != INVALID; ++e) { |
2834 |
_node_heap_index |
|
2834 |
(*_node_heap_index)[e] = BinHeap<Value, IntArcMap>::PRE_HEAP; |
|
2835 | 2835 |
} |
2836 | 2836 |
for (EdgeIt e(_graph); e != INVALID; ++e) { |
2837 |
_delta3_index |
|
2837 |
(*_delta3_index)[e] = _delta3->PRE_HEAP; |
|
2838 | 2838 |
} |
2839 | 2839 |
for (int i = 0; i < _blossom_num; ++i) { |
2840 |
_delta2_index->set(i, _delta2->PRE_HEAP); |
|
2841 |
_delta4_index->set(i, _delta4->PRE_HEAP); |
|
2840 |
(*_delta2_index)[i] = _delta2->PRE_HEAP; |
|
2841 |
(*_delta4_index)[i] = _delta4->PRE_HEAP; |
|
2842 | 2842 |
} |
2843 | 2843 |
|
2844 | 2844 |
int index = 0; |
... | ... |
@@ -2850,7 +2850,7 @@ |
2850 | 2850 |
max = (dualScale * _weight[e]) / 2; |
2851 | 2851 |
} |
2852 | 2852 |
} |
2853 |
_node_index |
|
2853 |
(*_node_index)[n] = index; |
|
2854 | 2854 |
(*_node_data)[index].pot = max; |
2855 | 2855 |
int blossom = |
2856 | 2856 |
_blossom_set->insert(n, std::numeric_limits<Value>::max()); |
... | ... |
@@ -293,7 +293,7 @@ |
293 | 293 |
minimum = (*_cost_arcs)[nodes[i]]; |
294 | 294 |
} |
295 | 295 |
} |
296 |
_arc_order |
|
296 |
(*_arc_order)[minimum.arc] = _dual_variables.size(); |
|
297 | 297 |
DualVariable var(_dual_node_list.size() - 1, |
298 | 298 |
_dual_node_list.size(), minimum.value); |
299 | 299 |
_dual_variables.push_back(var); |
... | ... |
@@ -335,7 +335,7 @@ |
335 | 335 |
minimum = (*_cost_arcs)[nodes[i]]; |
336 | 336 |
} |
337 | 337 |
} |
338 |
_arc_order |
|
338 |
(*_arc_order)[minimum.arc] = _dual_variables.size(); |
|
339 | 339 |
DualVariable var(node_bottom, _dual_node_list.size(), minimum.value); |
340 | 340 |
_dual_variables.push_back(var); |
341 | 341 |
StackLevel level; |
... | ... |
@@ -364,7 +364,7 @@ |
364 | 364 |
while (!_heap->empty()) { |
365 | 365 |
Node source = _heap->top(); |
366 | 366 |
_heap->pop(); |
367 |
_node_order |
|
367 |
(*_node_order)[source] = -1; |
|
368 | 368 |
for (OutArcIt it(*_digraph, source); it != INVALID; ++it) { |
369 | 369 |
if ((*_arc_order)[it] < 0) continue; |
370 | 370 |
Node target = _digraph->target(it); |
... | ... |
@@ -650,13 +650,13 @@ |
650 | 650 |
_heap->clear(); |
651 | 651 |
for (NodeIt it(*_digraph); it != INVALID; ++it) { |
652 | 652 |
(*_cost_arcs)[it].arc = INVALID; |
653 |
_node_order->set(it, -3); |
|
654 |
_heap_cross_ref->set(it, Heap::PRE_HEAP); |
|
653 |
(*_node_order)[it] = -3; |
|
654 |
(*_heap_cross_ref)[it] = Heap::PRE_HEAP; |
|
655 | 655 |
_pred->set(it, INVALID); |
656 | 656 |
} |
657 | 657 |
for (ArcIt it(*_digraph); it != INVALID; ++it) { |
658 | 658 |
_arborescence->set(it, false); |
659 |
_arc_order |
|
659 |
(*_arc_order)[it] = -1; |
|
660 | 660 |
} |
661 | 661 |
_dual_node_list.clear(); |
662 | 662 |
_dual_variables.clear(); |
... | ... |
@@ -404,7 +404,7 @@ |
404 | 404 |
|
405 | 405 |
_phase = true; |
406 | 406 |
for (NodeIt n(_graph); n != INVALID; ++n) { |
407 |
_excess |
|
407 |
(*_excess)[n] = 0; |
|
408 | 408 |
} |
409 | 409 |
|
410 | 410 |
for (ArcIt e(_graph); e != INVALID; ++e) { |
... | ... |
@@ -417,10 +417,10 @@ |
417 | 417 |
_level->initAddItem(_target); |
418 | 418 |
|
419 | 419 |
std::vector<Node> queue; |
420 |
reached |
|
420 |
reached[_source] = true; |
|
421 | 421 |
|
422 | 422 |
queue.push_back(_target); |
423 |
reached |
|
423 |
reached[_target] = true; |
|
424 | 424 |
while (!queue.empty()) { |
425 | 425 |
_level->initNewLevel(); |
426 | 426 |
std::vector<Node> nqueue; |
... | ... |
@@ -429,7 +429,7 @@ |
429 | 429 |
for (InArcIt e(_graph, n); e != INVALID; ++e) { |
430 | 430 |
Node u = _graph.source(e); |
431 | 431 |
if (!reached[u] && _tolerance.positive((*_capacity)[e])) { |
432 |
reached |
|
432 |
reached[u] = true; |
|
433 | 433 |
_level->initAddItem(u); |
434 | 434 |
nqueue.push_back(u); |
435 | 435 |
} |
... | ... |
@@ -444,7 +444,7 @@ |
444 | 444 |
Node u = _graph.target(e); |
445 | 445 |
if ((*_level)[u] == _level->maxLevel()) continue; |
446 | 446 |
_flow->set(e, (*_capacity)[e]); |
447 |
|
|
447 |
(*_excess)[u] += (*_capacity)[e]; |
|
448 | 448 |
if (u != _target && !_level->active(u)) { |
449 | 449 |
_level->activate(u); |
450 | 450 |
} |
... | ... |
@@ -478,7 +478,7 @@ |
478 | 478 |
excess -= (*_flow)[e]; |
479 | 479 |
} |
480 | 480 |
if (excess < 0 && n != _source) return false; |
481 |
_excess |
|
481 |
(*_excess)[n] = excess; |
|
482 | 482 |
} |
483 | 483 |
|
484 | 484 |
typename Digraph::template NodeMap<bool> reached(_graph, false); |
... | ... |
@@ -487,10 +487,10 @@ |
487 | 487 |
_level->initAddItem(_target); |
488 | 488 |
|
489 | 489 |
std::vector<Node> queue; |
490 |
reached |
|
490 |
reached[_source] = true; |
|
491 | 491 |
|
492 | 492 |
queue.push_back(_target); |
493 |
reached |
|
493 |
reached[_target] = true; |
|
494 | 494 |
while (!queue.empty()) { |
495 | 495 |
_level->initNewLevel(); |
496 | 496 |
std::vector<Node> nqueue; |
... | ... |
@@ -500,7 +500,7 @@ |
500 | 500 |
Node u = _graph.source(e); |
501 | 501 |
if (!reached[u] && |
502 | 502 |
_tolerance.positive((*_capacity)[e] - (*_flow)[e])) { |
503 |
reached |
|
503 |
reached[u] = true; |
|
504 | 504 |
_level->initAddItem(u); |
505 | 505 |
nqueue.push_back(u); |
506 | 506 |
} |
... | ... |
@@ -508,7 +508,7 @@ |
508 | 508 |
for (OutArcIt e(_graph, n); e != INVALID; ++e) { |
509 | 509 |
Node v = _graph.target(e); |
510 | 510 |
if (!reached[v] && _tolerance.positive((*_flow)[e])) { |
511 |
reached |
|
511 |
reached[v] = true; |
|
512 | 512 |
_level->initAddItem(v); |
513 | 513 |
nqueue.push_back(v); |
514 | 514 |
} |
... | ... |
@@ -524,7 +524,7 @@ |
524 | 524 |
Node u = _graph.target(e); |
525 | 525 |
if ((*_level)[u] == _level->maxLevel()) continue; |
526 | 526 |
_flow->set(e, (*_capacity)[e]); |
527 |
|
|
527 |
(*_excess)[u] += rem; |
|
528 | 528 |
if (u != _target && !_level->active(u)) { |
529 | 529 |
_level->activate(u); |
530 | 530 |
} |
... | ... |
@@ -536,7 +536,7 @@ |
536 | 536 |
Node v = _graph.source(e); |
537 | 537 |
if ((*_level)[v] == _level->maxLevel()) continue; |
538 | 538 |
_flow->set(e, 0); |
539 |
|
|
539 |
(*_excess)[v] += rem; |
|
540 | 540 |
if (v != _target && !_level->active(v)) { |
541 | 541 |
_level->activate(v); |
542 | 542 |
} |
... | ... |
@@ -577,12 +577,12 @@ |
577 | 577 |
} |
578 | 578 |
if (!_tolerance.less(rem, excess)) { |
579 | 579 |
_flow->set(e, (*_flow)[e] + excess); |
580 |
|
|
580 |
(*_excess)[v] += excess; |
|
581 | 581 |
excess = 0; |
582 | 582 |
goto no_more_push_1; |
583 | 583 |
} else { |
584 | 584 |
excess -= rem; |
585 |
|
|
585 |
(*_excess)[v] += rem; |
|
586 | 586 |
_flow->set(e, (*_capacity)[e]); |
587 | 587 |
} |
588 | 588 |
} else if (new_level > (*_level)[v]) { |
... | ... |
@@ -600,12 +600,12 @@ |
600 | 600 |
} |
601 | 601 |
if (!_tolerance.less(rem, excess)) { |
602 | 602 |
_flow->set(e, (*_flow)[e] - excess); |
603 |
|
|
603 |
(*_excess)[v] += excess; |
|
604 | 604 |
excess = 0; |
605 | 605 |
goto no_more_push_1; |
606 | 606 |
} else { |
607 | 607 |
excess -= rem; |
608 |
|
|
608 |
(*_excess)[v] += rem; |
|
609 | 609 |
_flow->set(e, 0); |
610 | 610 |
} |
611 | 611 |
} else if (new_level > (*_level)[v]) { |
... | ... |
@@ -615,7 +615,7 @@ |
615 | 615 |
|
616 | 616 |
no_more_push_1: |
617 | 617 |
|
618 |
_excess |
|
618 |
(*_excess)[n] = excess; |
|
619 | 619 |
|
620 | 620 |
if (excess != 0) { |
621 | 621 |
if (new_level + 1 < _level->maxLevel()) { |
... | ... |
@@ -650,12 +650,12 @@ |
650 | 650 |
} |
651 | 651 |
if (!_tolerance.less(rem, excess)) { |
652 | 652 |
_flow->set(e, (*_flow)[e] + excess); |
653 |
|
|
653 |
(*_excess)[v] += excess; |
|
654 | 654 |
excess = 0; |
655 | 655 |
goto no_more_push_2; |
656 | 656 |
} else { |
657 | 657 |
excess -= rem; |
658 |
|
|
658 |
(*_excess)[v] += rem; |
|
659 | 659 |
_flow->set(e, (*_capacity)[e]); |
660 | 660 |
} |
661 | 661 |
} else if (new_level > (*_level)[v]) { |
... | ... |
@@ -673,12 +673,12 @@ |
673 | 673 |
} |
674 | 674 |
if (!_tolerance.less(rem, excess)) { |
675 | 675 |
_flow->set(e, (*_flow)[e] - excess); |
676 |
|
|
676 |
(*_excess)[v] += excess; |
|
677 | 677 |
excess = 0; |
678 | 678 |
goto no_more_push_2; |
679 | 679 |
} else { |
680 | 680 |
excess -= rem; |
681 |
|
|
681 |
(*_excess)[v] += rem; |
|
682 | 682 |
_flow->set(e, 0); |
683 | 683 |
} |
684 | 684 |
} else if (new_level > (*_level)[v]) { |
... | ... |
@@ -688,7 +688,7 @@ |
688 | 688 |
|
689 | 689 |
no_more_push_2: |
690 | 690 |
|
691 |
_excess |
|
691 |
(*_excess)[n] = excess; |
|
692 | 692 |
|
693 | 693 |
if (excess != 0) { |
694 | 694 |
if (new_level + 1 < _level->maxLevel()) { |
... | ... |
@@ -731,7 +731,7 @@ |
731 | 731 |
|
732 | 732 |
typename Digraph::template NodeMap<bool> reached(_graph); |
733 | 733 |
for (NodeIt n(_graph); n != INVALID; ++n) { |
734 |
reached |
|
734 |
reached[n] = (*_level)[n] < _level->maxLevel(); |
|
735 | 735 |
} |
736 | 736 |
|
737 | 737 |
_level->initStart(); |
... | ... |
@@ -739,7 +739,7 @@ |
739 | 739 |
|
740 | 740 |
std::vector<Node> queue; |
741 | 741 |
queue.push_back(_source); |
742 |
reached |
|
742 |
reached[_source] = true; |
|
743 | 743 |
|
744 | 744 |
while (!queue.empty()) { |
745 | 745 |
_level->initNewLevel(); |
... | ... |
@@ -749,7 +749,7 @@ |
749 | 749 |
for (OutArcIt e(_graph, n); e != INVALID; ++e) { |
750 | 750 |
Node v = _graph.target(e); |
751 | 751 |
if (!reached[v] && _tolerance.positive((*_flow)[e])) { |
752 |
reached |
|
752 |
reached[v] = true; |
|
753 | 753 |
_level->initAddItem(v); |
754 | 754 |
nqueue.push_back(v); |
755 | 755 |
} |
... | ... |
@@ -758,7 +758,7 @@ |
758 | 758 |
Node u = _graph.source(e); |
759 | 759 |
if (!reached[u] && |
760 | 760 |
_tolerance.positive((*_capacity)[e] - (*_flow)[e])) { |
761 |
reached |
|
761 |
reached[u] = true; |
|
762 | 762 |
_level->initAddItem(u); |
763 | 763 |
nqueue.push_back(u); |
764 | 764 |
} |
... | ... |
@@ -792,12 +792,12 @@ |
792 | 792 |
} |
793 | 793 |
if (!_tolerance.less(rem, excess)) { |
794 | 794 |
_flow->set(e, (*_flow)[e] + excess); |
795 |
|
|
795 |
(*_excess)[v] += excess; |
|
796 | 796 |
excess = 0; |
797 | 797 |
goto no_more_push; |
798 | 798 |
} else { |
799 | 799 |
excess -= rem; |
800 |
|
|
800 |
(*_excess)[v] += rem; |
|
801 | 801 |
_flow->set(e, (*_capacity)[e]); |
802 | 802 |
} |
803 | 803 |
} else if (new_level > (*_level)[v]) { |
... | ... |
@@ -815,12 +815,12 @@ |
815 | 815 |
} |
816 | 816 |
if (!_tolerance.less(rem, excess)) { |
817 | 817 |
_flow->set(e, (*_flow)[e] - excess); |
818 |
|
|
818 |
(*_excess)[v] += excess; |
|
819 | 819 |
excess = 0; |
820 | 820 |
goto no_more_push; |
821 | 821 |
} else { |
822 | 822 |
excess -= rem; |
823 |
|
|
823 |
(*_excess)[v] += rem; |
|
824 | 824 |
_flow->set(e, 0); |
825 | 825 |
} |
826 | 826 |
} else if (new_level > (*_level)[v]) { |
... | ... |
@@ -830,7 +830,7 @@ |
830 | 830 |
|
831 | 831 |
no_more_push: |
832 | 832 |
|
833 |
_excess |
|
833 |
(*_excess)[n] = excess; |
|
834 | 834 |
|
835 | 835 |
if (excess != 0) { |
836 | 836 |
if (new_level + 1 < _level->maxLevel()) { |
... | ... |
@@ -99,16 +99,16 @@ |
99 | 99 |
check(kruskal(G, edge_cost_map, tree_map)==10, |
100 | 100 |
"Total cost should be 10"); |
101 | 101 |
|
102 |
edge_cost_map.set(e1, -10); |
|
103 |
edge_cost_map.set(e2, -9); |
|
104 |
edge_cost_map.set(e3, -8); |
|
105 |
edge_cost_map.set(e4, -7); |
|
106 |
edge_cost_map.set(e5, -6); |
|
107 |
edge_cost_map.set(e6, -5); |
|
108 |
edge_cost_map.set(e7, -4); |
|
109 |
edge_cost_map.set(e8, -3); |
|
110 |
edge_cost_map.set(e9, -2); |
|
111 |
edge_cost_map.set(e10, -1); |
|
102 |
edge_cost_map[e1] = -10; |
|
103 |
edge_cost_map[e2] = -9; |
|
104 |
edge_cost_map[e3] = -8; |
|
105 |
edge_cost_map[e4] = -7; |
|
106 |
edge_cost_map[e5] = -6; |
|
107 |
edge_cost_map[e6] = -5; |
|
108 |
edge_cost_map[e7] = -4; |
|
109 |
edge_cost_map[e8] = -3; |
|
110 |
edge_cost_map[e9] = -2; |
|
111 |
edge_cost_map[e10] = -1; |
|
112 | 112 |
|
113 | 113 |
vector<Edge> tree_edge_vec(5); |
114 | 114 |
|
0 comments (0 inline)