Changeset 973:6a6f3ac07b20 in lemon-0.x
- Timestamp:
- 11/09/04 18:48:52 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1361
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/lemon/smart_graph.h
r969 r973 26 26 #include <lemon/invalid.h> 27 27 28 #include <lemon/erasable_graph_extender.h>29 28 #include <lemon/clearable_graph_extender.h> 30 29 #include <lemon/extendable_graph_extender.h> … … 46 45 /// @{ 47 46 47 class SmartGraph; 48 48 ///Base of SmartGraph 49 49 … … 52 52 class SmartGraphBase { 53 53 54 friend class SmatGraph; 55 56 protected: 54 57 struct NodeT 55 58 { … … 144 147 class Node { 145 148 friend class SmartGraphBase; 149 friend class SmartGraph; 146 150 147 151 protected: 148 152 int n; 153 ///\todo It should be removed (or at least define a setToId() instead). 154 /// 149 155 Node(int nn) {n=nn;} 150 156 public: … … 159 165 class Edge { 160 166 friend class SmartGraphBase; 167 friend class SmartGraph; 161 168 162 169 protected: 163 170 int n; 171 ///\todo It should be removed (or at least define a setToId() instead). 172 /// 164 173 Edge(int nn) {n=nn;} 165 174 public: … … 210 219 return prev; 211 220 } 221 212 222 }; 213 223 … … 241 251 public: 242 252 /// Finds an edge between two nodes. 243 253 244 254 /// Finds an edge from node \c u to node \c v. 245 255 /// … … 260 270 return _findEdge(u,v,prev); 261 271 } 262 }; 272 273 ///Internal data structure to store snapshots 274 275 ///\ingroup graphs 276 ///\sa makeSnapShot() 277 ///\sa rollBack() 278 struct SnapShot 279 { 280 unsigned int node_num; 281 unsigned int edge_num; 282 }; 283 284 ///Make a snapshot of the graph. 285 286 ///Make a snapshot of the graph. 287 /// 288 ///The newly added nodes and edges can be removed using the 289 ///rollBack() function. 290 /// 291 ///\return An stucture SnapShot describing the pesent state of the 292 ///graph. 293 ///\note After you rolled back to a state, you cannot roll "back" to 294 ///a later state, in other word you cannot add again the edges deleted 295 ///by rollBack(). 296 SnapShot makeSnapShot() 297 { 298 SnapShot s; 299 s.node_num=nodes.size(); 300 s.edge_num=edges.size(); 301 return s; 302 } 303 304 ///Undo the changes until a snapshot. 305 306 ///Undo the changes until a snapshot created by makeSnapShot(). 307 /// 308 ///\param s an internal stucture given back by makeSnapShot() 309 ///\note After you rolled back to a state, you cannot "roll forward" to 310 ///a later state, in other word you cannot add again the edges deleted 311 ///by rollBack(). 312 /// 313 ///\todo This function might be called undo(). 314 315 void rollBack(const SnapShot &s) 316 { 317 while(s.edge_num>edges.size()) { 318 edge_observers.erase(Edge(edges.size()-1)); 319 nodes[edges.back().head].first_in=edges.back().next_in; 320 nodes[edges.back().tail].first_out=edges.back().next_out; 321 edges.pop_back(); 322 } 323 //nodes.resize(s.nodes_num); 324 while(s.node_num>nodes.size()) { 325 node_observers.erase(Node(nodes.size()-1)); 326 nodes.pop_back(); 327 } 328 } 329 }; 263 330 264 331 template <>
Note: See TracChangeset
for help on using the changeset viewer.