gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
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.
0 1 0
default
1 file changed with 7 insertions and 7 deletions:
↑ Collapse diff ↑
Ignore white space 24 line context
... ...
@@ -107,38 +107,38 @@
107 107
    void first(Node& node) const {
108 108
      node.id = first_node;
109 109
    }
110 110

	
111 111
    void next(Node& node) const {
112 112
      node.id = nodes[node.id].next;
113 113
    }
114 114

	
115 115

	
116 116
    void first(Arc& arc) const {
117 117
      int n;
118 118
      for(n = first_node;
119
          n!=-1 && nodes[n].first_in == -1;
119
          n != -1 && nodes[n].first_out == -1;
120 120
          n = nodes[n].next) {}
121
      arc.id = (n == -1) ? -1 : nodes[n].first_in;
121
      arc.id = (n == -1) ? -1 : nodes[n].first_out;
122 122
    }
123 123

	
124 124
    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;
127 127
      } else {
128 128
        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;
131 131
            n = nodes[n].next) {}
132
        arc.id = (n == -1) ? -1 : nodes[n].first_in;
132
        arc.id = (n == -1) ? -1 : nodes[n].first_out;
133 133
      }
134 134
    }
135 135

	
136 136
    void firstOut(Arc &e, const Node& v) const {
137 137
      e.id = nodes[v.id].first_out;
138 138
    }
139 139
    void nextOut(Arc &e) const {
140 140
      e.id=arcs[e.id].next_out;
141 141
    }
142 142

	
143 143
    void firstIn(Arc &e, const Node& v) const {
144 144
      e.id = nodes[v.id].first_in;
0 comments (0 inline)