NewUndirEdgeSetAdaptor class
authordeba
Mon, 04 Jul 2005 17:22:03 +0000
changeset 1538777834118f73
parent 1537 0d9f1a71be27
child 1539 8f589de42c76
NewUndirEdgeSetAdaptor class
some doc
some bug fix
lemon/graph_adaptor.h
lemon/graph_utils.h
     1.1 --- a/lemon/graph_adaptor.h	Mon Jul 04 17:16:05 2005 +0000
     1.2 +++ b/lemon/graph_adaptor.h	Mon Jul 04 17:22:03 2005 +0000
     1.3 @@ -1215,7 +1215,6 @@
     1.4  
     1.5    };
     1.6  
     1.7 -  /// \e
     1.8    template <typename _Graph>
     1.9    class NewEdgeSetAdaptorBase {
    1.10    public:
    1.11 @@ -1413,6 +1412,20 @@
    1.12  
    1.13    };
    1.14  
    1.15 +
    1.16 +  /// \brief Graph adaptor using a node set of another graph and an
    1.17 +  /// own edge set.
    1.18 +  ///
    1.19 +  /// This structure can be used to establish another graph over a node set
    1.20 +  /// of an existing one. The node iterator will go through the nodes of the
    1.21 +  /// original graph.
    1.22 +  ///
    1.23 +  /// \param _Graph The type of the graph which shares its node set with 
    1.24 +  /// this class. Its interface must conform to the \ref skeleton::StaticGraph
    1.25 +  /// "StaticGraph" concept.
    1.26 +  ///
    1.27 +  /// In the edge extension and removing it conforms to the 
    1.28 +  /// \ref skeleton::ExtendableGraph "ExtendableGraph" concept.
    1.29    template <typename _Graph>
    1.30    class NewEdgeSetAdaptor :
    1.31      public ErasableGraphExtender<
    1.32 @@ -1475,16 +1488,115 @@
    1.33      
    1.34    public:
    1.35  
    1.36 +    /// \brief Constructor of the adaptor.
    1.37 +    /// 
    1.38 +    /// Constructor of the adaptor.
    1.39      NewEdgeSetAdaptor(const _Graph& _graph) : nodes(*this, _graph) {
    1.40        Parent::initalize(_graph, nodes);
    1.41      }
    1.42  
    1.43      void clear() {
    1.44 +      Parent::getNotifier(Edge()).clear();      
    1.45 +
    1.46        Parent::edges.clear();
    1.47        Parent::first_edge = -1;
    1.48        Parent::first_free_edge = -1;
    1.49 +    }
    1.50 +    
    1.51 +  };
    1.52  
    1.53 +  /// \brief Graph adaptor using a node set of another graph and an
    1.54 +  /// own undir edge set.
    1.55 +  ///
    1.56 +  /// This structure can be used to establish another undirected graph over 
    1.57 +  /// a node set of an existing one. The node iterator will go through the 
    1.58 +  /// nodes of the original graph.
    1.59 +  ///
    1.60 +  /// \param _Graph The type of the graph which shares its node set with 
    1.61 +  /// this class. Its interface must conform to the \ref skeleton::StaticGraph
    1.62 +  /// "StaticGraph" concept.
    1.63 +  ///
    1.64 +  /// In the edge extension and removing it conforms to the 
    1.65 +  /// \ref skeleton::ExtendableGraph "ExtendableGraph" concept.
    1.66 +  template <typename _Graph>
    1.67 +  class NewUndirEdgeSetAdaptor :
    1.68 +    public ErasableUndirGraphExtender<
    1.69 +    ClearableUndirGraphExtender<
    1.70 +    ExtendableUndirGraphExtender<
    1.71 +    MappableUndirGraphExtender<
    1.72 +    IterableUndirGraphExtender<
    1.73 +    AlterableUndirGraphExtender<
    1.74 +    UndirGraphExtender<
    1.75 +    NewEdgeSetAdaptorBase<_Graph> > > > > > > > {
    1.76 +
    1.77 +  public:
    1.78 +
    1.79 +    typedef ErasableUndirGraphExtender<
    1.80 +      ClearableUndirGraphExtender<
    1.81 +      ExtendableUndirGraphExtender<
    1.82 +      MappableUndirGraphExtender<
    1.83 +      IterableUndirGraphExtender<
    1.84 +      AlterableUndirGraphExtender<
    1.85 +      UndirGraphExtender<
    1.86 +      NewEdgeSetAdaptorBase<_Graph> > > > > > > > Parent;
    1.87 +    
    1.88 +
    1.89 +    typedef typename Parent::Node Node;
    1.90 +    typedef typename Parent::Edge Edge;
    1.91 +    typedef typename Parent::UndirEdge UndirEdge;
    1.92 +
    1.93 +  private:
    1.94 +
    1.95 +    virtual void _clear() {
    1.96 +      Parent::edges.clear();
    1.97 +      Parent::first_edge = -1;
    1.98 +      Parent::first_free_edge = -1;
    1.99 +      Parent::getNotifier(Edge()).clear();
   1.100 +      Parent::getNotifier(Node()).clear();
   1.101 +    }
   1.102 +
   1.103 +    virtual void _add(const Node& node) {
   1.104 +      Parent::getNotifier(Node()).add(node);
   1.105 +    }
   1.106 +
   1.107 +    virtual void _erase(const Node& node) {
   1.108 +      Edge edge;
   1.109 +      Parent::firstOut(edge, node);
   1.110 +      while (edge != INVALID) {
   1.111 +	Parent::erase(edge);
   1.112 +	Parent::firstOut(edge, node);
   1.113 +      }
   1.114 +
   1.115 +      Parent::firstIn(edge, node);
   1.116 +      while (edge != INVALID) {
   1.117 +	Parent::erase(edge);
   1.118 +	Parent::firstIn(edge, node);
   1.119 +      }
   1.120 +      
   1.121 +      Parent::getNotifier(Node()).erase(node);
   1.122 +    }
   1.123 +
   1.124 +    typedef typename Parent::NodesImpl NodesImpl;
   1.125 +
   1.126 +    NodesImpl nodes;
   1.127 +    
   1.128 +  public:
   1.129 +
   1.130 +
   1.131 +    /// \brief Constructor of the adaptor.
   1.132 +    /// 
   1.133 +    /// Constructor of the adaptor.
   1.134 +    NewUndirEdgeSetAdaptor(const _Graph& _graph) : nodes(*this, _graph) {
   1.135 +      Parent::initalize(_graph, nodes);
   1.136 +    }
   1.137 +
   1.138 +    void clear() {
   1.139        Parent::getNotifier(Edge()).clear();      
   1.140 +      Parent::getNotifier(UndirEdge()).clear();      
   1.141 +
   1.142 +      Parent::edges.clear();
   1.143 +      Parent::first_edge = -1;
   1.144 +      Parent::first_free_edge = -1;
   1.145      }
   1.146      
   1.147    };
     2.1 --- a/lemon/graph_utils.h	Mon Jul 04 17:16:05 2005 +0000
     2.2 +++ b/lemon/graph_utils.h	Mon Jul 04 17:22:03 2005 +0000
     2.3 @@ -739,6 +739,8 @@
     2.4        Map::clear();
     2.5      }
     2.6  
     2.7 +  public:
     2.8 +
     2.9      /// \brief Gives back the \e descriptor of the item.
    2.10      ///
    2.11      /// Gives back the mutable and unique \e descriptor of the map.