Modify the implementation of ListDigraph::ArcIt (#311)
authorPeter Kovacs <kpeter@inf.elte.hu>
Mon, 28 Sep 2009 12:48:44 +0200 (2009-09-28)
changeset 73932baeb8e5c8f
parent 687 fb93895f84d9
child 741 10c9c3a35b83
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.
lemon/list_graph.h
     1.1 --- a/lemon/list_graph.h	Thu Aug 20 22:52:16 2009 +0200
     1.2 +++ b/lemon/list_graph.h	Mon Sep 28 12:48:44 2009 +0200
     1.3 @@ -116,20 +116,20 @@
     1.4      void first(Arc& arc) const {
     1.5        int n;
     1.6        for(n = first_node;
     1.7 -          n!=-1 && nodes[n].first_in == -1;
     1.8 +          n != -1 && nodes[n].first_out == -1;
     1.9            n = nodes[n].next) {}
    1.10 -      arc.id = (n == -1) ? -1 : nodes[n].first_in;
    1.11 +      arc.id = (n == -1) ? -1 : nodes[n].first_out;
    1.12      }
    1.13  
    1.14      void next(Arc& arc) const {
    1.15 -      if (arcs[arc.id].next_in != -1) {
    1.16 -        arc.id = arcs[arc.id].next_in;
    1.17 +      if (arcs[arc.id].next_out != -1) {
    1.18 +        arc.id = arcs[arc.id].next_out;
    1.19        } else {
    1.20          int n;
    1.21 -        for(n = nodes[arcs[arc.id].target].next;
    1.22 -            n!=-1 && nodes[n].first_in == -1;
    1.23 +        for(n = nodes[arcs[arc.id].source].next;
    1.24 +            n != -1 && nodes[n].first_out == -1;
    1.25              n = nodes[n].next) {}
    1.26 -        arc.id = (n == -1) ? -1 : nodes[n].first_in;
    1.27 +        arc.id = (n == -1) ? -1 : nodes[n].first_out;
    1.28        }
    1.29      }
    1.30