COIN-OR::LEMON - Graph Library

Ticket #311: 311-309-32baeb8e5c8f.patch

File 311-309-32baeb8e5c8f.patch, 1.4 KB (added by Peter Kovacs, 10 years ago)
  • lemon/list_graph.h

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1254134924 -7200
    # Node ID 32baeb8e5c8fc2cec7dd167588af17a1777b3c8b
    # Parent  fb93895f84d9050f68f4e9db6f3d70da4038be69
    Modify the implementation of ListDigraph::ArcIt (#311)
    
    The new implementation is based on out-arc iteration (like
    ListGraph::ArcIt) instead of in-arc iteration to make it
    consistent with the documentation.
    
    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