src/work/list_graph.h
changeset 325 5fe27632f9ac
parent 304 10d035c2e81c
child 335 999eb3cd7b49
equal deleted inserted replaced
8:c8cf3f683c94 9:ba5f6ac7fe97
   231     /* default constructor */
   231     /* default constructor */
   232 
   232 
   233     ListGraph() : node_id(0), edge_id(0), _node_num(0), _edge_num(0), _first_node(0), _last_node(0) { }
   233     ListGraph() : node_id(0), edge_id(0), _node_num(0), _edge_num(0), _first_node(0), _last_node(0) { }
   234     
   234     
   235     ~ListGraph() { 
   235     ~ListGraph() { 
   236       while (first<NodeIt>().valid()) erase(first<NodeIt>());
   236       NodeIt n;
       
   237       while (this->valid(first(n))) erase(n);
       
   238       //while (first<NodeIt>().valid()) erase(first<NodeIt>());
   237     }
   239     }
   238 
   240 
   239     int nodeNum() const { return _node_num; }
   241     int nodeNum() const { return _node_num; }
   240     int edgeNum() const { return _edge_num; }
   242     int edgeNum() const { return _edge_num; }
   241 
   243 
   332     Edge addEdge(Node u, Node v) {
   334     Edge addEdge(Node u, Node v) {
   333       return Edge(_add_edge(u.node, v.node)); 
   335       return Edge(_add_edge(u.node, v.node)); 
   334     }
   336     }
   335 
   337 
   336     void erase(Node i) { 
   338     void erase(Node i) { 
   337       while (first<OutEdgeIt>(i).valid()) erase(first<OutEdgeIt>(i));
   339       { 
   338       while (first<InEdgeIt>(i).valid()) erase(first<InEdgeIt>(i));
   340 	OutEdgeIt e;
       
   341 	while (this->valid(first(e, i))) erase(e);
       
   342       }
       
   343       {
       
   344 	InEdgeIt e;
       
   345 	while (this->valid(first(e, i))) erase(e);
       
   346       }
       
   347       //while (first<OutEdgeIt>(i).valid()) erase(first<OutEdgeIt>(i));
       
   348       //while (first<InEdgeIt>(i).valid()) erase(first<InEdgeIt>(i));
   339       _delete_node(i.node); 
   349       _delete_node(i.node); 
   340     }
   350     }
   341   
   351   
   342     void erase(Edge e) { _delete_edge(e.edge); }
   352     void erase(Edge e) { _delete_edge(e.edge); }
   343 
   353