Changeset 581:aa1804409f29 in lemon-main
- Timestamp:
- 04/14/09 10:35:38 (16 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/circulation.h
r559 r581 454 454 455 455 for(NodeIt n(_g);n!=INVALID;++n) { 456 _excess->set(n, (*_delta)[n]);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 … … 483 483 484 484 for(NodeIt n(_g);n!=INVALID;++n) { 485 _excess->set(n, (*_delta)[n]);485 (*_excess)[n] = (*_delta)[n]; 486 486 } 487 487 … … 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 } … … 538 538 if(!_tol.less(fc, exc)) { 539 539 _flow->set(e, (*_flow)[e] + exc); 540 _excess->set(v, (*_excess)[v] + exc);540 (*_excess)[v] += exc; 541 541 if(!_level->active(v) && _tol.positive((*_excess)[v])) 542 542 _level->activate(v); 543 _excess->set(act,0);543 (*_excess)[act] = 0; 544 544 _level->deactivate(act); 545 545 goto next_l; … … 547 547 else { 548 548 _flow->set(e, (*_up)[e]); 549 _excess->set(v, (*_excess)[v] + fc);549 (*_excess)[v] += fc; 550 550 if(!_level->active(v) && _tol.positive((*_excess)[v])) 551 551 _level->activate(v); … … 562 562 if(!_tol.less(fc, exc)) { 563 563 _flow->set(e, (*_flow)[e] - exc); 564 _excess->set(v, (*_excess)[v] + exc);564 (*_excess)[v] += exc; 565 565 if(!_level->active(v) && _tol.positive((*_excess)[v])) 566 566 _level->activate(v); 567 _excess->set(act,0);567 (*_excess)[act] = 0; 568 568 _level->deactivate(act); 569 569 goto next_l; … … 571 571 else { 572 572 _flow->set(e, (*_lo)[e]); 573 _excess->set(v, (*_excess)[v] + fc);573 (*_excess)[v] += fc; 574 574 if(!_level->active(v) && _tol.positive((*_excess)[v])) 575 575 _level->activate(v); … … 580 580 } 581 581 582 _excess->set(act, exc);582 (*_excess)[act] = exc; 583 583 if(!_tol.positive(exc)) _level->deactivate(act); 584 584 else if(mlevel==_node_num) { -
lemon/core.h
r559 r581 1316 1316 virtual void clear() { 1317 1317 for(NodeIt n(_g);n!=INVALID;++n) { 1318 _head .set(n, INVALID);1318 _head[n] = INVALID; 1319 1319 } 1320 1320 } … … 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 } … … 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; … … 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; … … 1358 1358 if (_left[arc] == INVALID) { 1359 1359 if (_right[arc] != INVALID) { 1360 _parent .set(_right[arc], _parent[arc]);1360 _parent[_right[arc]] = _parent[arc]; 1361 1361 } 1362 1362 if (_parent[arc] != INVALID) { 1363 1363 if (_left[_parent[arc]] == arc) { 1364 _left .set(_parent[arc], _right[arc]);1364 _left[_parent[arc]] = _right[arc]; 1365 1365 } else { 1366 _right .set(_parent[arc], _right[arc]);1366 _right[_parent[arc]] = _right[arc]; 1367 1367 } 1368 1368 } else { 1369 _head .set(_g.source(arc), _right[arc]);1369 _head[_g.source(arc)] = _right[arc]; 1370 1370 } 1371 1371 } else if (_right[arc] == INVALID) { 1372 _parent .set(_left[arc], _parent[arc]);1372 _parent[_left[arc]] = _parent[arc]; 1373 1373 if (_parent[arc] != INVALID) { 1374 1374 if (_left[_parent[arc]] == arc) { 1375 _left .set(_parent[arc], _left[arc]);1375 _left[_parent[arc]] = _left[arc]; 1376 1376 } else { 1377 _right .set(_parent[arc], _left[arc]);1377 _right[_parent[arc]] = _left[arc]; 1378 1378 } 1379 1379 } else { 1380 _head .set(_g.source(arc), _left[arc]);1380 _head[_g.source(arc)] = _left[arc]; 1381 1381 } 1382 1382 } else { … … 1388 1388 } 1389 1389 Arc s = _parent[e]; 1390 _right .set(_parent[e], _left[e]);1390 _right[_parent[e]] = _left[e]; 1391 1391 if (_left[e] != INVALID) { 1392 _parent .set(_left[e], _parent[e]);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);1399 1400 _parent .set(e, _parent[arc]);1395 _left[e] = _left[arc]; 1396 _parent[_left[arc]] = e; 1397 _right[e] = _right[arc]; 1398 _parent[_right[arc]] = e; 1399 1400 _parent[e] = _parent[arc]; 1401 1401 if (_parent[arc] != INVALID) { 1402 1402 if (_left[_parent[arc]] == arc) { 1403 _left .set(_parent[arc], e);1403 _left[_parent[arc]] = e; 1404 1404 } else { 1405 _right .set(_parent[arc], e);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 _parent .set(e, _parent[arc]);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 .set(_parent[arc], e);1416 _left[_parent[arc]] = e; 1417 1417 } else { 1418 _right .set(_parent[arc], e);1418 _right[_parent[arc]] = e; 1419 1419 } 1420 1420 } else { 1421 _head .set(_g.source(arc), e);1421 _head[_g.source(arc)] = e; 1422 1422 } 1423 1423 } … … 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 .set(me, INVALID);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 .set(me, INVALID);1443 _right[me] = INVALID; 1444 1444 } 1445 1445 return me; … … 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);1457 } 1458 else _head .set(n, INVALID);1455 _head[n] = head; 1456 _parent[head] = INVALID; 1457 } 1458 else _head[n] = INVALID; 1459 1459 } 1460 1460 } … … 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 .set(_parent[v], v);1470 _right[_parent[v]] = v; 1471 1471 } else { 1472 _left .set(_parent[v], v);1472 _left[_parent[v]] = v; 1473 1473 } 1474 1474 } 1475 1475 if (_left[w] != INVALID){ 1476 _parent .set(_left[w], w);1476 _parent[_left[w]] = w; 1477 1477 } 1478 1478 } … … 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 .set(_parent[v], v);1488 _left[_parent[v]] = v; 1489 1489 } else { 1490 _right .set(_parent[v], v);1490 _right[_parent[v]] = v; 1491 1491 } 1492 1492 } 1493 1493 if (_right[w] != INVALID){ 1494 _parent .set(_right[w], w);1494 _parent[_right[w]] = w; 1495 1495 } 1496 1496 } -
lemon/elevator.h
r559 r581 77 77 void copy(Item i, Vit p) 78 78 { 79 _where .set(*p=i,p);79 _where[*p=i] = p; 80 80 } 81 81 void copy(Vit s, Vit p) … … 85 85 Item i=*s; 86 86 *p=i; 87 _where .set(i,p);87 _where[i] = p; 88 88 } 89 89 } … … 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 } … … 227 227 { 228 228 Item it = *_last_active[_highest_active]; 229 _level.set(it,_level[it]+1);229 ++_level[it]; 230 230 swap(_last_active[_highest_active]--,_last_active[_highest_active+1]); 231 231 --_first[++_highest_active]; … … 250 250 } 251 251 copy(li,_first[new_level]); 252 _level .set(li,new_level);252 _level[li] = new_level; 253 253 _highest_active=new_level; 254 254 } … … 270 270 copy(li,_first[_max_level]); 271 271 --_last_active[_max_level]; 272 _level .set(li,_max_level);272 _level[li] = _max_level; 273 273 274 274 while(_highest_active>=0 && … … 300 300 { 301 301 Item it =*_last_active[level]; 302 _level.set(it,_level[it]+1);302 ++_level[it]; 303 303 swap(_last_active[level]--, --_first[level+1]); 304 304 if (level+1>_highest_active) ++_highest_active; … … 320 320 } 321 321 copy(ai,_first[new_level]); 322 _level .set(ai,new_level);322 _level[ai] = new_level; 323 323 if (new_level>_highest_active) _highest_active=new_level; 324 324 } … … 340 340 copy(ai,_first[_max_level]); 341 341 --_last_active[_max_level]; 342 _level .set(ai,_max_level);342 _level[ai] = _max_level; 343 343 344 344 if (_highest_active==level) { … … 371 371 } 372 372 copy(i,_first[new_level]); 373 _level .set(i,new_level);373 _level[i] = new_level; 374 374 if(new_level>_highest_active) _highest_active=new_level; 375 375 } … … 383 383 ///\pre The item is on the top level. 384 384 void dirtyTopButOne(Item i) { 385 _level .set(i,_max_level - 1);385 _level[i] = _max_level - 1; 386 386 } 387 387 … … 395 395 const Vit tl=_first[_max_level]; 396 396 for(Vit i=f;i!=tl;++i) 397 _level .set(*i,_max_level);397 _level[*i] = _max_level; 398 398 for(int i=l;i<=_max_level;i++) 399 399 { … … 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 } … … 444 444 { 445 445 swap(_where[i],_init_num); 446 _level .set(i,_init_lev);446 _level[i] = _init_lev; 447 447 ++_init_num; 448 448 } … … 552 552 ///\pre Item \c i shouldn't be active before. 553 553 void activate(Item i) { 554 _active .set(i, true);554 _active[i] = true; 555 555 556 556 int level = _level[i]; … … 561 561 if (_prev[i] == INVALID || _active[_prev[i]]) return; 562 562 //unlace 563 _next .set(_prev[i], _next[i]);563 _next[_prev[i]] = _next[i]; 564 564 if (_next[i] != INVALID) { 565 _prev .set(_next[i], _prev[i]);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 _prev .set(i, INVALID);570 _next[i] = _first[level]; 571 _prev[_first[level]] = i; 572 _prev[i] = INVALID; 573 573 _first[level] = i; 574 574 … … 580 580 ///\pre Item \c i must be active before. 581 581 void deactivate(Item i) { 582 _active .set(i, false);582 _active[i] = false; 583 583 int level = _level[i]; 584 584 … … 587 587 588 588 //unlace 589 _prev .set(_next[i], _prev[i]);589 _prev[_next[i]] = _prev[i]; 590 590 if (_prev[i] != INVALID) { 591 _next .set(_prev[i], _next[i]);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 _next .set(i, INVALID);596 _prev[i] = _last[level]; 597 _next[_last[level]] = i; 598 _next[i] = INVALID; 599 599 _last[level] = i; 600 600 … … 686 686 Item i = _first[_highest_active]; 687 687 if (_next[i] != INVALID) { 688 _prev .set(_next[i], INVALID);688 _prev[_next[i]] = INVALID; 689 689 _first[_highest_active] = _next[i]; 690 690 } else { … … 692 692 _last[_highest_active] = INVALID; 693 693 } 694 _level .set(i, ++_highest_active);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);700 } else { 701 _prev .set(_first[_highest_active], i);702 _next .set(i, _first[_highest_active]);698 _prev[i] = INVALID; 699 _next[i] = INVALID; 700 } else { 701 _prev[_first[_highest_active]] = i; 702 _next[i] = _first[_highest_active]; 703 703 _first[_highest_active] = i; 704 704 } … … 715 715 Item i = _first[_highest_active]; 716 716 if (_next[i] != INVALID) { 717 _prev .set(_next[i], INVALID);717 _prev[_next[i]] = INVALID; 718 718 _first[_highest_active] = _next[i]; 719 719 } else { … … 721 721 _last[_highest_active] = INVALID; 722 722 } 723 _level .set(i, _highest_active = new_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);728 } else { 729 _prev .set(_first[_highest_active], i);730 _next .set(i, _first[_highest_active]);726 _prev[i] = INVALID; 727 _next[i] = INVALID; 728 } else { 729 _prev[_first[_highest_active]] = i; 730 _next[i] = _first[_highest_active]; 731 731 _first[_highest_active] = i; 732 732 } … … 739 739 void liftHighestActiveToTop() { 740 740 Item i = _first[_highest_active]; 741 _level .set(i, _max_level);741 _level[i] = _max_level; 742 742 if (_next[i] != INVALID) { 743 _prev .set(_next[i], INVALID);743 _prev[_next[i]] = INVALID; 744 744 _first[_highest_active] = _next[i]; 745 745 } else { … … 775 775 Item i = _first[l]; 776 776 if (_next[i] != INVALID) { 777 _prev .set(_next[i], INVALID);777 _prev[_next[i]] = INVALID; 778 778 _first[l] = _next[i]; 779 779 } else { … … 781 781 _last[l] = INVALID; 782 782 } 783 _level .set(i, ++l);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);788 } else { 789 _prev .set(_first[l], i);790 _next .set(i, _first[l]);786 _prev[i] = INVALID; 787 _next[i] = INVALID; 788 } else { 789 _prev[_first[l]] = i; 790 _next[i] = _first[l]; 791 791 _first[l] = i; 792 792 } … … 804 804 Item i = _first[l]; 805 805 if (_next[i] != INVALID) { 806 _prev .set(_next[i], INVALID);806 _prev[_next[i]] = INVALID; 807 807 _first[l] = _next[i]; 808 808 } else { … … 810 810 _last[l] = INVALID; 811 811 } 812 _level .set(i, l = new_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);817 } else { 818 _prev .set(_first[l], i);819 _next .set(i, _first[l]);815 _prev[i] = INVALID; 816 _next[i] = INVALID; 817 } else { 818 _prev[_first[l]] = i; 819 _next[i] = _first[l]; 820 820 _first[l] = i; 821 821 } … … 833 833 Item i = _first[l]; 834 834 if (_next[i] != INVALID) { 835 _prev .set(_next[i], INVALID);835 _prev[_next[i]] = INVALID; 836 836 _first[l] = _next[i]; 837 837 } else { … … 839 839 _last[l] = INVALID; 840 840 } 841 _level .set(i, _max_level);841 _level[i] = _max_level; 842 842 if (l == _highest_active) { 843 843 while (_highest_active >= 0 && activeFree(_highest_active)) … … 857 857 void lift(Item i, int new_level) { 858 858 if (_next[i] != INVALID) { 859 _prev .set(_next[i], _prev[i]);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 .set(_prev[i], _next[i]);864 _next[_prev[i]] = _next[i]; 865 865 } else { 866 866 _first[new_level] = _next[i]; 867 867 } 868 _level .set(i, new_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);873 } else { 874 _prev .set(_first[new_level], i);875 _next .set(i, _first[new_level]);871 _prev[i] = INVALID; 872 _next[i] = INVALID; 873 } else { 874 _prev[_first[new_level]] = i; 875 _next[i] = _first[new_level]; 876 876 _first[new_level] = i; 877 877 } … … 889 889 ///\pre The item is on the top level. 890 890 void dirtyTopButOne(Item i) { 891 _level .set(i, _max_level - 1);891 _level[i] = _max_level - 1; 892 892 } 893 893 … … 900 900 Item n = _first[i]; 901 901 while (n != INVALID) { 902 _level .set(n, _max_level);902 _level[n] = _max_level; 903 903 n = _next[n]; 904 904 } … … 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 } … … 945 945 ///Add an item to the current level. 946 946 void initAddItem(Item i) { 947 _level .set(i, _init_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);953 } else { 954 _prev .set(i, _last[_init_level]);955 _next .set(i, INVALID);956 _next .set(_last[_init_level], i);951 _prev[i] = INVALID; 952 _next[i] = INVALID; 953 } else { 954 _prev[i] = _last[_init_level]; 955 _next[i] = INVALID; 956 _next[_last[_init_level]] = i; 957 957 _last[_init_level] = i; 958 958 } -
lemon/gomory_hu.h
r546 r581 144 144 _root = NodeIt(_graph); 145 145 for (NodeIt n(_graph); n != INVALID; ++n) { 146 _pred->set(n, _root);147 _order->set(n, -1);148 } 149 _pred->set(_root, INVALID);150 _weight->set(_root, std::numeric_limits<Value>::max());146 (*_pred)[n] = _root; 147 (*_order)[n] = -1; 148 } 149 (*_pred)[_root] = INVALID; 150 (*_weight)[_root] = std::numeric_limits<Value>::max(); 151 151 } 152 152 … … 165 165 fa.runMinCut(); 166 166 167 _weight->set(n, fa.flowValue());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->set(nn, n);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());179 } 180 } 181 182 _order->set(_root, 0);175 (*_pred)[n] = (*_pred)[pn]; 176 (*_pred)[pn] = n; 177 (*_weight)[n] = (*_weight)[pn]; 178 (*_weight)[pn] = fa.flowValue(); 179 } 180 } 181 182 (*_order)[_root] = 0; 183 183 int index = 1; 184 184 … … 191 191 } 192 192 while (!st.empty()) { 193 _order->set(st.back(), index++);193 (*_order)[st.back()] = index++; 194 194 st.pop_back(); 195 195 } … … 310 310 311 311 typename Graph::template NodeMap<bool> reached(_graph, false); 312 reached .set(_root, true);312 reached[_root] = true; 313 313 cutMap.set(_root, !s_root); 314 reached .set(rn, true);314 reached[rn] = true; 315 315 cutMap.set(rn, s_root); 316 316 -
lemon/hao_orlin.h
r559 r581 162 162 163 163 void activate(const Node& i) { 164 _active->set(i, true);164 (*_active)[i] = true; 165 165 166 166 int bucket = (*_bucket)[i]; … … 168 168 if ((*_prev)[i] == INVALID || (*_active)[(*_prev)[i]]) return; 169 169 //unlace 170 _next->set((*_prev)[i], (*_next)[i]);170 (*_next)[(*_prev)[i]] = (*_next)[i]; 171 171 if ((*_next)[i] != INVALID) { 172 _prev->set((*_next)[i], (*_prev)[i]);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 _prev->set(i, INVALID);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->set(i, false);184 (*_active)[i] = false; 185 185 int bucket = (*_bucket)[i]; 186 186 … … 188 188 189 189 //unlace 190 _prev->set((*_next)[i], (*_prev)[i]);190 (*_prev)[(*_next)[i]] = (*_prev)[i]; 191 191 if ((*_prev)[i] != INVALID) { 192 _next->set((*_prev)[i], (*_next)[i]);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 _next->set(i, INVALID);197 (*_prev)[i] = _last[bucket]; 198 (*_next)[_last[bucket]] = i; 199 (*_next)[i] = INVALID; 200 200 _last[bucket] = i; 201 201 } … … 204 204 (*_bucket)[i] = bucket; 205 205 if (_last[bucket] != INVALID) { 206 _prev->set(i, _last[bucket]);207 _next->set(_last[bucket], i);208 _next->set(i, INVALID);206 (*_prev)[i] = _last[bucket]; 207 (*_next)[_last[bucket]] = i; 208 (*_next)[i] = INVALID; 209 209 _last[bucket] = i; 210 210 } else { 211 _prev->set(i, INVALID);211 (*_prev)[i] = INVALID; 212 212 _first[bucket] = i; 213 _next->set(i, INVALID);213 (*_next)[i] = INVALID; 214 214 _last[bucket] = i; 215 215 } … … 219 219 220 220 for (NodeIt n(_graph); n != INVALID; ++n) { 221 _excess->set(n, 0);221 (*_excess)[n] = 0; 222 222 } 223 223 224 224 for (ArcIt a(_graph); a != INVALID; ++a) { 225 _flow->set(a, 0);225 (*_flow)[a] = 0; 226 226 } 227 227 … … 233 233 typename Digraph::template NodeMap<bool> reached(_graph, false); 234 234 235 reached .set(_source, true);235 reached[_source] = true; 236 236 bool first_set = true; 237 237 … … 241 241 242 242 queue[qlast++] = t; 243 reached .set(t, true);243 reached[t] = true; 244 244 245 245 while (qfirst != qlast) { … … 258 258 Node u = _graph.source(a); 259 259 if (!reached[u] && _tolerance.positive((*_capacity)[a])) { 260 reached .set(u, true);260 reached[u] = true; 261 261 queue[qlast++] = u; 262 262 } … … 267 267 268 268 ++bucket_num; 269 _bucket->set(_source, 0);269 (*_bucket)[_source] = 0; 270 270 _dormant[0] = true; 271 271 } 272 _source_set->set(_source, true);272 (*_source_set)[_source] = true; 273 273 274 274 Node target = _last[_sets.back().back()]; … … 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); … … 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]) { … … 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]) { … … 359 359 no_more_push: 360 360 361 _excess->set(n, excess);361 (*_excess)[n] = excess; 362 362 363 363 if (excess != 0) { … … 377 377 } else if (next_bucket == _node_num) { 378 378 _first[(*_bucket)[n]] = (*_next)[n]; 379 _prev->set((*_next)[n], INVALID);379 (*_prev)[(*_next)[n]] = INVALID; 380 380 381 381 std::list<std::list<int> >::iterator new_set = … … 383 383 384 384 new_set->push_front(bucket_num); 385 _bucket->set(n, bucket_num);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; … … 396 396 } else { 397 397 _first[*_highest] = (*_next)[n]; 398 _prev->set((*_next)[n], INVALID);398 (*_prev)[(*_next)[n]] = INVALID; 399 399 400 400 while (next_bucket != *_highest) { … … 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->set(_first[*_highest], n);415 (*_prev)[_first[*_highest]] = n; 416 416 } else { 417 417 _last[*_highest] = n; … … 435 435 _min_cut = (*_excess)[target]; 436 436 for (NodeIt i(_graph); i != INVALID; ++i) { 437 _min_cut_map->set(i, true);437 (*_min_cut_map)[i] = true; 438 438 } 439 439 for (std::list<int>::iterator it = _sets.back().begin(); … … 441 441 Node n = _first[*it]; 442 442 while (n != INVALID) { 443 _min_cut_map->set(n, false);443 (*_min_cut_map)[n] = false; 444 444 n = (*_next)[n]; 445 445 } … … 454 454 new_target = (*_prev)[target]; 455 455 } else { 456 _prev->set((*_next)[target], (*_prev)[target]);456 (*_prev)[(*_next)[target]] = (*_prev)[target]; 457 457 new_target = (*_next)[target]; 458 458 } … … 460 460 _first[(*_bucket)[target]] = (*_next)[target]; 461 461 } else { 462 _next->set((*_prev)[target], (*_next)[target]);462 (*_next)[(*_prev)[target]] = (*_next)[target]; 463 463 } 464 464 } else { … … 476 476 } 477 477 478 _bucket->set(target, 0);479 480 _source_set->set(target, true);478 (*_bucket)[target] = 0; 479 480 (*_source_set)[target] = true; 481 481 for (OutArcIt a(_graph, target); a != INVALID; ++a) { 482 482 Value rem = (*_capacity)[a] - (*_flow)[a]; … … 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 … … 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 … … 518 518 519 519 for (NodeIt n(_graph); n != INVALID; ++n) { 520 _excess->set(n, 0);520 (*_excess)[n] = 0; 521 521 } 522 522 523 523 for (ArcIt a(_graph); a != INVALID; ++a) { 524 _flow->set(a, 0);524 (*_flow)[a] = 0; 525 525 } 526 526 … … 532 532 typename Digraph::template NodeMap<bool> reached(_graph, false); 533 533 534 reached .set(_source, true);534 reached[_source] = true; 535 535 536 536 bool first_set = true; … … 541 541 542 542 queue[qlast++] = t; 543 reached .set(t, true);543 reached[t] = true; 544 544 545 545 while (qfirst != qlast) { … … 558 558 Node u = _graph.target(a); 559 559 if (!reached[u] && _tolerance.positive((*_capacity)[a])) { 560 reached .set(u, true);560 reached[u] = true; 561 561 queue[qlast++] = u; 562 562 } … … 567 567 568 568 ++bucket_num; 569 _bucket->set(_source, 0);569 (*_bucket)[_source] = 0; 570 570 _dormant[0] = true; 571 571 } 572 _source_set->set(_source, true);572 (*_source_set)[_source] = true; 573 573 574 574 Node target = _last[_sets.back().back()]; … … 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); … … 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]) { … … 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]) { … … 659 659 no_more_push: 660 660 661 _excess->set(n, excess);661 (*_excess)[n] = excess; 662 662 663 663 if (excess != 0) { … … 677 677 } else if (next_bucket == _node_num) { 678 678 _first[(*_bucket)[n]] = (*_next)[n]; 679 _prev->set((*_next)[n], INVALID);679 (*_prev)[(*_next)[n]] = INVALID; 680 680 681 681 std::list<std::list<int> >::iterator new_set = … … 683 683 684 684 new_set->push_front(bucket_num); 685 _bucket->set(n, bucket_num);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; … … 696 696 } else { 697 697 _first[*_highest] = (*_next)[n]; 698 _prev->set((*_next)[n], INVALID);698 (*_prev)[(*_next)[n]] = INVALID; 699 699 700 700 while (next_bucket != *_highest) { … … 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->set(_first[*_highest], n);714 (*_prev)[_first[*_highest]] = n; 715 715 } else { 716 716 _last[*_highest] = n; … … 734 734 _min_cut = (*_excess)[target]; 735 735 for (NodeIt i(_graph); i != INVALID; ++i) { 736 _min_cut_map->set(i, false);736 (*_min_cut_map)[i] = false; 737 737 } 738 738 for (std::list<int>::iterator it = _sets.back().begin(); … … 740 740 Node n = _first[*it]; 741 741 while (n != INVALID) { 742 _min_cut_map->set(n, true);742 (*_min_cut_map)[n] = true; 743 743 n = (*_next)[n]; 744 744 } … … 753 753 new_target = (*_prev)[target]; 754 754 } else { 755 _prev->set((*_next)[target], (*_prev)[target]);755 (*_prev)[(*_next)[target]] = (*_prev)[target]; 756 756 new_target = (*_next)[target]; 757 757 } … … 759 759 _first[(*_bucket)[target]] = (*_next)[target]; 760 760 } else { 761 _next->set((*_prev)[target], (*_next)[target]);761 (*_next)[(*_prev)[target]] = (*_next)[target]; 762 762 } 763 763 } else { … … 775 775 } 776 776 777 _bucket->set(target, 0);778 779 _source_set->set(target, true);777 (*_bucket)[target] = 0; 778 779 (*_source_set)[target] = true; 780 780 for (InArcIt a(_graph, target); a != INVALID; ++a) { 781 781 Value rem = (*_capacity)[a] - (*_flow)[a]; … … 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 … … 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 -
lemon/max_matching.h
r559 r581 283 283 284 284 while (base != nca) { 285 _ear->set(node, arc);285 (*_ear)[node] = arc; 286 286 287 287 Node n = node; … … 290 290 Arc a = (*_ear)[n]; 291 291 n = _graph.target(a); 292 _ear->set(n, _graph.oppositeArc(a));292 (*_ear)[n] = _graph.oppositeArc(a); 293 293 } 294 294 node = _graph.target((*_matching)[base]); … … 296 296 _tree_set->erase(node); 297 297 _blossom_set->insert(node, _blossom_set->find(base)); 298 _status->set(node, EVEN);298 (*_status)[node] = EVEN; 299 299 _node_queue[_last++] = node; 300 300 arc = _graph.oppositeArc((*_ear)[node]); … … 305 305 } 306 306 307 _blossom_rep->set(_blossom_set->find(nca), nca);307 (*_blossom_rep)[_blossom_set->find(nca)] = nca; 308 308 309 309 { … … 314 314 315 315 while (base != nca) { 316 _ear->set(node, arc);316 (*_ear)[node] = arc; 317 317 318 318 Node n = node; … … 321 321 Arc a = (*_ear)[n]; 322 322 n = _graph.target(a); 323 _ear->set(n, _graph.oppositeArc(a));323 (*_ear)[n] = _graph.oppositeArc(a); 324 324 } 325 325 node = _graph.target((*_matching)[base]); … … 327 327 _tree_set->erase(node); 328 328 _blossom_set->insert(node, _blossom_set->find(base)); 329 _status->set(node, EVEN);329 (*_status)[node] = EVEN; 330 330 _node_queue[_last++] = node; 331 331 arc = _graph.oppositeArc((*_ear)[node]); … … 336 336 } 337 337 338 _blossom_rep->set(_blossom_set->find(nca), nca);338 (*_blossom_rep)[_blossom_set->find(nca)] = nca; 339 339 } 340 340 … … 345 345 Node odd = _graph.target(a); 346 346 347 _ear->set(odd, _graph.oppositeArc(a));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 _status->set(even, EVEN);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); … … 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->set(even, a);369 (*_matching)[even] = a; 370 370 371 371 while (arc != INVALID) { … … 373 373 arc = (*_ear)[odd]; 374 374 even = _graph.target(arc); 375 _matching->set(odd, arc);375 (*_matching)[odd] = arc; 376 376 arc = (*_matching)[even]; 377 _matching->set(even, _graph.oppositeArc((*_matching)[odd]));377 (*_matching)[even] = _graph.oppositeArc((*_matching)[odd]); 378 378 } 379 379 … … 381 381 it != INVALID; ++it) { 382 382 if ((*_status)[it] == ODD) { 383 _status->set(it, MATCHED);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->set(jt, MATCHED);388 (*_status)[jt] = MATCHED; 389 389 } 390 390 _blossom_set->eraseClass(blossom); … … 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 } … … 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) { … … 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 } … … 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) { … … 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 } … … 498 498 (*_blossom_rep)[_blossom_set->insert(n)] = n; 499 499 _tree_set->insert(n); 500 _status->set(n, EVEN);500 (*_status)[n] = EVEN; 501 501 processSparse(n); 502 502 } … … 513 513 (*_blossom_rep)[_blossom_set->insert(n)] = n; 514 514 _tree_set->insert(n); 515 _status->set(n, EVEN);515 (*_status)[n] = EVEN; 516 516 processDense(n); 517 517 } … … 1549 1549 Value pot = (*_node_data)[bi].pot; 1550 1550 1551 _matching->set(base, matching);1551 (*_matching)[base] = matching; 1552 1552 _blossom_node_list.push_back(base); 1553 _node_potential->set(base, pot);1553 (*_node_potential)[base] = pot; 1554 1554 } else { 1555 1555 … … 1645 1645 1646 1646 for (ArcIt e(_graph); e != INVALID; ++e) { 1647 _node_heap_index->set(e, BinHeap<Value, IntArcMap>::PRE_HEAP);1647 (*_node_heap_index)[e] = BinHeap<Value, IntArcMap>::PRE_HEAP; 1648 1648 } 1649 1649 for (NodeIt n(_graph); n != INVALID; ++n) { 1650 _delta1_index->set(n, _delta1->PRE_HEAP);1650 (*_delta1_index)[n] = _delta1->PRE_HEAP; 1651 1651 } 1652 1652 for (EdgeIt e(_graph); e != INVALID; ++e) { 1653 _delta3_index->set(e, _delta3->PRE_HEAP);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 … … 1667 1667 } 1668 1668 } 1669 _node_index->set(n, index);1669 (*_node_index)[n] = index; 1670 1670 (*_node_data)[index].pot = max; 1671 1671 _delta1->push(n, max); … … 2742 2742 Value pot = (*_node_data)[bi].pot; 2743 2743 2744 _matching->set(base, matching);2744 (*_matching)[base] = matching; 2745 2745 _blossom_node_list.push_back(base); 2746 _node_potential->set(base, pot);2746 (*_node_potential)[base] = pot; 2747 2747 } else { 2748 2748 … … 2832 2832 2833 2833 for (ArcIt e(_graph); e != INVALID; ++e) { 2834 _node_heap_index->set(e, BinHeap<Value, IntArcMap>::PRE_HEAP);2834 (*_node_heap_index)[e] = BinHeap<Value, IntArcMap>::PRE_HEAP; 2835 2835 } 2836 2836 for (EdgeIt e(_graph); e != INVALID; ++e) { 2837 _delta3_index->set(e, _delta3->PRE_HEAP);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 … … 2851 2851 } 2852 2852 } 2853 _node_index->set(n, index);2853 (*_node_index)[n] = index; 2854 2854 (*_node_data)[index].pot = max; 2855 2855 int blossom = -
lemon/min_cost_arborescence.h
r559 r581 294 294 } 295 295 } 296 _arc_order->set(minimum.arc, _dual_variables.size());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); … … 336 336 } 337 337 } 338 _arc_order->set(minimum.arc, _dual_variables.size());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); … … 365 365 Node source = _heap->top(); 366 366 _heap->pop(); 367 _node_order->set(source, -1);367 (*_node_order)[source] = -1; 368 368 for (OutArcIt it(*_digraph, source); it != INVALID; ++it) { 369 369 if ((*_arc_order)[it] < 0) continue; … … 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->set(it, -1);659 (*_arc_order)[it] = -1; 660 660 } 661 661 _dual_node_list.clear(); -
lemon/preflow.h
r559 r581 405 405 _phase = true; 406 406 for (NodeIt n(_graph); n != INVALID; ++n) { 407 _excess->set(n, 0);407 (*_excess)[n] = 0; 408 408 } 409 409 … … 418 418 419 419 std::vector<Node> queue; 420 reached .set(_source, true);420 reached[_source] = true; 421 421 422 422 queue.push_back(_target); 423 reached .set(_target, true);423 reached[_target] = true; 424 424 while (!queue.empty()) { 425 425 _level->initNewLevel(); … … 430 430 Node u = _graph.source(e); 431 431 if (!reached[u] && _tolerance.positive((*_capacity)[e])) { 432 reached .set(u, true);432 reached[u] = true; 433 433 _level->initAddItem(u); 434 434 nqueue.push_back(u); … … 445 445 if ((*_level)[u] == _level->maxLevel()) continue; 446 446 _flow->set(e, (*_capacity)[e]); 447 _excess->set(u, (*_excess)[u] + (*_capacity)[e]);447 (*_excess)[u] += (*_capacity)[e]; 448 448 if (u != _target && !_level->active(u)) { 449 449 _level->activate(u); … … 479 479 } 480 480 if (excess < 0 && n != _source) return false; 481 _excess->set(n, excess);481 (*_excess)[n] = excess; 482 482 } 483 483 … … 488 488 489 489 std::vector<Node> queue; 490 reached .set(_source, true);490 reached[_source] = true; 491 491 492 492 queue.push_back(_target); 493 reached .set(_target, true);493 reached[_target] = true; 494 494 while (!queue.empty()) { 495 495 _level->initNewLevel(); … … 501 501 if (!reached[u] && 502 502 _tolerance.positive((*_capacity)[e] - (*_flow)[e])) { 503 reached .set(u, true);503 reached[u] = true; 504 504 _level->initAddItem(u); 505 505 nqueue.push_back(u); … … 509 509 Node v = _graph.target(e); 510 510 if (!reached[v] && _tolerance.positive((*_flow)[e])) { 511 reached .set(v, true);511 reached[v] = true; 512 512 _level->initAddItem(v); 513 513 nqueue.push_back(v); … … 525 525 if ((*_level)[u] == _level->maxLevel()) continue; 526 526 _flow->set(e, (*_capacity)[e]); 527 _excess->set(u, (*_excess)[u] + rem);527 (*_excess)[u] += rem; 528 528 if (u != _target && !_level->active(u)) { 529 529 _level->activate(u); … … 537 537 if ((*_level)[v] == _level->maxLevel()) continue; 538 538 _flow->set(e, 0); 539 _excess->set(v, (*_excess)[v] + rem);539 (*_excess)[v] += rem; 540 540 if (v != _target && !_level->active(v)) { 541 541 _level->activate(v); … … 578 578 if (!_tolerance.less(rem, excess)) { 579 579 _flow->set(e, (*_flow)[e] + excess); 580 _excess->set(v, (*_excess)[v] + excess);580 (*_excess)[v] += excess; 581 581 excess = 0; 582 582 goto no_more_push_1; 583 583 } else { 584 584 excess -= rem; 585 _excess->set(v, (*_excess)[v] + rem);585 (*_excess)[v] += rem; 586 586 _flow->set(e, (*_capacity)[e]); 587 587 } … … 601 601 if (!_tolerance.less(rem, excess)) { 602 602 _flow->set(e, (*_flow)[e] - excess); 603 _excess->set(v, (*_excess)[v] + excess);603 (*_excess)[v] += excess; 604 604 excess = 0; 605 605 goto no_more_push_1; 606 606 } else { 607 607 excess -= rem; 608 _excess->set(v, (*_excess)[v] + rem);608 (*_excess)[v] += rem; 609 609 _flow->set(e, 0); 610 610 } … … 616 616 no_more_push_1: 617 617 618 _excess->set(n, excess);618 (*_excess)[n] = excess; 619 619 620 620 if (excess != 0) { … … 651 651 if (!_tolerance.less(rem, excess)) { 652 652 _flow->set(e, (*_flow)[e] + excess); 653 _excess->set(v, (*_excess)[v] + excess);653 (*_excess)[v] += excess; 654 654 excess = 0; 655 655 goto no_more_push_2; 656 656 } else { 657 657 excess -= rem; 658 _excess->set(v, (*_excess)[v] + rem);658 (*_excess)[v] += rem; 659 659 _flow->set(e, (*_capacity)[e]); 660 660 } … … 674 674 if (!_tolerance.less(rem, excess)) { 675 675 _flow->set(e, (*_flow)[e] - excess); 676 _excess->set(v, (*_excess)[v] + excess);676 (*_excess)[v] += excess; 677 677 excess = 0; 678 678 goto no_more_push_2; 679 679 } else { 680 680 excess -= rem; 681 _excess->set(v, (*_excess)[v] + rem);681 (*_excess)[v] += rem; 682 682 _flow->set(e, 0); 683 683 } … … 689 689 no_more_push_2: 690 690 691 _excess->set(n, excess);691 (*_excess)[n] = excess; 692 692 693 693 if (excess != 0) { … … 732 732 typename Digraph::template NodeMap<bool> reached(_graph); 733 733 for (NodeIt n(_graph); n != INVALID; ++n) { 734 reached .set(n, (*_level)[n] < _level->maxLevel());734 reached[n] = (*_level)[n] < _level->maxLevel(); 735 735 } 736 736 … … 740 740 std::vector<Node> queue; 741 741 queue.push_back(_source); 742 reached .set(_source, true);742 reached[_source] = true; 743 743 744 744 while (!queue.empty()) { … … 750 750 Node v = _graph.target(e); 751 751 if (!reached[v] && _tolerance.positive((*_flow)[e])) { 752 reached .set(v, true);752 reached[v] = true; 753 753 _level->initAddItem(v); 754 754 nqueue.push_back(v); … … 759 759 if (!reached[u] && 760 760 _tolerance.positive((*_capacity)[e] - (*_flow)[e])) { 761 reached .set(u, true);761 reached[u] = true; 762 762 _level->initAddItem(u); 763 763 nqueue.push_back(u); … … 793 793 if (!_tolerance.less(rem, excess)) { 794 794 _flow->set(e, (*_flow)[e] + excess); 795 _excess->set(v, (*_excess)[v] + excess);795 (*_excess)[v] += excess; 796 796 excess = 0; 797 797 goto no_more_push; 798 798 } else { 799 799 excess -= rem; 800 _excess->set(v, (*_excess)[v] + rem);800 (*_excess)[v] += rem; 801 801 _flow->set(e, (*_capacity)[e]); 802 802 } … … 816 816 if (!_tolerance.less(rem, excess)) { 817 817 _flow->set(e, (*_flow)[e] - excess); 818 _excess->set(v, (*_excess)[v] + excess);818 (*_excess)[v] += excess; 819 819 excess = 0; 820 820 goto no_more_push; 821 821 } else { 822 822 excess -= rem; 823 _excess->set(v, (*_excess)[v] + rem);823 (*_excess)[v] += rem; 824 824 _flow->set(e, 0); 825 825 } … … 831 831 no_more_push: 832 832 833 _excess->set(n, excess);833 (*_excess)[n] = excess; 834 834 835 835 if (excess != 0) { -
test/kruskal_test.cc
r440 r581 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);
Note: See TracChangeset
for help on using the changeset viewer.