COIN-OR::LEMON - Graph Library

Ticket #309: 309-listdigraph-arcit-c6157e490d8c.patch

File 309-listdigraph-arcit-c6157e490d8c.patch, 1.5 KB (added by Peter Kovacs, 15 years ago)
  • lemon/list_graph.h

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1250599376 -7200
    # Node ID c6157e490d8c52ec14e1b57c14e0df59d450eccd
    # Parent  9f529abcaebf13f19e61ba24fdd2c3631860af91
    Modify the implementation of ListDigraph::ArcIt (#309)
    
    The new implementation is based on out-arc iteration (like
    ListGraph::ArcIt) instead of in-arc iteration. It could be
    better if the outgoing arcs of the nodes were added to the
    graph near to each other, which seems to be a typical case.
    
    diff --git a/lemon/list_graph.h b/lemon/list_graph.h
    a b  
    116116    void first(Arc& arc) const {
    117117      int n;
    118118      for(n = first_node;
    119           n!=-1 && nodes[n].first_in == -1;
     119          n != -1 && nodes[n].first_out == -1;
    120120          n = nodes[n].next) {}
    121       arc.id = (n == -1) ? -1 : nodes[n].first_in;
     121      arc.id = (n == -1) ? -1 : nodes[n].first_out;
    122122    }
    123123
    124124    void next(Arc& arc) const {
    125       if (arcs[arc.id].next_in != -1) {
    126         arc.id = arcs[arc.id].next_in;
     125      if (arcs[arc.id].next_out != -1) {
     126        arc.id = arcs[arc.id].next_out;
    127127      } else {
    128128        int n;
    129         for(n = nodes[arcs[arc.id].target].next;
    130             n!=-1 && nodes[n].first_in == -1;
     129        for(n = nodes[arcs[arc.id].source].next;
     130            n != -1 && nodes[n].first_out == -1;
    131131            n = nodes[n].next) {}
    132         arc.id = (n == -1) ? -1 : nodes[n].first_in;
     132        arc.id = (n == -1) ? -1 : nodes[n].first_out;
    133133      }
    134134    }
    135135