[948] | 1 | /* -*- C++ -*- |
---|
| 2 | * src/lemon/list_graph.h - Part of LEMON, a generic C++ optimization library |
---|
| 3 | * |
---|
| 4 | * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
---|
| 5 | * (Egervary Combinatorial Optimization Research Group, EGRES). |
---|
| 6 | * |
---|
| 7 | * Permission to use, modify and distribute this software is granted |
---|
| 8 | * provided that this copyright notice appears in all copies. For |
---|
| 9 | * precise terms see the accompanying LICENSE file. |
---|
| 10 | * |
---|
| 11 | * This software is provided "AS IS" with no warranty of any kind, |
---|
| 12 | * express or implied, and with no claim as to its suitability for any |
---|
| 13 | * purpose. |
---|
| 14 | * |
---|
| 15 | */ |
---|
[395] | 16 | |
---|
[921] | 17 | #ifndef LEMON_LIST_GRAPH_H |
---|
| 18 | #define LEMON_LIST_GRAPH_H |
---|
[395] | 19 | |
---|
[948] | 20 | ///\ingroup graphs |
---|
| 21 | ///\file |
---|
| 22 | ///\brief ListGraph, SymListGraph, NodeSet and EdgeSet classes. |
---|
| 23 | |
---|
[946] | 24 | #include <lemon/erasable_graph_extender.h> |
---|
| 25 | #include <lemon/clearable_graph_extender.h> |
---|
| 26 | #include <lemon/extendable_graph_extender.h> |
---|
[395] | 27 | |
---|
[946] | 28 | #include <lemon/iterable_graph_extender.h> |
---|
[395] | 29 | |
---|
[946] | 30 | #include <lemon/alteration_observer_registry.h> |
---|
[782] | 31 | |
---|
[946] | 32 | #include <lemon/default_map.h> |
---|
[782] | 33 | |
---|
[1011] | 34 | #include <list> |
---|
[782] | 35 | |
---|
[921] | 36 | namespace lemon { |
---|
[395] | 37 | |
---|
[946] | 38 | class ListGraphBase { |
---|
[406] | 39 | |
---|
[949] | 40 | protected: |
---|
[946] | 41 | struct NodeT { |
---|
[397] | 42 | int first_in,first_out; |
---|
| 43 | int prev, next; |
---|
[395] | 44 | }; |
---|
[946] | 45 | |
---|
| 46 | struct EdgeT { |
---|
[986] | 47 | int target, source; |
---|
[397] | 48 | int prev_in, prev_out; |
---|
| 49 | int next_in, next_out; |
---|
[395] | 50 | }; |
---|
| 51 | |
---|
| 52 | std::vector<NodeT> nodes; |
---|
[946] | 53 | |
---|
[397] | 54 | int first_node; |
---|
[946] | 55 | |
---|
[397] | 56 | int first_free_node; |
---|
[946] | 57 | |
---|
[395] | 58 | std::vector<EdgeT> edges; |
---|
[946] | 59 | |
---|
[397] | 60 | int first_free_edge; |
---|
[395] | 61 | |
---|
[782] | 62 | public: |
---|
[395] | 63 | |
---|
[946] | 64 | typedef ListGraphBase Graph; |
---|
[397] | 65 | |
---|
[946] | 66 | class Node { |
---|
[975] | 67 | friend class ListGraphBase; |
---|
[946] | 68 | protected: |
---|
[395] | 69 | |
---|
[946] | 70 | int id; |
---|
| 71 | Node(int pid) { id = pid;} |
---|
[395] | 72 | |
---|
[946] | 73 | public: |
---|
| 74 | Node() {} |
---|
| 75 | Node (Invalid) { id = -1; } |
---|
| 76 | bool operator==(const Node& node) const {return id == node.id;} |
---|
| 77 | bool operator!=(const Node& node) const {return id != node.id;} |
---|
| 78 | bool operator<(const Node& node) const {return id < node.id;} |
---|
| 79 | }; |
---|
[782] | 80 | |
---|
[946] | 81 | class Edge { |
---|
[975] | 82 | friend class ListGraphBase; |
---|
[946] | 83 | protected: |
---|
[782] | 84 | |
---|
[946] | 85 | int id; |
---|
| 86 | Edge(int pid) { id = pid;} |
---|
[395] | 87 | |
---|
[946] | 88 | public: |
---|
| 89 | Edge() {} |
---|
| 90 | Edge (Invalid) { id = -1; } |
---|
| 91 | bool operator==(const Edge& edge) const {return id == edge.id;} |
---|
| 92 | bool operator!=(const Edge& edge) const {return id != edge.id;} |
---|
| 93 | bool operator<(const Edge& edge) const {return id < edge.id;} |
---|
| 94 | }; |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | ListGraphBase() |
---|
[782] | 99 | : nodes(), first_node(-1), |
---|
| 100 | first_free_node(-1), edges(), first_free_edge(-1) {} |
---|
| 101 | |
---|
[395] | 102 | |
---|
[813] | 103 | /// Maximum node ID. |
---|
| 104 | |
---|
| 105 | /// Maximum node ID. |
---|
| 106 | ///\sa id(Node) |
---|
[980] | 107 | int maxId(Node = INVALID) const { return nodes.size()-1; } |
---|
[946] | 108 | |
---|
[813] | 109 | /// Maximum edge ID. |
---|
| 110 | |
---|
| 111 | /// Maximum edge ID. |
---|
| 112 | ///\sa id(Edge) |
---|
[980] | 113 | int maxId(Edge = INVALID) const { return edges.size()-1; } |
---|
[395] | 114 | |
---|
[986] | 115 | Node source(Edge e) const { return edges[e.id].source; } |
---|
| 116 | Node target(Edge e) const { return edges[e.id].target; } |
---|
[395] | 117 | |
---|
| 118 | |
---|
[946] | 119 | void first(Node& node) const { |
---|
| 120 | node.id = first_node; |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | void next(Node& node) const { |
---|
| 124 | node.id = nodes[node.id].next; |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | |
---|
| 128 | void first(Edge& e) const { |
---|
| 129 | int n; |
---|
| 130 | for(n = first_node; |
---|
| 131 | n!=-1 && nodes[n].first_in == -1; |
---|
| 132 | n = nodes[n].next); |
---|
| 133 | e.id = (n == -1) ? -1 : nodes[n].first_in; |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | void next(Edge& edge) const { |
---|
| 137 | if (edges[edge.id].next_in != -1) { |
---|
| 138 | edge.id = edges[edge.id].next_in; |
---|
| 139 | } else { |
---|
| 140 | int n; |
---|
[986] | 141 | for(n = nodes[edges[edge.id].target].next; |
---|
[946] | 142 | n!=-1 && nodes[n].first_in == -1; |
---|
| 143 | n = nodes[n].next); |
---|
| 144 | edge.id = (n == -1) ? -1 : nodes[n].first_in; |
---|
| 145 | } |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | void firstOut(Edge &e, const Node& v) const { |
---|
| 149 | e.id = nodes[v.id].first_out; |
---|
| 150 | } |
---|
| 151 | void nextOut(Edge &e) const { |
---|
| 152 | e.id=edges[e.id].next_out; |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | void firstIn(Edge &e, const Node& v) const { |
---|
| 156 | e.id = nodes[v.id].first_in; |
---|
| 157 | } |
---|
| 158 | void nextIn(Edge &e) const { |
---|
| 159 | e.id=edges[e.id].next_in; |
---|
| 160 | } |
---|
| 161 | |
---|
[813] | 162 | |
---|
[946] | 163 | static int id(Node v) { return v.id; } |
---|
| 164 | static int id(Edge e) { return e.id; } |
---|
[395] | 165 | |
---|
[397] | 166 | /// Adds a new node to the graph. |
---|
| 167 | |
---|
[813] | 168 | /// \warning It adds the new node to the front of the list. |
---|
[397] | 169 | /// (i.e. the lastly added node becomes the first.) |
---|
[946] | 170 | Node addNode() { |
---|
[397] | 171 | int n; |
---|
| 172 | |
---|
[946] | 173 | if(first_free_node==-1) { |
---|
| 174 | n = nodes.size(); |
---|
| 175 | nodes.push_back(NodeT()); |
---|
| 176 | } else { |
---|
[397] | 177 | n = first_free_node; |
---|
| 178 | first_free_node = nodes[n].next; |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | nodes[n].next = first_node; |
---|
| 182 | if(first_node != -1) nodes[first_node].prev = n; |
---|
| 183 | first_node = n; |
---|
| 184 | nodes[n].prev = -1; |
---|
| 185 | |
---|
| 186 | nodes[n].first_in = nodes[n].first_out = -1; |
---|
| 187 | |
---|
[946] | 188 | return Node(n); |
---|
[395] | 189 | } |
---|
| 190 | |
---|
| 191 | Edge addEdge(Node u, Node v) { |
---|
[946] | 192 | int n; |
---|
| 193 | |
---|
| 194 | if (first_free_edge == -1) { |
---|
| 195 | n = edges.size(); |
---|
| 196 | edges.push_back(EdgeT()); |
---|
| 197 | } else { |
---|
[397] | 198 | n = first_free_edge; |
---|
| 199 | first_free_edge = edges[n].next_in; |
---|
| 200 | } |
---|
| 201 | |
---|
[986] | 202 | edges[n].source = u.id; |
---|
| 203 | edges[n].target = v.id; |
---|
[395] | 204 | |
---|
[946] | 205 | edges[n].next_out = nodes[u.id].first_out; |
---|
| 206 | if(nodes[u.id].first_out != -1) { |
---|
| 207 | edges[nodes[u.id].first_out].prev_out = n; |
---|
| 208 | } |
---|
| 209 | |
---|
| 210 | edges[n].next_in = nodes[v.id].first_in; |
---|
| 211 | if(nodes[v.id].first_in != -1) { |
---|
| 212 | edges[nodes[v.id].first_in].prev_in = n; |
---|
| 213 | } |
---|
| 214 | |
---|
[397] | 215 | edges[n].prev_in = edges[n].prev_out = -1; |
---|
| 216 | |
---|
[946] | 217 | nodes[u.id].first_out = nodes[v.id].first_in = n; |
---|
[397] | 218 | |
---|
[946] | 219 | return Edge(n); |
---|
[395] | 220 | } |
---|
[774] | 221 | |
---|
[946] | 222 | void erase(const Node& node) { |
---|
| 223 | int n = node.id; |
---|
| 224 | |
---|
| 225 | if(nodes[n].next != -1) { |
---|
| 226 | nodes[nodes[n].next].prev = nodes[n].prev; |
---|
| 227 | } |
---|
| 228 | |
---|
| 229 | if(nodes[n].prev != -1) { |
---|
| 230 | nodes[nodes[n].prev].next = nodes[n].next; |
---|
| 231 | } else { |
---|
| 232 | first_node = nodes[n].next; |
---|
| 233 | } |
---|
| 234 | |
---|
| 235 | nodes[n].next = first_free_node; |
---|
| 236 | first_free_node = n; |
---|
[395] | 237 | |
---|
[774] | 238 | } |
---|
| 239 | |
---|
[946] | 240 | void erase(const Edge& edge) { |
---|
| 241 | int n = edge.id; |
---|
[397] | 242 | |
---|
[946] | 243 | if(edges[n].next_in!=-1) { |
---|
[397] | 244 | edges[edges[n].next_in].prev_in = edges[n].prev_in; |
---|
[946] | 245 | } |
---|
| 246 | |
---|
| 247 | if(edges[n].prev_in!=-1) { |
---|
[397] | 248 | edges[edges[n].prev_in].next_in = edges[n].next_in; |
---|
[946] | 249 | } else { |
---|
[986] | 250 | nodes[edges[n].target].first_in = edges[n].next_in; |
---|
[946] | 251 | } |
---|
| 252 | |
---|
[397] | 253 | |
---|
[946] | 254 | if(edges[n].next_out!=-1) { |
---|
[397] | 255 | edges[edges[n].next_out].prev_out = edges[n].prev_out; |
---|
[946] | 256 | } |
---|
| 257 | |
---|
| 258 | if(edges[n].prev_out!=-1) { |
---|
[397] | 259 | edges[edges[n].prev_out].next_out = edges[n].next_out; |
---|
[946] | 260 | } else { |
---|
[986] | 261 | nodes[edges[n].source].first_out = edges[n].next_out; |
---|
[946] | 262 | } |
---|
[397] | 263 | |
---|
| 264 | edges[n].next_in = first_free_edge; |
---|
[695] | 265 | first_free_edge = n; |
---|
[397] | 266 | |
---|
| 267 | } |
---|
| 268 | |
---|
| 269 | void clear() { |
---|
[782] | 270 | edges.clear(); |
---|
| 271 | nodes.clear(); |
---|
[946] | 272 | first_node = first_free_node = first_free_edge = -1; |
---|
[937] | 273 | } |
---|
| 274 | |
---|
[949] | 275 | protected: |
---|
[986] | 276 | void _moveTarget(Edge e, Node n) |
---|
[949] | 277 | { |
---|
| 278 | if(edges[e.id].next_in != -1) |
---|
| 279 | edges[edges[e.id].next_in].prev_in = edges[e.id].prev_in; |
---|
| 280 | if(edges[e.id].prev_in != -1) |
---|
| 281 | edges[edges[e.id].prev_in].next_in = edges[e.id].next_in; |
---|
[986] | 282 | else nodes[edges[e.id].target].first_in = edges[e.id].next_in; |
---|
| 283 | edges[e.id].target = n.id; |
---|
[949] | 284 | edges[e.id].prev_in = -1; |
---|
| 285 | edges[e.id].next_in = nodes[n.id].first_in; |
---|
| 286 | nodes[n.id].first_in = e.id; |
---|
| 287 | } |
---|
[986] | 288 | void _moveSource(Edge e, Node n) |
---|
[949] | 289 | { |
---|
| 290 | if(edges[e.id].next_out != -1) |
---|
| 291 | edges[edges[e.id].next_out].prev_out = edges[e.id].prev_out; |
---|
| 292 | if(edges[e.id].prev_out != -1) |
---|
| 293 | edges[edges[e.id].prev_out].next_out = edges[e.id].next_out; |
---|
[986] | 294 | else nodes[edges[e.id].source].first_out = edges[e.id].next_out; |
---|
| 295 | edges[e.id].source = n.id; |
---|
[949] | 296 | edges[e.id].prev_out = -1; |
---|
| 297 | edges[e.id].next_out = nodes[n.id].first_out; |
---|
| 298 | nodes[n.id].first_out = e.id; |
---|
| 299 | } |
---|
| 300 | |
---|
[919] | 301 | }; |
---|
[909] | 302 | |
---|
[946] | 303 | typedef AlterableGraphExtender<ListGraphBase> AlterableListGraphBase; |
---|
| 304 | typedef IterableGraphExtender<AlterableListGraphBase> IterableListGraphBase; |
---|
[980] | 305 | typedef DefaultMappableGraphExtender<IterableListGraphBase> MappableListGraphBase; |
---|
[946] | 306 | typedef ExtendableGraphExtender<MappableListGraphBase> ExtendableListGraphBase; |
---|
| 307 | typedef ClearableGraphExtender<ExtendableListGraphBase> ClearableListGraphBase; |
---|
| 308 | typedef ErasableGraphExtender<ClearableListGraphBase> ErasableListGraphBase; |
---|
[400] | 309 | |
---|
[948] | 310 | /// \addtogroup graphs |
---|
| 311 | /// @{ |
---|
[400] | 312 | |
---|
[948] | 313 | ///A list graph class. |
---|
[400] | 314 | |
---|
[948] | 315 | ///This is a simple and fast erasable graph implementation. |
---|
| 316 | /// |
---|
[1010] | 317 | ///It addition that it conforms to the |
---|
| 318 | ///\ref concept::ErasableGraph "ErasableGraph" concept, |
---|
| 319 | ///it also provides several additional useful extra functionalities. |
---|
[959] | 320 | ///\sa concept::ErasableGraph. |
---|
[782] | 321 | |
---|
[948] | 322 | class ListGraph : public ErasableListGraphBase |
---|
| 323 | { |
---|
| 324 | public: |
---|
[986] | 325 | /// Moves the target of \c e to \c n |
---|
[948] | 326 | |
---|
[986] | 327 | /// Moves the target of \c e to \c n |
---|
[948] | 328 | /// |
---|
[1010] | 329 | ///\note The <tt>Edge</tt>'s and <tt>OutEdge</tt>'s |
---|
| 330 | ///referencing the moved edge remain |
---|
| 331 | ///valid. However <tt>InEdge</tt>'s are invalidated. |
---|
[986] | 332 | void moveTarget(Edge e, Node n) { _moveTarget(e,n); } |
---|
| 333 | /// Moves the source of \c e to \c n |
---|
[948] | 334 | |
---|
[986] | 335 | /// Moves the source of \c e to \c n |
---|
[948] | 336 | /// |
---|
[1010] | 337 | ///\note The <tt>Edge</tt>'s and <tt>InEdge</tt>'s |
---|
| 338 | ///referencing the moved edge remain |
---|
| 339 | ///valid. However <tt>OutEdge</tt>'s are invalidated. |
---|
[986] | 340 | void moveSource(Edge e, Node n) { _moveSource(e,n); } |
---|
[949] | 341 | |
---|
[1010] | 342 | /// Invert the direction of an edge. |
---|
| 343 | |
---|
| 344 | ///\note The <tt>Edge</tt>'s |
---|
| 345 | ///referencing the moved edge remain |
---|
| 346 | ///valid. However <tt>OutEdge</tt>'s and <tt>InEdge</tt>'s are invalidated. |
---|
| 347 | void reverseEdge(Edge e) { |
---|
| 348 | Node t=target(e); |
---|
| 349 | _moveTarget(e,source(e)); |
---|
| 350 | _moveSource(e,t); |
---|
| 351 | } |
---|
| 352 | |
---|
| 353 | ///Using this it possible to avoid the superfluous memory allocation. |
---|
| 354 | |
---|
[949] | 355 | ///Using this it possible to avoid the superfluous memory allocation. |
---|
| 356 | ///\todo more docs... |
---|
| 357 | void reserveEdge(int n) { edges.reserve(n); }; |
---|
[1010] | 358 | |
---|
| 359 | ///Contract two nodes. |
---|
| 360 | |
---|
| 361 | ///This function contracts two nodes. |
---|
| 362 | /// |
---|
| 363 | ///Node \p b will be removed but instead of deleting |
---|
| 364 | ///its neighboring edges, they will be joined to \p a. |
---|
| 365 | ///The last parameter \p r controls whether to remove loops. \c true |
---|
| 366 | ///means that loops will be removed. |
---|
| 367 | /// |
---|
| 368 | ///\note The <tt>Edge</tt>s |
---|
| 369 | ///referencing the moved edge remain |
---|
| 370 | ///valid. However <tt>InEdge</tt>'s and <tt>OutEdge</tt>'s |
---|
| 371 | ///may be invalidated. |
---|
| 372 | void contract(Node a,Node b,bool r=true) |
---|
| 373 | { |
---|
| 374 | for(OutEdgeIt e(*this,b);e!=INVALID;) { |
---|
| 375 | OutEdgeIt f=e; |
---|
| 376 | ++f; |
---|
| 377 | if(r && target(e)==a) erase(e); |
---|
| 378 | else moveSource(e,b); |
---|
| 379 | e=f; |
---|
| 380 | } |
---|
| 381 | for(InEdgeIt e(*this,b);e!=INVALID;) { |
---|
| 382 | InEdgeIt f=e; |
---|
| 383 | ++f; |
---|
| 384 | if(r && source(e)==a) erase(e); |
---|
| 385 | else moveTarget(e,b); |
---|
| 386 | e=f; |
---|
| 387 | } |
---|
| 388 | erase(b); |
---|
| 389 | } |
---|
[1011] | 390 | |
---|
| 391 | |
---|
| 392 | ///Class to make a snapshot of the graph and to restrore to it later. |
---|
| 393 | |
---|
| 394 | ///Class to make a snapshot of the graph and to restrore to it later. |
---|
| 395 | /// |
---|
| 396 | ///The newly added nodes and edges can be removed using the |
---|
| 397 | ///restore() function. |
---|
| 398 | /// |
---|
| 399 | ///\warning Edge and node deletions cannot be restored. |
---|
| 400 | ///\warning SnapShots cannot be nested. |
---|
| 401 | ///\ingroup graphs |
---|
[1012] | 402 | class SnapShot : protected AlterationObserverRegistry<Node>::ObserverBase, |
---|
| 403 | protected AlterationObserverRegistry<Edge>::ObserverBase |
---|
[1011] | 404 | { |
---|
| 405 | protected: |
---|
| 406 | |
---|
| 407 | ListGraph *g; |
---|
| 408 | std::list<Node> added_nodes; |
---|
| 409 | std::list<Edge> added_edges; |
---|
| 410 | |
---|
| 411 | bool active; |
---|
| 412 | virtual void add(const Node& n) { |
---|
| 413 | added_nodes.push_back(n); |
---|
| 414 | }; |
---|
| 415 | ///\bug Exception... |
---|
| 416 | /// |
---|
| 417 | virtual void erase(const Node&) |
---|
| 418 | { |
---|
| 419 | exit(1); |
---|
| 420 | } |
---|
| 421 | virtual void add(const Edge& n) { |
---|
| 422 | added_edges.push_back(n); |
---|
| 423 | }; |
---|
| 424 | ///\bug Exception... |
---|
| 425 | /// |
---|
| 426 | virtual void erase(const Edge&) |
---|
| 427 | { |
---|
| 428 | exit(1); |
---|
| 429 | } |
---|
| 430 | |
---|
| 431 | void regist(ListGraph &_g) { |
---|
| 432 | g=&_g; |
---|
| 433 | AlterationObserverRegistry<Node>::ObserverBase:: |
---|
| 434 | attach(g->node_observers); |
---|
| 435 | AlterationObserverRegistry<Edge>::ObserverBase:: |
---|
| 436 | attach(g->edge_observers); |
---|
| 437 | } |
---|
| 438 | |
---|
| 439 | void deregist() { |
---|
| 440 | AlterationObserverRegistry<Node>::ObserverBase:: |
---|
| 441 | detach(); |
---|
| 442 | AlterationObserverRegistry<Edge>::ObserverBase:: |
---|
| 443 | detach(); |
---|
| 444 | g=0; |
---|
| 445 | } |
---|
| 446 | |
---|
| 447 | public: |
---|
| 448 | ///Default constructur. |
---|
| 449 | |
---|
| 450 | ///Default constructur. |
---|
| 451 | ///To actually make a snapshot you must call save(). |
---|
| 452 | /// |
---|
| 453 | SnapShot() : g(0) {} |
---|
| 454 | ///Constructor that immediately makes a snapshot. |
---|
| 455 | |
---|
| 456 | ///This constructor immediately makes a snapshot of the graph. |
---|
| 457 | ///\param _g The graph we make a snapshot of. |
---|
| 458 | SnapShot(ListGraph &_g) { |
---|
| 459 | regist(_g); |
---|
| 460 | } |
---|
| 461 | ///\bug Is it necessary? |
---|
| 462 | /// |
---|
| 463 | ~SnapShot() |
---|
| 464 | { |
---|
| 465 | if(g) deregist(); |
---|
| 466 | } |
---|
| 467 | |
---|
| 468 | ///Make a snapshot. |
---|
| 469 | |
---|
| 470 | ///Make a snapshot of the graph. |
---|
| 471 | /// |
---|
| 472 | ///This function can be called more than once. In case of a repeated |
---|
| 473 | ///call, the previous snapshot gets lost. |
---|
| 474 | ///\param _g The graph we make the snapshot of. |
---|
| 475 | void save(ListGraph &_g) |
---|
| 476 | { |
---|
| 477 | if(g!=&_g) { |
---|
| 478 | if(g) deregist(); |
---|
| 479 | regist(_g); |
---|
| 480 | } |
---|
| 481 | added_nodes.clear(); |
---|
| 482 | added_edges.clear(); |
---|
| 483 | } |
---|
| 484 | |
---|
| 485 | ///Undo the changes until the last snapshot. |
---|
| 486 | |
---|
| 487 | ///Undo the changes until last snapshot created by save(). |
---|
| 488 | /// |
---|
| 489 | ///\todo This function might be called undo(). |
---|
| 490 | void restore() { |
---|
| 491 | deregist(); |
---|
| 492 | while(!added_edges.empty()) { |
---|
| 493 | g->erase(added_edges.front()); |
---|
| 494 | added_edges.pop_front(); |
---|
| 495 | } |
---|
| 496 | while(!added_nodes.empty()) { |
---|
| 497 | g->erase(added_nodes.front()); |
---|
| 498 | added_nodes.pop_front(); |
---|
| 499 | } |
---|
| 500 | } |
---|
| 501 | }; |
---|
| 502 | |
---|
[949] | 503 | }; |
---|
| 504 | |
---|
[948] | 505 | /// @} |
---|
| 506 | } //namespace lemon |
---|
[946] | 507 | |
---|
[400] | 508 | |
---|
[946] | 509 | #endif |
---|