equal
deleted
inserted
replaced
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 |