lemon/smart_graph.h
changeset 1785 606178a14011
parent 1768 1e2e0238e7c8
child 1791 62e7d237e1fb
equal deleted inserted replaced
9:bd28c39dac84 10:931ab280dfc2
   247   ///
   247   ///
   248   ///\author Alpar Juttner
   248   ///\author Alpar Juttner
   249   class SmartGraph : public ExtendedSmartGraphBase {
   249   class SmartGraph : public ExtendedSmartGraphBase {
   250   public:
   250   public:
   251     
   251     
   252     class SnapShot;
   252     class Snapshot;
   253     friend class SnapShot;
   253     friend class Snapshot;
   254 
   254 
   255   protected:
   255   protected:
   256     void restoreSnapShot(const SnapShot &s)
   256     void restoreSnapshot(const Snapshot &s)
   257     {
   257     {
   258       while(s.edge_num<edges.size()) {
   258       while(s.edge_num<edges.size()) {
   259 	Parent::getNotifier(Edge()).erase(Edge(edges.size()-1));
   259 	Parent::getNotifier(Edge()).erase(Edge(edges.size()-1));
   260 	nodes[edges.back().target].first_in=edges.back().next_in;
   260 	nodes[edges.back().target].first_in=edges.back().next_in;
   261 	nodes[edges.back().source].first_out=edges.back().next_out;
   261 	nodes[edges.back().source].first_out=edges.back().next_out;
   280     ///
   280     ///
   281     ///\note The <tt>Edge</tt>s
   281     ///\note The <tt>Edge</tt>s
   282     ///referencing a moved edge remain
   282     ///referencing a moved edge remain
   283     ///valid. However <tt>InEdge</tt>'s and <tt>OutEdge</tt>'s
   283     ///valid. However <tt>InEdge</tt>'s and <tt>OutEdge</tt>'s
   284     ///may be invalidated.
   284     ///may be invalidated.
   285     ///\warning This functionality cannot be used together with the SnapShot
   285     ///\warning This functionality cannot be used together with the Snapshot
   286     ///feature.
   286     ///feature.
   287     ///\todo It could be implemented in a bit faster way.
   287     ///\todo It could be implemented in a bit faster way.
   288     Node split(Node n, bool connect = true) 
   288     Node split(Node n, bool connect = true) 
   289     {
   289     {
   290       Node b = _split(n,connect);
   290       Node b = _split(n,connect);
   298     ///
   298     ///
   299     ///The newly added nodes and edges can be removed using the
   299     ///The newly added nodes and edges can be removed using the
   300     ///restore() function.
   300     ///restore() function.
   301     ///\note After you restore a state, you cannot restore
   301     ///\note After you restore a state, you cannot restore
   302     ///a later state, in other word you cannot add again the edges deleted
   302     ///a later state, in other word you cannot add again the edges deleted
   303     ///by restore() using another SnapShot instance.
   303     ///by restore() using another Snapshot instance.
   304     ///
   304     ///
   305     class SnapShot 
   305     class Snapshot 
   306     {
   306     {
   307       SmartGraph *g;
   307       SmartGraph *g;
   308     protected:
   308     protected:
   309       friend class SmartGraph;
   309       friend class SmartGraph;
   310       unsigned int node_num;
   310       unsigned int node_num;
   313       ///Default constructor.
   313       ///Default constructor.
   314       
   314       
   315       ///Default constructor.
   315       ///Default constructor.
   316       ///To actually make a snapshot you must call save().
   316       ///To actually make a snapshot you must call save().
   317       ///
   317       ///
   318       SnapShot() : g(0) {}
   318       Snapshot() : g(0) {}
   319       ///Constructor that immediately makes a snapshot
   319       ///Constructor that immediately makes a snapshot
   320       
   320       
   321       ///This constructor immediately makes a snapshot of the graph.
   321       ///This constructor immediately makes a snapshot of the graph.
   322       ///\param _g The graph we make a snapshot of.
   322       ///\param _g The graph we make a snapshot of.
   323       SnapShot(SmartGraph &_g) :g(&_g) {
   323       Snapshot(SmartGraph &_g) :g(&_g) {
   324 	node_num=g->nodes.size();
   324 	node_num=g->nodes.size();
   325 	edge_num=g->edges.size();
   325 	edge_num=g->edges.size();
   326       }
   326       }
   327 
   327 
   328       ///Make a snapshot.
   328       ///Make a snapshot.
   349       ///
   349       ///
   350       ///\todo This function might be called undo().
   350       ///\todo This function might be called undo().
   351       
   351       
   352       void restore()
   352       void restore()
   353       {
   353       {
   354 	g->restoreSnapShot(*this);
   354 	g->restoreSnapshot(*this);
   355       }
   355       }
   356     };
   356     };
   357   };
   357   };
   358 
   358 
   359 
   359 
   374   ///node and edge deletions</b>.
   374   ///node and edge deletions</b>.
   375   ///Except from this it conforms to 
   375   ///Except from this it conforms to 
   376   ///the \ref concept::UndirGraph "UndirGraph" concept.
   376   ///the \ref concept::UndirGraph "UndirGraph" concept.
   377   ///\sa concept::UndirGraph.
   377   ///\sa concept::UndirGraph.
   378   ///
   378   ///
   379   ///\todo SnapShot hasn't been implemented yet.
   379   ///\todo Snapshot hasn't been implemented yet.
   380   ///
   380   ///
   381   class UndirSmartGraph : public ExtendedUndirSmartGraphBase {
   381   class UndirSmartGraph : public ExtendedUndirSmartGraphBase {
   382   };
   382   };
   383 
   383 
   384   
   384