gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Merge
0 1 0
merge default
0 files changed with 2 insertions and 0 deletions:
↑ Collapse diff ↑
Show white space 48 line context
... ...
@@ -577,51 +577,53 @@
577 577
      int n = _nodes->size();
578 578
      LargeValue length;
579 579
      int size;
580 580
      Node u;
581 581
      
582 582
      // Search for cycles that are already found
583 583
      _curr_found = false;
584 584
      for (int i = 0; i < n; ++i) {
585 585
        u = (*_nodes)[i];
586 586
        if (_data[u][k].dist == INF) continue;
587 587
        for (int j = k; j >= 0; --j) {
588 588
          if (level[u].first == i && level[u].second > 0) {
589 589
            // A cycle is found
590 590
            length = _data[u][level[u].second].dist - _data[u][j].dist;
591 591
            size = level[u].second - j;
592 592
            if (!_curr_found || length * _curr_size < _curr_length * size) {
593 593
              _curr_length = length;
594 594
              _curr_size = size;
595 595
              _curr_node = u;
596 596
              _curr_level = level[u].second;
597 597
              _curr_found = true;
598 598
            }
599 599
          }
600 600
          level[u] = Pair(i, j);
601
          if (j != 0) {
601 602
          u = _gr.source(_data[u][j].pred);
602 603
        }
603 604
      }
605
      }
604 606

	
605 607
      // If at least one cycle is found, check the optimality condition
606 608
      LargeValue d;
607 609
      if (_curr_found && k < n) {
608 610
        // Find node potentials
609 611
        for (int i = 0; i < n; ++i) {
610 612
          u = (*_nodes)[i];
611 613
          pi[u] = INF;
612 614
          for (int j = 0; j <= k; ++j) {
613 615
            if (_data[u][j].dist < INF) {
614 616
              d = _data[u][j].dist * _curr_size - j * _curr_length;
615 617
              if (_tolerance.less(d, pi[u])) pi[u] = d;
616 618
            }
617 619
          }
618 620
        }
619 621

	
620 622
        // Check the optimality condition for all arcs
621 623
        bool done = true;
622 624
        for (ArcIt a(_gr); a != INVALID; ++a) {
623 625
          if (_tolerance.less(_length[a] * _curr_size - _curr_length,
624 626
                              pi[_gr.target(a)] - pi[_gr.source(a)]) ) {
625 627
            done = false;
626 628
            break;
627 629
          }
0 comments (0 inline)