lemon/list_graph.h
changeset 2627 197e2ea11bad
parent 2553 bfced05fa852
equal deleted inserted replaced
52:b6f56f3c9df5 53:8a7fdee2ada8
   116 
   116 
   117     void first(Edge& e) const { 
   117     void first(Edge& e) const { 
   118       int n;
   118       int n;
   119       for(n = first_node; 
   119       for(n = first_node; 
   120 	  n!=-1 && nodes[n].first_in == -1; 
   120 	  n!=-1 && nodes[n].first_in == -1; 
   121 	  n = nodes[n].next);
   121 	  n = nodes[n].next) { }
   122       e.id = (n == -1) ? -1 : nodes[n].first_in;
   122       e.id = (n == -1) ? -1 : nodes[n].first_in;
   123     }
   123     }
   124 
   124 
   125     void next(Edge& edge) const {
   125     void next(Edge& edge) const {
   126       if (edges[edge.id].next_in != -1) {
   126       if (edges[edge.id].next_in != -1) {
   127 	edge.id = edges[edge.id].next_in;
   127 	edge.id = edges[edge.id].next_in;
   128       } else {
   128       } else {
   129 	int n;
   129 	int n;
   130 	for(n = nodes[edges[edge.id].target].next;
   130 	for(n = nodes[edges[edge.id].target].next;
   131 	  n!=-1 && nodes[n].first_in == -1; 
   131 	    n!=-1 && nodes[n].first_in == -1; 
   132 	  n = nodes[n].next);
   132 	    n = nodes[n].next) { }
   133 	edge.id = (n == -1) ? -1 : nodes[n].first_in;
   133 	edge.id = (n == -1) ? -1 : nodes[n].first_in;
   134       }      
   134       }      
   135     }
   135     }
   136 
   136 
   137     void firstOut(Edge &e, const Node& v) const {
   137     void firstOut(Edge &e, const Node& v) const {