COIN-OR::LEMON - Graph Library

Changeset 431:4b6112235fad in lemon for lemon/graph_adaptor.h


Ignore:
Timestamp:
11/30/08 19:00:30 (15 years ago)
Author:
Balazs Dezso <deba@…>
Branch:
default
Phase:
public
Message:

Improvements in graph adaptors (#67)

Remove DigraphAdaptor? and GraphAdaptor?
Remove docs of base classes
Move the member documentations to real adaptors
Minor improvements in documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/graph_adaptor.h

    r430 r431  
    3232namespace lemon {
    3333
    34   /// \brief Base type for the Graph Adaptors
    35   ///
    36   /// This is the base type for most of LEMON graph adaptors.
    37   /// This class implements a trivial graph adaptor i.e. it only wraps the
    38   /// functions and types of the graph. The purpose of this class is to
    39   /// make easier implementing graph adaptors. E.g. if an adaptor is
    40   /// considered which differs from the wrapped graph only in some of its
    41   /// functions or types, then it can be derived from GraphAdaptor, and only
    42   /// the differences should be implemented.
    4334  template<typename _Graph>
    4435  class GraphAdaptorBase {
     
    196187  };
    197188
    198   /// \ingroup graph_adaptors
    199   ///
    200   /// \brief Trivial graph adaptor
    201   ///
    202   /// This class is an adaptor which does not change the adapted undirected
    203   /// graph. It can be used only to test the graph adaptors.
    204   template <typename _Graph>
    205   class GraphAdaptor
    206     : public GraphAdaptorExtender< GraphAdaptorBase<_Graph> > {
    207   public:
    208     typedef _Graph Graph;
    209     typedef GraphAdaptorExtender<GraphAdaptorBase<_Graph> > Parent;
    210   protected:
    211     GraphAdaptor() : Parent() {}
    212 
    213   public:
    214     explicit GraphAdaptor(Graph& graph) { setGraph(graph); }
    215   };
    216 
    217189  template <typename _Graph, typename NodeFilterMap,
    218190            typename EdgeFilterMap, bool checked = true>
     
    319291    }
    320292
    321     /// \brief Hide the given node in the graph.
    322     ///
    323     /// This function hides \c n in the graph, i.e. the iteration
    324     /// jumps over it. This is done by simply setting the value of \c n 
    325     /// to be false in the corresponding node-map.
    326293    void hide(const Node& n) const { _node_filter_map->set(n, false); }
    327 
    328     /// \brief Hide the given edge in the graph.
    329     ///
    330     /// This function hides \c e in the graph, i.e. the iteration
    331     /// jumps over it. This is done by simply setting the value of \c e 
    332     /// to be false in the corresponding edge-map.
    333294    void hide(const Edge& e) const { _edge_filter_map->set(e, false); }
    334295
    335     /// \brief Unhide the given node in the graph.
    336     ///
    337     /// The value of \c n is set to be true in the node-map which stores
    338     /// hide information. If \c n was hidden previuosly, then it is shown
    339     /// again
    340      void unHide(const Node& n) const { _node_filter_map->set(n, true); }
    341 
    342     /// \brief Hide the given edge in the graph.
    343     ///
    344     /// The value of \c e is set to be true in the edge-map which stores
    345     /// hide information. If \c e was hidden previuosly, then it is shown
    346     /// again
     296    void unHide(const Node& n) const { _node_filter_map->set(n, true); }
    347297    void unHide(const Edge& e) const { _edge_filter_map->set(e, true); }
    348298
    349     /// \brief Returns true if \c n is hidden.
    350     ///
    351     /// Returns true if \c n is hidden.
    352299    bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; }
    353 
    354     /// \brief Returns true if \c e is hidden.
    355     ///
    356     /// Returns true if \c e is hidden.
    357300    bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; }
    358301
     
    544487    }
    545488
    546     /// \brief Hide the given node in the graph.
    547     ///
    548     /// This function hides \c n in the graph, i.e. the iteration
    549     /// jumps over it. This is done by simply setting the value of \c n 
    550     /// to be false in the corresponding node-map.
    551489    void hide(const Node& n) const { _node_filter_map->set(n, false); }
    552 
    553     /// \brief Hide the given edge in the graph.
    554     ///
    555     /// This function hides \c e in the graph, i.e. the iteration
    556     /// jumps over it. This is done by simply setting the value of \c e 
    557     /// to be false in the corresponding edge-map.
    558490    void hide(const Edge& e) const { _edge_filter_map->set(e, false); }
    559491
    560     /// \brief Unhide the given node in the graph.
    561     ///
    562     /// The value of \c n is set to be true in the node-map which stores
    563     /// hide information. If \c n was hidden previuosly, then it is shown
    564     /// again
    565      void unHide(const Node& n) const { _node_filter_map->set(n, true); }
    566 
    567     /// \brief Hide the given edge in the graph.
    568     ///
    569     /// The value of \c e is set to be true in the edge-map which stores
    570     /// hide information. If \c e was hidden previuosly, then it is shown
    571     /// again
     492    void unHide(const Node& n) const { _node_filter_map->set(n, true); }
    572493    void unHide(const Edge& e) const { _edge_filter_map->set(e, true); }
    573494
    574     /// \brief Returns true if \c n is hidden.
    575     ///
    576     /// Returns true if \c n is hidden.
    577495    bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; }
    578 
    579     /// \brief Returns true if \c e is hidden.
    580     ///
    581     /// Returns true if \c e is hidden.
    582496    bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; }
    583497
     
    683597  /// \ingroup graph_adaptors
    684598  ///
    685   /// \brief A graph adaptor for hiding nodes and arcs from an
     599  /// \brief A graph adaptor for hiding nodes and edges from an
    686600  /// undirected graph.
    687601  ///
     
    705619    typedef GraphAdaptorExtender<
    706620      SubGraphAdaptorBase<_Graph, NodeFilterMap, EdgeFilterMap> > Parent;
     621
     622    typedef typename Parent::Node Node;
     623    typedef typename Parent::Edge Edge;
     624
    707625  protected:
    708626    SubGraphAdaptor() { }
    709627  public:
     628   
     629    /// \brief Constructor
     630    ///
     631    /// Creates a sub-graph-adaptor for the given graph with
     632    /// given node and edge map filters.
    710633    SubGraphAdaptor(Graph& _graph, NodeFilterMap& node_filter_map,
    711634                    EdgeFilterMap& edge_filter_map) {
     
    714637      setEdgeFilterMap(edge_filter_map);
    715638    }
     639
     640    /// \brief Hides the node of the graph
     641    ///
     642    /// This function hides \c n in the digraph, i.e. the iteration
     643    /// jumps over it. This is done by simply setting the value of \c n 
     644    /// to be false in the corresponding node-map.
     645    void hide(const Node& n) const { Parent::hide(n); }
     646
     647    /// \brief Hides the edge of the graph
     648    ///
     649    /// This function hides \c e in the digraph, i.e. the iteration
     650    /// jumps over it. This is done by simply setting the value of \c e
     651    /// to be false in the corresponding edge-map.
     652    void hide(const Edge& e) const { Parent::hide(e); }
     653
     654    /// \brief Unhides the node of the graph
     655    ///
     656    /// The value of \c n is set to be true in the node-map which stores
     657    /// hide information. If \c n was hidden previuosly, then it is shown
     658    /// again
     659    void unHide(const Node& n) const { Parent::unHide(n); }
     660
     661    /// \brief Unhides the edge of the graph
     662    ///
     663    /// The value of \c e is set to be true in the edge-map which stores
     664    /// hide information. If \c e was hidden previuosly, then it is shown
     665    /// again
     666    void unHide(const Edge& e) const { Parent::unHide(e); }
     667
     668    /// \brief Returns true if \c n is hidden.
     669    ///
     670    /// Returns true if \c n is hidden.
     671    ///
     672    bool hidden(const Node& n) const { return Parent::hidden(n); }
     673
     674    /// \brief Returns true if \c e is hidden.
     675    ///
     676    /// Returns true if \c e is hidden.
     677    ///
     678    bool hidden(const Edge& e) const { return Parent::hidden(e); }
    716679  };
    717680
     681  /// \brief Just gives back a sub-graph adaptor
     682  ///
     683  /// Just gives back a sub-graph adaptor
    718684  template<typename Graph, typename NodeFilterMap, typename ArcFilterMap>
    719685  SubGraphAdaptor<const Graph, NodeFilterMap, ArcFilterMap>
     
    766732    typedef SubGraphAdaptor<Graph, NodeFilterMap,
    767733                            ConstMap<typename Graph::Edge, bool> > Parent;
     734
     735    typedef typename Parent::Node Node;
    768736  protected:
    769737    ConstMap<typename Graph::Edge, bool> const_true_map;
     
    774742
    775743  public:
     744
     745    /// \brief Constructor
     746    ///
     747    /// Creates a node-sub-graph-adaptor for the given graph with
     748    /// given node map filters.
    776749    NodeSubGraphAdaptor(Graph& _graph, NodeFilterMap& node_filter_map) :
    777750      Parent(), const_true_map(true) {
     
    780753      Parent::setEdgeFilterMap(const_true_map);
    781754    }
     755
     756    /// \brief Hides the node of the graph
     757    ///
     758    /// This function hides \c n in the digraph, i.e. the iteration
     759    /// jumps over it. This is done by simply setting the value of \c n 
     760    /// to be false in the corresponding node-map.
     761    void hide(const Node& n) const { Parent::hide(n); }
     762
     763    /// \brief Unhides the node of the graph
     764    ///
     765    /// The value of \c n is set to be true in the node-map which stores
     766    /// hide information. If \c n was hidden previuosly, then it is shown
     767    /// again
     768    void unHide(const Node& n) const { Parent::unHide(n); }
     769
     770    /// \brief Returns true if \c n is hidden.
     771    ///
     772    /// Returns true if \c n is hidden.
     773    ///
     774    bool hidden(const Node& n) const { return Parent::hidden(n); }
     775
    782776  };
    783777
     778  /// \brief Just gives back a node-sub-graph adaptor
     779  ///
     780  /// Just gives back a node-sub-graph adaptor
    784781  template<typename Graph, typename NodeFilterMap>
    785782  NodeSubGraphAdaptor<const Graph, NodeFilterMap>
     
    814811    typedef SubGraphAdaptor<Graph, ConstMap<typename Graph::Node,bool>,
    815812                            EdgeFilterMap, false> Parent;
     813    typedef typename Parent::Edge Edge;
    816814  protected:
    817815    ConstMap<typename Graph::Node, bool> const_true_map;
     
    823821  public:
    824822
     823    /// \brief Constructor
     824    ///
     825    /// Creates a edge-sub-graph-adaptor for the given graph with
     826    /// given node map filters.
    825827    EdgeSubGraphAdaptor(Graph& _graph, EdgeFilterMap& edge_filter_map) :
    826828      Parent(), const_true_map(true) {
     
    830832    }
    831833
     834    /// \brief Hides the edge of the graph
     835    ///
     836    /// This function hides \c e in the digraph, i.e. the iteration
     837    /// jumps over it. This is done by simply setting the value of \c e
     838    /// to be false in the corresponding edge-map.
     839    void hide(const Edge& e) const { Parent::hide(e); }
     840
     841    /// \brief Unhides the edge of the graph
     842    ///
     843    /// The value of \c e is set to be true in the edge-map which stores
     844    /// hide information. If \c e was hidden previuosly, then it is shown
     845    /// again
     846    void unHide(const Edge& e) const { Parent::unHide(e); }
     847
     848    /// \brief Returns true if \c e is hidden.
     849    ///
     850    /// Returns true if \c e is hidden.
     851    ///
     852    bool hidden(const Edge& e) const { return Parent::hidden(e); }
     853
    832854  };
    833855
     856  /// \brief Just gives back an edge-sub-graph adaptor
     857  ///
     858  /// Just gives back an edge-sub-graph adaptor
    834859  template<typename Graph, typename EdgeFilterMap>
    835860  EdgeSubGraphAdaptor<const Graph, EdgeFilterMap>
     
    844869  }
    845870
    846   /// \brief Base of direct graph adaptor
    847   ///
    848   /// Base class of the direct graph adaptor. All public member
    849   /// of this class can be used with the DirGraphAdaptor too.
    850   /// \sa DirGraphAdaptor
    851871  template <typename _Graph, typename _DirectionMap>
    852872  class DirGraphAdaptorBase {
     
    11041124    typedef DigraphAdaptorExtender<
    11051125      DirGraphAdaptorBase<_Graph, DirectionMap> > Parent;
     1126    typedef typename Parent::Arc Arc;
    11061127  protected:
    11071128    DirGraphAdaptor() { }
     
    11141135      setGraph(graph);
    11151136      setDirectionMap(direction);
     1137    }
     1138
     1139    /// \brief Reverse arc
     1140    ///
     1141    /// It reverse the given arc. It simply negate the direction in the map.
     1142    void reverseArc(const Arc& a) {
     1143      Parent::reverseArc(a);
    11161144    }
    11171145  };
Note: See TracChangeset for help on using the changeset viewer.