lemon/list_graph.h
changeset 184 716b220697a0
parent 149 2f7ae34e1333
child 209 765619b7cbb2
equal deleted inserted replaced
4:f2f995ea1744 5:1f4723c94176
   113 
   113 
   114     void first(Arc& arc) const { 
   114     void first(Arc& arc) const { 
   115       int n;
   115       int n;
   116       for(n = first_node; 
   116       for(n = first_node; 
   117 	  n!=-1 && nodes[n].first_in == -1; 
   117 	  n!=-1 && nodes[n].first_in == -1; 
   118 	  n = nodes[n].next);
   118 	  n = nodes[n].next) {}
   119       arc.id = (n == -1) ? -1 : nodes[n].first_in;
   119       arc.id = (n == -1) ? -1 : nodes[n].first_in;
   120     }
   120     }
   121 
   121 
   122     void next(Arc& arc) const {
   122     void next(Arc& arc) const {
   123       if (arcs[arc.id].next_in != -1) {
   123       if (arcs[arc.id].next_in != -1) {
   124 	arc.id = arcs[arc.id].next_in;
   124 	arc.id = arcs[arc.id].next_in;
   125       } else {
   125       } else {
   126 	int n;
   126 	int n;
   127 	for(n = nodes[arcs[arc.id].target].next;
   127 	for(n = nodes[arcs[arc.id].target].next;
   128 	  n!=-1 && nodes[n].first_in == -1; 
   128 	    n!=-1 && nodes[n].first_in == -1; 
   129 	  n = nodes[n].next);
   129 	    n = nodes[n].next) {}
   130 	arc.id = (n == -1) ? -1 : nodes[n].first_in;
   130 	arc.id = (n == -1) ? -1 : nodes[n].first_in;
   131       }      
   131       }      
   132     }
   132     }
   133 
   133 
   134     void firstOut(Arc &e, const Node& v) const {
   134     void firstOut(Arc &e, const Node& v) const {