1.1 --- a/lemon/smart_graph.h Fri Oct 16 10:21:37 2009 +0200
1.2 +++ b/lemon/smart_graph.h Thu Nov 05 15:50:01 2009 +0100
1.3 @@ -2,7 +2,7 @@
1.4 *
1.5 * This file is a part of LEMON, a generic C++ optimization library.
1.6 *
1.7 - * Copyright (C) 2003-2008
1.8 + * Copyright (C) 2003-2009
1.9 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 *
1.12 @@ -32,10 +32,7 @@
1.13 namespace lemon {
1.14
1.15 class SmartDigraph;
1.16 - ///Base of SmartDigraph
1.17
1.18 - ///Base of SmartDigraph
1.19 - ///
1.20 class SmartDigraphBase {
1.21 protected:
1.22
1.23 @@ -55,7 +52,7 @@
1.24
1.25 public:
1.26
1.27 - typedef SmartDigraphBase Graph;
1.28 + typedef SmartDigraphBase Digraph;
1.29
1.30 class Node;
1.31 class Arc;
1.32 @@ -67,7 +64,7 @@
1.33 : nodes(_g.nodes), arcs(_g.arcs) { }
1.34
1.35 typedef True NodeNumTag;
1.36 - typedef True EdgeNumTag;
1.37 + typedef True ArcNumTag;
1.38
1.39 int nodeNum() const { return nodes.size(); }
1.40 int arcNum() const { return arcs.size(); }
1.41 @@ -187,32 +184,26 @@
1.42 ///
1.43 ///\brief A smart directed graph class.
1.44 ///
1.45 - ///This is a simple and fast digraph implementation.
1.46 - ///It is also quite memory efficient, but at the price
1.47 - ///that <b> it does support only limited (only stack-like)
1.48 - ///node and arc deletions</b>.
1.49 - ///It conforms to the \ref concepts::Digraph "Digraph concept" with
1.50 - ///an important extra feature that its maps are real \ref
1.51 - ///concepts::ReferenceMap "reference map"s.
1.52 + ///\ref SmartDigraph is a simple and fast digraph implementation.
1.53 + ///It is also quite memory efficient but at the price
1.54 + ///that it does not support node and arc deletion
1.55 + ///(except for the Snapshot feature).
1.56 ///
1.57 - ///\sa concepts::Digraph.
1.58 + ///This type fully conforms to the \ref concepts::Digraph "Digraph concept"
1.59 + ///and it also provides some additional functionalities.
1.60 + ///Most of its member functions and nested classes are documented
1.61 + ///only in the concept class.
1.62 + ///
1.63 + ///\sa concepts::Digraph
1.64 + ///\sa SmartGraph
1.65 class SmartDigraph : public ExtendedSmartDigraphBase {
1.66 - public:
1.67 -
1.68 typedef ExtendedSmartDigraphBase Parent;
1.69
1.70 private:
1.71 -
1.72 - ///SmartDigraph is \e not copy constructible. Use DigraphCopy() instead.
1.73 -
1.74 - ///SmartDigraph is \e not copy constructible. Use DigraphCopy() instead.
1.75 - ///
1.76 + /// Digraphs are \e not copy constructible. Use DigraphCopy instead.
1.77 SmartDigraph(const SmartDigraph &) : ExtendedSmartDigraphBase() {};
1.78 - ///\brief Assignment of SmartDigraph to another one is \e not allowed.
1.79 - ///Use DigraphCopy() instead.
1.80 -
1.81 - ///Assignment of SmartDigraph to another one is \e not allowed.
1.82 - ///Use DigraphCopy() instead.
1.83 + /// \brief Assignment of a digraph to another one is \e not allowed.
1.84 + /// Use DigraphCopy instead.
1.85 void operator=(const SmartDigraph &) {}
1.86
1.87 public:
1.88 @@ -225,79 +216,49 @@
1.89
1.90 ///Add a new node to the digraph.
1.91
1.92 - /// \return the new node.
1.93 - ///
1.94 + ///This function adds a new node to the digraph.
1.95 + ///\return The new node.
1.96 Node addNode() { return Parent::addNode(); }
1.97
1.98 ///Add a new arc to the digraph.
1.99
1.100 - ///Add a new arc to the digraph with source node \c s
1.101 + ///This function adds a new arc to the digraph with source node \c s
1.102 ///and target node \c t.
1.103 - ///\return the new arc.
1.104 - Arc addArc(const Node& s, const Node& t) {
1.105 + ///\return The new arc.
1.106 + Arc addArc(Node s, Node t) {
1.107 return Parent::addArc(s, t);
1.108 }
1.109
1.110 - /// \brief Using this it is possible to avoid the superfluous memory
1.111 - /// allocation.
1.112 -
1.113 - /// Using this it is possible to avoid the superfluous memory
1.114 - /// allocation: if you know that the digraph you want to build will
1.115 - /// be very large (e.g. it will contain millions of nodes and/or arcs)
1.116 - /// then it is worth reserving space for this amount before starting
1.117 - /// to build the digraph.
1.118 - /// \sa reserveArc
1.119 - void reserveNode(int n) { nodes.reserve(n); };
1.120 -
1.121 - /// \brief Using this it is possible to avoid the superfluous memory
1.122 - /// allocation.
1.123 -
1.124 - /// Using this it is possible to avoid the superfluous memory
1.125 - /// allocation: if you know that the digraph you want to build will
1.126 - /// be very large (e.g. it will contain millions of nodes and/or arcs)
1.127 - /// then it is worth reserving space for this amount before starting
1.128 - /// to build the digraph.
1.129 - /// \sa reserveNode
1.130 - void reserveArc(int m) { arcs.reserve(m); };
1.131 -
1.132 /// \brief Node validity check
1.133 ///
1.134 - /// This function gives back true if the given node is valid,
1.135 - /// ie. it is a real node of the graph.
1.136 + /// This function gives back \c true if the given node is valid,
1.137 + /// i.e. it is a real node of the digraph.
1.138 ///
1.139 /// \warning A removed node (using Snapshot) could become valid again
1.140 - /// when new nodes are added to the graph.
1.141 + /// if new nodes are added to the digraph.
1.142 bool valid(Node n) const { return Parent::valid(n); }
1.143
1.144 /// \brief Arc validity check
1.145 ///
1.146 - /// This function gives back true if the given arc is valid,
1.147 - /// ie. it is a real arc of the graph.
1.148 + /// This function gives back \c true if the given arc is valid,
1.149 + /// i.e. it is a real arc of the digraph.
1.150 ///
1.151 /// \warning A removed arc (using Snapshot) could become valid again
1.152 - /// when new arcs are added to the graph.
1.153 + /// if new arcs are added to the graph.
1.154 bool valid(Arc a) const { return Parent::valid(a); }
1.155
1.156 - ///Clear the digraph.
1.157 -
1.158 - ///Erase all the nodes and arcs from the digraph.
1.159 - ///
1.160 - void clear() {
1.161 - Parent::clear();
1.162 - }
1.163 -
1.164 ///Split a node.
1.165
1.166 - ///This function splits a node. First a new node is added to the digraph,
1.167 - ///then the source of each outgoing arc of \c n is moved to this new node.
1.168 - ///If \c connect is \c true (this is the default value), then a new arc
1.169 - ///from \c n to the newly created node is also added.
1.170 + ///This function splits the given node. First, a new node is added
1.171 + ///to the digraph, then the source of each outgoing arc of node \c n
1.172 + ///is moved to this new node.
1.173 + ///If the second parameter \c connect is \c true (this is the default
1.174 + ///value), then a new arc from node \c n to the newly created node
1.175 + ///is also added.
1.176 ///\return The newly created node.
1.177 ///
1.178 - ///\note The <tt>Arc</tt>s
1.179 - ///referencing a moved arc remain
1.180 - ///valid. However <tt>InArc</tt>'s and <tt>OutArc</tt>'s
1.181 - ///may be invalidated.
1.182 + ///\note All iterators remain valid.
1.183 + ///
1.184 ///\warning This functionality cannot be used together with the Snapshot
1.185 ///feature.
1.186 Node split(Node n, bool connect = true)
1.187 @@ -305,11 +266,41 @@
1.188 Node b = addNode();
1.189 nodes[b._id].first_out=nodes[n._id].first_out;
1.190 nodes[n._id].first_out=-1;
1.191 - for(int i=nodes[b._id].first_out;i!=-1;i++) arcs[i].source=b._id;
1.192 + for(int i=nodes[b._id].first_out; i!=-1; i=arcs[i].next_out) {
1.193 + arcs[i].source=b._id;
1.194 + }
1.195 if(connect) addArc(n,b);
1.196 return b;
1.197 }
1.198
1.199 + ///Clear the digraph.
1.200 +
1.201 + ///This function erases all nodes and arcs from the digraph.
1.202 + ///
1.203 + void clear() {
1.204 + Parent::clear();
1.205 + }
1.206 +
1.207 + /// Reserve memory for nodes.
1.208 +
1.209 + /// Using this function, it is possible to avoid superfluous memory
1.210 + /// allocation: if you know that the digraph you want to build will
1.211 + /// be large (e.g. it will contain millions of nodes and/or arcs),
1.212 + /// then it is worth reserving space for this amount before starting
1.213 + /// to build the digraph.
1.214 + /// \sa reserveArc()
1.215 + void reserveNode(int n) { nodes.reserve(n); };
1.216 +
1.217 + /// Reserve memory for arcs.
1.218 +
1.219 + /// Using this function, it is possible to avoid superfluous memory
1.220 + /// allocation: if you know that the digraph you want to build will
1.221 + /// be large (e.g. it will contain millions of nodes and/or arcs),
1.222 + /// then it is worth reserving space for this amount before starting
1.223 + /// to build the digraph.
1.224 + /// \sa reserveNode()
1.225 + void reserveArc(int m) { arcs.reserve(m); };
1.226 +
1.227 public:
1.228
1.229 class Snapshot;
1.230 @@ -334,20 +325,23 @@
1.231
1.232 public:
1.233
1.234 - ///Class to make a snapshot of the digraph and to restrore to it later.
1.235 + ///Class to make a snapshot of the digraph and to restore it later.
1.236
1.237 - ///Class to make a snapshot of the digraph and to restrore to it later.
1.238 + ///Class to make a snapshot of the digraph and to restore it later.
1.239 ///
1.240 ///The newly added nodes and arcs can be removed using the
1.241 - ///restore() function.
1.242 - ///\note After you restore a state, you cannot restore
1.243 - ///a later state, in other word you cannot add again the arcs deleted
1.244 - ///by restore() using another one Snapshot instance.
1.245 + ///restore() function. This is the only way for deleting nodes and/or
1.246 + ///arcs from a SmartDigraph structure.
1.247 ///
1.248 - ///\warning If you do not use correctly the snapshot that can cause
1.249 - ///either broken program, invalid state of the digraph, valid but
1.250 - ///not the restored digraph or no change. Because the runtime performance
1.251 - ///the validity of the snapshot is not stored.
1.252 + ///\note After a state is restored, you cannot restore a later state,
1.253 + ///i.e. you cannot add the removed nodes and arcs again using
1.254 + ///another Snapshot instance.
1.255 + ///
1.256 + ///\warning Node splitting cannot be restored.
1.257 + ///\warning The validity of the snapshot is not stored due to
1.258 + ///performance reasons. If you do not use the snapshot correctly,
1.259 + ///it can cause broken program, invalid or not restored state of
1.260 + ///the digraph or no change.
1.261 class Snapshot
1.262 {
1.263 SmartDigraph *_graph;
1.264 @@ -359,39 +353,32 @@
1.265 ///Default constructor.
1.266
1.267 ///Default constructor.
1.268 - ///To actually make a snapshot you must call save().
1.269 - ///
1.270 + ///You have to call save() to actually make a snapshot.
1.271 Snapshot() : _graph(0) {}
1.272 ///Constructor that immediately makes a snapshot
1.273
1.274 - ///This constructor immediately makes a snapshot of the digraph.
1.275 - ///\param graph The digraph we make a snapshot of.
1.276 - Snapshot(SmartDigraph &graph) : _graph(&graph) {
1.277 + ///This constructor immediately makes a snapshot of the given digraph.
1.278 + ///
1.279 + Snapshot(SmartDigraph &gr) : _graph(&gr) {
1.280 node_num=_graph->nodes.size();
1.281 arc_num=_graph->arcs.size();
1.282 }
1.283
1.284 ///Make a snapshot.
1.285
1.286 - ///Make a snapshot of the digraph.
1.287 - ///
1.288 - ///This function can be called more than once. In case of a repeated
1.289 + ///This function makes a snapshot of the given digraph.
1.290 + ///It can be called more than once. In case of a repeated
1.291 ///call, the previous snapshot gets lost.
1.292 - ///\param graph The digraph we make the snapshot of.
1.293 - void save(SmartDigraph &graph)
1.294 - {
1.295 - _graph=&graph;
1.296 + void save(SmartDigraph &gr) {
1.297 + _graph=&gr;
1.298 node_num=_graph->nodes.size();
1.299 arc_num=_graph->arcs.size();
1.300 }
1.301
1.302 ///Undo the changes until a snapshot.
1.303
1.304 - ///Undo the changes until a snapshot created by save().
1.305 - ///
1.306 - ///\note After you restored a state, you cannot restore
1.307 - ///a later state, in other word you cannot add again the arcs deleted
1.308 - ///by restore().
1.309 + ///This function undos the changes until the last snapshot
1.310 + ///created by save() or Snapshot(SmartDigraph&).
1.311 void restore()
1.312 {
1.313 _graph->restoreSnapshot(*this);
1.314 @@ -420,7 +407,7 @@
1.315
1.316 public:
1.317
1.318 - typedef SmartGraphBase Digraph;
1.319 + typedef SmartGraphBase Graph;
1.320
1.321 class Node;
1.322 class Arc;
1.323 @@ -464,8 +451,8 @@
1.324 explicit Arc(int id) { _id = id;}
1.325
1.326 public:
1.327 - operator Edge() const {
1.328 - return _id != -1 ? edgeFromId(_id / 2) : INVALID;
1.329 + operator Edge() const {
1.330 + return _id != -1 ? edgeFromId(_id / 2) : INVALID;
1.331 }
1.332
1.333 Arc() {}
1.334 @@ -480,6 +467,13 @@
1.335 SmartGraphBase()
1.336 : nodes(), arcs() {}
1.337
1.338 + typedef True NodeNumTag;
1.339 + typedef True EdgeNumTag;
1.340 + typedef True ArcNumTag;
1.341 +
1.342 + int nodeNum() const { return nodes.size(); }
1.343 + int edgeNum() const { return arcs.size() / 2; }
1.344 + int arcNum() const { return arcs.size(); }
1.345
1.346 int maxNodeId() const { return nodes.size()-1; }
1.347 int maxEdgeId() const { return arcs.size() / 2 - 1; }
1.348 @@ -503,7 +497,7 @@
1.349 node._id = nodes.size() - 1;
1.350 }
1.351
1.352 - void next(Node& node) const {
1.353 + static void next(Node& node) {
1.354 --node._id;
1.355 }
1.356
1.357 @@ -511,7 +505,7 @@
1.358 arc._id = arcs.size() - 1;
1.359 }
1.360
1.361 - void next(Arc& arc) const {
1.362 + static void next(Arc& arc) {
1.363 --arc._id;
1.364 }
1.365
1.366 @@ -519,7 +513,7 @@
1.367 arc._id = arcs.size() / 2 - 1;
1.368 }
1.369
1.370 - void next(Edge& arc) const {
1.371 + static void next(Edge& arc) {
1.372 --arc._id;
1.373 }
1.374
1.375 @@ -616,95 +610,107 @@
1.376 ///
1.377 /// \brief A smart undirected graph class.
1.378 ///
1.379 - /// This is a simple and fast graph implementation.
1.380 - /// It is also quite memory efficient, but at the price
1.381 - /// that <b> it does support only limited (only stack-like)
1.382 - /// node and arc deletions</b>.
1.383 - /// Except from this it conforms to
1.384 - /// the \ref concepts::Graph "Graph concept".
1.385 + /// \ref SmartGraph is a simple and fast graph implementation.
1.386 + /// It is also quite memory efficient but at the price
1.387 + /// that it does not support node and edge deletion
1.388 + /// (except for the Snapshot feature).
1.389 ///
1.390 - /// It also has an
1.391 - /// important extra feature that
1.392 - /// its maps are real \ref concepts::ReferenceMap "reference map"s.
1.393 + /// This type fully conforms to the \ref concepts::Graph "Graph concept"
1.394 + /// and it also provides some additional functionalities.
1.395 + /// Most of its member functions and nested classes are documented
1.396 + /// only in the concept class.
1.397 ///
1.398 - /// \sa concepts::Graph.
1.399 - ///
1.400 + /// \sa concepts::Graph
1.401 + /// \sa SmartDigraph
1.402 class SmartGraph : public ExtendedSmartGraphBase {
1.403 + typedef ExtendedSmartGraphBase Parent;
1.404 +
1.405 private:
1.406 -
1.407 - ///SmartGraph is \e not copy constructible. Use GraphCopy() instead.
1.408 -
1.409 - ///SmartGraph is \e not copy constructible. Use GraphCopy() instead.
1.410 - ///
1.411 + /// Graphs are \e not copy constructible. Use GraphCopy instead.
1.412 SmartGraph(const SmartGraph &) : ExtendedSmartGraphBase() {};
1.413 -
1.414 - ///\brief Assignment of SmartGraph to another one is \e not allowed.
1.415 - ///Use GraphCopy() instead.
1.416 -
1.417 - ///Assignment of SmartGraph to another one is \e not allowed.
1.418 - ///Use GraphCopy() instead.
1.419 + /// \brief Assignment of a graph to another one is \e not allowed.
1.420 + /// Use GraphCopy instead.
1.421 void operator=(const SmartGraph &) {}
1.422
1.423 public:
1.424
1.425 - typedef ExtendedSmartGraphBase Parent;
1.426 -
1.427 /// Constructor
1.428
1.429 /// Constructor.
1.430 ///
1.431 SmartGraph() {}
1.432
1.433 - ///Add a new node to the graph.
1.434 -
1.435 - /// \return the new node.
1.436 + /// \brief Add a new node to the graph.
1.437 ///
1.438 + /// This function adds a new node to the graph.
1.439 + /// \return The new node.
1.440 Node addNode() { return Parent::addNode(); }
1.441
1.442 - ///Add a new edge to the graph.
1.443 -
1.444 - ///Add a new edge to the graph with node \c s
1.445 - ///and \c t.
1.446 - ///\return the new edge.
1.447 - Edge addEdge(const Node& s, const Node& t) {
1.448 - return Parent::addEdge(s, t);
1.449 + /// \brief Add a new edge to the graph.
1.450 + ///
1.451 + /// This function adds a new edge to the graph between nodes
1.452 + /// \c u and \c v with inherent orientation from node \c u to
1.453 + /// node \c v.
1.454 + /// \return The new edge.
1.455 + Edge addEdge(Node u, Node v) {
1.456 + return Parent::addEdge(u, v);
1.457 }
1.458
1.459 /// \brief Node validity check
1.460 ///
1.461 - /// This function gives back true if the given node is valid,
1.462 - /// ie. it is a real node of the graph.
1.463 + /// This function gives back \c true if the given node is valid,
1.464 + /// i.e. it is a real node of the graph.
1.465 ///
1.466 /// \warning A removed node (using Snapshot) could become valid again
1.467 - /// when new nodes are added to the graph.
1.468 + /// if new nodes are added to the graph.
1.469 bool valid(Node n) const { return Parent::valid(n); }
1.470
1.471 + /// \brief Edge validity check
1.472 + ///
1.473 + /// This function gives back \c true if the given edge is valid,
1.474 + /// i.e. it is a real edge of the graph.
1.475 + ///
1.476 + /// \warning A removed edge (using Snapshot) could become valid again
1.477 + /// if new edges are added to the graph.
1.478 + bool valid(Edge e) const { return Parent::valid(e); }
1.479 +
1.480 /// \brief Arc validity check
1.481 ///
1.482 - /// This function gives back true if the given arc is valid,
1.483 - /// ie. it is a real arc of the graph.
1.484 + /// This function gives back \c true if the given arc is valid,
1.485 + /// i.e. it is a real arc of the graph.
1.486 ///
1.487 /// \warning A removed arc (using Snapshot) could become valid again
1.488 - /// when new edges are added to the graph.
1.489 + /// if new edges are added to the graph.
1.490 bool valid(Arc a) const { return Parent::valid(a); }
1.491
1.492 - /// \brief Edge validity check
1.493 - ///
1.494 - /// This function gives back true if the given edge is valid,
1.495 - /// ie. it is a real edge of the graph.
1.496 - ///
1.497 - /// \warning A removed edge (using Snapshot) could become valid again
1.498 - /// when new edges are added to the graph.
1.499 - bool valid(Edge e) const { return Parent::valid(e); }
1.500 -
1.501 ///Clear the graph.
1.502
1.503 - ///Erase all the nodes and edges from the graph.
1.504 + ///This function erases all nodes and arcs from the graph.
1.505 ///
1.506 void clear() {
1.507 Parent::clear();
1.508 }
1.509
1.510 + /// Reserve memory for nodes.
1.511 +
1.512 + /// Using this function, it is possible to avoid superfluous memory
1.513 + /// allocation: if you know that the graph you want to build will
1.514 + /// be large (e.g. it will contain millions of nodes and/or edges),
1.515 + /// then it is worth reserving space for this amount before starting
1.516 + /// to build the graph.
1.517 + /// \sa reserveEdge()
1.518 + void reserveNode(int n) { nodes.reserve(n); };
1.519 +
1.520 + /// Reserve memory for edges.
1.521 +
1.522 + /// Using this function, it is possible to avoid superfluous memory
1.523 + /// allocation: if you know that the graph you want to build will
1.524 + /// be large (e.g. it will contain millions of nodes and/or edges),
1.525 + /// then it is worth reserving space for this amount before starting
1.526 + /// to build the graph.
1.527 + /// \sa reserveNode()
1.528 + void reserveEdge(int m) { arcs.reserve(2 * m); };
1.529 +
1.530 public:
1.531
1.532 class Snapshot;
1.533 @@ -728,8 +734,8 @@
1.534 dir.push_back(arcFromId(n));
1.535 dir.push_back(arcFromId(n-1));
1.536 Parent::notifier(Arc()).erase(dir);
1.537 - nodes[arcs[n].target].first_out=arcs[n].next_out;
1.538 - nodes[arcs[n-1].target].first_out=arcs[n-1].next_out;
1.539 + nodes[arcs[n-1].target].first_out=arcs[n].next_out;
1.540 + nodes[arcs[n].target].first_out=arcs[n-1].next_out;
1.541 arcs.pop_back();
1.542 arcs.pop_back();
1.543 }
1.544 @@ -743,21 +749,22 @@
1.545
1.546 public:
1.547
1.548 - ///Class to make a snapshot of the digraph and to restrore to it later.
1.549 + ///Class to make a snapshot of the graph and to restore it later.
1.550
1.551 - ///Class to make a snapshot of the digraph and to restrore to it later.
1.552 + ///Class to make a snapshot of the graph and to restore it later.
1.553 ///
1.554 - ///The newly added nodes and arcs can be removed using the
1.555 - ///restore() function.
1.556 + ///The newly added nodes and edges can be removed using the
1.557 + ///restore() function. This is the only way for deleting nodes and/or
1.558 + ///edges from a SmartGraph structure.
1.559 ///
1.560 - ///\note After you restore a state, you cannot restore
1.561 - ///a later state, in other word you cannot add again the arcs deleted
1.562 - ///by restore() using another one Snapshot instance.
1.563 + ///\note After a state is restored, you cannot restore a later state,
1.564 + ///i.e. you cannot add the removed nodes and edges again using
1.565 + ///another Snapshot instance.
1.566 ///
1.567 - ///\warning If you do not use correctly the snapshot that can cause
1.568 - ///either broken program, invalid state of the digraph, valid but
1.569 - ///not the restored digraph or no change. Because the runtime performance
1.570 - ///the validity of the snapshot is not stored.
1.571 + ///\warning The validity of the snapshot is not stored due to
1.572 + ///performance reasons. If you do not use the snapshot correctly,
1.573 + ///it can cause broken program, invalid or not restored state of
1.574 + ///the graph or no change.
1.575 class Snapshot
1.576 {
1.577 SmartGraph *_graph;
1.578 @@ -769,36 +776,30 @@
1.579 ///Default constructor.
1.580
1.581 ///Default constructor.
1.582 - ///To actually make a snapshot you must call save().
1.583 - ///
1.584 + ///You have to call save() to actually make a snapshot.
1.585 Snapshot() : _graph(0) {}
1.586 ///Constructor that immediately makes a snapshot
1.587
1.588 - ///This constructor immediately makes a snapshot of the digraph.
1.589 - ///\param graph The digraph we make a snapshot of.
1.590 - Snapshot(SmartGraph &graph) {
1.591 - graph.saveSnapshot(*this);
1.592 + /// This constructor immediately makes a snapshot of the given graph.
1.593 + ///
1.594 + Snapshot(SmartGraph &gr) {
1.595 + gr.saveSnapshot(*this);
1.596 }
1.597
1.598 ///Make a snapshot.
1.599
1.600 - ///Make a snapshot of the graph.
1.601 - ///
1.602 - ///This function can be called more than once. In case of a repeated
1.603 + ///This function makes a snapshot of the given graph.
1.604 + ///It can be called more than once. In case of a repeated
1.605 ///call, the previous snapshot gets lost.
1.606 - ///\param graph The digraph we make the snapshot of.
1.607 - void save(SmartGraph &graph)
1.608 + void save(SmartGraph &gr)
1.609 {
1.610 - graph.saveSnapshot(*this);
1.611 + gr.saveSnapshot(*this);
1.612 }
1.613
1.614 - ///Undo the changes until a snapshot.
1.615 + ///Undo the changes until the last snapshot.
1.616
1.617 - ///Undo the changes until a snapshot created by save().
1.618 - ///
1.619 - ///\note After you restored a state, you cannot restore
1.620 - ///a later state, in other word you cannot add again the arcs deleted
1.621 - ///by restore().
1.622 + ///This function undos the changes until the last snapshot
1.623 + ///created by save() or Snapshot(SmartGraph&).
1.624 void restore()
1.625 {
1.626 _graph->restoreSnapshot(*this);