lemon/list_graph.h
changeset 2006 00d59f733817
parent 1995 c1fc2c14a3ae
child 2031 080d51024ac5
equal deleted inserted replaced
21:cbbbadd096c0 22:609e102a9e69
    21 
    21 
    22 ///\ingroup graphs
    22 ///\ingroup graphs
    23 ///\file
    23 ///\file
    24 ///\brief ListGraph, ListUGraph classes.
    24 ///\brief ListGraph, ListUGraph classes.
    25 
    25 
       
    26 #include <lemon/bits/base_extender.h>
    26 #include <lemon/bits/graph_extender.h>
    27 #include <lemon/bits/graph_extender.h>
    27 
    28 
    28 #include <lemon/error.h>
    29 #include <lemon/error.h>
    29 
    30 
    30 #include <vector>
    31 #include <vector>
   318   ///It addition that it conforms to the
   319   ///It addition that it conforms to the
   319   ///\ref concept::ErasableGraph "ErasableGraph" concept,
   320   ///\ref concept::ErasableGraph "ErasableGraph" concept,
   320   ///it also provides several additional useful extra functionalities.
   321   ///it also provides several additional useful extra functionalities.
   321   ///\sa concept::ErasableGraph.
   322   ///\sa concept::ErasableGraph.
   322 
   323 
   323   class ListGraph : public ExtendedListGraphBase 
   324   class ListGraph : public ExtendedListGraphBase {
   324   {
       
   325   public:
   325   public:
       
   326 
       
   327     typedef ExtendedListGraphBase Parent;
       
   328 
   326     /// Changes the target of \c e to \c n
   329     /// Changes the target of \c e to \c n
   327 
   330 
   328     /// Changes the target of \c e to \c n
   331     /// Changes the target of \c e to \c n
   329     ///
   332     ///
   330     ///\note The <tt>Edge</tt>'s and <tt>OutEdge</tt>'s
   333     ///\note The <tt>Edge</tt>'s and <tt>OutEdge</tt>'s
   444     ///The newly added nodes and edges can be removed using the
   447     ///The newly added nodes and edges can be removed using the
   445     ///restore() function.
   448     ///restore() function.
   446     ///
   449     ///
   447     ///\warning Edge and node deletions cannot be restored.
   450     ///\warning Edge and node deletions cannot be restored.
   448     ///\warning Snapshots cannot be nested.
   451     ///\warning Snapshots cannot be nested.
   449     class Snapshot : protected AlterationNotifier<Node>::ObserverBase,
   452     class Snapshot : protected Parent::NodeNotifier::ObserverBase,
   450 		     protected AlterationNotifier<Edge>::ObserverBase
   453 		     protected Parent::EdgeNotifier::ObserverBase
   451     {
   454     {
   452     public:
   455     public:
   453       
   456       
   454       class UnsupportedOperation : public LogicError {
   457       class UnsupportedOperation : public LogicError {
   455       public:
   458       public:
   457 	  return "lemon::ListGraph::Snapshot::UnsupportedOperation";
   460 	  return "lemon::ListGraph::Snapshot::UnsupportedOperation";
   458 	}
   461 	}
   459       };
   462       };
   460             
   463             
   461 
   464 
   462       protected:
   465     protected:
   463       
   466       
   464       ListGraph *g;
   467       ListGraph *g;
   465       std::list<Node> added_nodes;
   468       std::list<Node> added_nodes;
   466       std::list<Edge> added_edges;
   469       std::list<Edge> added_edges;
   467       
   470       
   488       ///
   491       ///
   489       virtual void clear() {}
   492       virtual void clear() {}
   490 
   493 
   491       void regist(ListGraph &_g) {
   494       void regist(ListGraph &_g) {
   492 	g=&_g;
   495 	g=&_g;
   493 	AlterationNotifier<Node>::ObserverBase::
   496 	Parent::NodeNotifier::ObserverBase::attach(g->getNotifier(Node()));
   494 	  attach(g->getNotifier(Node()));
   497 	Parent::EdgeNotifier::ObserverBase::attach(g->getNotifier(Edge()));
   495 	AlterationNotifier<Edge>::ObserverBase::
       
   496 	  attach(g->getNotifier(Edge()));
       
   497       }
   498       }
   498             
   499             
   499       void deregist() {
   500       void deregist() {
   500 	AlterationNotifier<Node>::ObserverBase::
   501 	Parent::NodeNotifier::ObserverBase::detach();
   501 	  detach();
   502 	Parent::EdgeNotifier::ObserverBase::detach();
   502 	AlterationNotifier<Edge>::ObserverBase::
       
   503 	  detach();
       
   504 	g=0;
   503 	g=0;
   505       }
   504       }
   506 
   505 
   507     public:
   506     public:
   508       ///Default constructur.
   507       ///Default constructur.