# HG changeset patch # User Alpar Juttner <alpar@cs.elte.hu> # Date 1231686593 0 # Node ID 5a1e9fdcfd3a5b1393b11a9b6a8dd9ac98fe92c9 # Parent 75a5df083951a54aa6c2e564331319fb4dc2c881# Parent f599fa651202485e2625e607d2506c90c44398a7 Merge diff -r 75a5df083951 -r 5a1e9fdcfd3a doc/groups.dox --- a/doc/groups.dox Thu Jan 08 17:19:26 2009 +0000 +++ b/doc/groups.dox Sun Jan 11 15:09:53 2009 +0000 @@ -62,18 +62,20 @@ */ /** -@defgroup graph_adaptors Adaptor Classes for graphs +@defgroup graph_adaptors Adaptor Classes for Graphs @ingroup graphs -\brief This group contains several adaptor classes for digraphs and graphs +\brief Adaptor classes for digraphs and graphs + +This group contains several useful adaptor classes for digraphs and graphs. The main parts of LEMON are the different graph structures, generic -graph algorithms, graph concepts which couple these, and graph +graph algorithms, graph concepts, which couple them, and graph adaptors. While the previous notions are more or less clear, the latter one needs further explanation. Graph adaptors are graph classes which serve for considering graph structures in different ways. A short example makes this much clearer. Suppose that we have an -instance \c g of a directed graph type say ListDigraph and an algorithm +instance \c g of a directed graph type, say ListDigraph and an algorithm \code template <typename Digraph> int algorithm(const Digraph&); @@ -81,13 +83,13 @@ is needed to run on the reverse oriented graph. It may be expensive (in time or in memory usage) to copy \c g with the reversed arcs. In this case, an adaptor class is used, which (according -to LEMON digraph concepts) works as a digraph. The adaptor uses the -original digraph structure and digraph operations when methods of the -reversed oriented graph are called. This means that the adaptor have -minor memory usage, and do not perform sophisticated algorithmic +to LEMON \ref concepts::Digraph "digraph concepts") works as a digraph. +The adaptor uses the original digraph structure and digraph operations when +methods of the reversed oriented graph are called. This means that the adaptor +have minor memory usage, and do not perform sophisticated algorithmic actions. The purpose of it is to give a tool for the cases when a graph have to be used in a specific alteration. If this alteration is -obtained by a usual construction like filtering the arc-set or +obtained by a usual construction like filtering the node or the arc set or considering a new orientation, then an adaptor is worthwhile to use. To come back to the reverse oriented graph, in this situation \code @@ -96,39 +98,40 @@ template class can be used. The code looks as follows \code ListDigraph g; -ReverseDigraph<ListGraph> rg(g); +ReverseDigraph<ListDigraph> rg(g); int result = algorithm(rg); \endcode -After running the algorithm, the original graph \c g is untouched. -This techniques gives rise to an elegant code, and based on stable +During running the algorithm, the original digraph \c g is untouched. +This techniques give rise to an elegant code, and based on stable graph adaptors, complex algorithms can be implemented easily. -In flow, circulation and bipartite matching problems, the residual +In flow, circulation and matching problems, the residual graph is of particular importance. Combining an adaptor implementing -this, shortest path algorithms and minimum mean cycle algorithms, +this with shortest path algorithms or minimum mean cycle algorithms, a range of weighted and cardinality optimization algorithms can be obtained. For other examples, the interested user is referred to the detailed documentation of particular adaptors. The behavior of graph adaptors can be very different. Some of them keep capabilities of the original graph while in other cases this would be -meaningless. This means that the concepts that they are models of depend -on the graph adaptor, and the wrapped graph(s). -If an arc of \c rg is deleted, this is carried out by deleting the -corresponding arc of \c g, thus the adaptor modifies the original graph. +meaningless. This means that the concepts that they meet depend +on the graph adaptor, and the wrapped graph. +For example, if an arc of a reversed digraph is deleted, this is carried +out by deleting the corresponding arc of the original digraph, thus the +adaptor modifies the original digraph. +However in case of a residual digraph, this operation has no sense. -But for a residual graph, this operation has no sense. Let us stand one more example here to simplify your work. -RevGraphAdaptor has constructor +ReverseDigraph has constructor \code ReverseDigraph(Digraph& digraph); \endcode -This means that in a situation, when a <tt>const ListDigraph&</tt> +This means that in a situation, when a <tt>const %ListDigraph&</tt> reference to a graph is given, then it have to be instantiated with -<tt>Digraph=const ListDigraph</tt>. +<tt>Digraph=const %ListDigraph</tt>. \code int algorithm1(const ListDigraph& g) { - RevGraphAdaptor<const ListDigraph> rg(g); + ReverseDigraph<const ListDigraph> rg(g); return algorithm2(rg); } \endcode diff -r 75a5df083951 -r 5a1e9fdcfd3a lemon/adaptors.h --- a/lemon/adaptors.h Thu Jan 08 17:19:26 2009 +0000 +++ b/lemon/adaptors.h Sun Jan 11 15:09:53 2009 +0000 @@ -21,7 +21,7 @@ /// \ingroup graph_adaptors /// \file -/// \brief Several graph adaptors +/// \brief Adaptor classes for digraphs and graphs /// /// This file contains several useful adaptors for digraphs and graphs. @@ -70,21 +70,21 @@ typedef NodeNumTagIndicator<Digraph> NodeNumTag; int nodeNum() const { return _digraph->nodeNum(); } - typedef EdgeNumTagIndicator<Digraph> EdgeNumTag; + typedef ArcNumTagIndicator<Digraph> ArcNumTag; int arcNum() const { return _digraph->arcNum(); } - typedef FindEdgeTagIndicator<Digraph> FindEdgeTag; - Arc findArc(const Node& u, const Node& v, const Arc& prev = INVALID) { + typedef FindArcTagIndicator<Digraph> FindArcTag; + Arc findArc(const Node& u, const Node& v, const Arc& prev = INVALID) const { return _digraph->findArc(u, v, prev); } Node addNode() { return _digraph->addNode(); } Arc addArc(const Node& u, const Node& v) { return _digraph->addArc(u, v); } - void erase(const Node& n) const { _digraph->erase(n); } - void erase(const Arc& a) const { _digraph->erase(a); } - - void clear() const { _digraph->clear(); } + void erase(const Node& n) { _digraph->erase(n); } + void erase(const Arc& a) { _digraph->erase(a); } + + void clear() { _digraph->clear(); } int id(const Node& n) const { return _digraph->id(n); } int id(const Arc& a) const { return _digraph->id(a); } @@ -198,15 +198,21 @@ typedef NodeNumTagIndicator<Graph> NodeNumTag; int nodeNum() const { return _graph->nodeNum(); } + typedef ArcNumTagIndicator<Graph> ArcNumTag; + int arcNum() const { return _graph->arcNum(); } + typedef EdgeNumTagIndicator<Graph> EdgeNumTag; - int arcNum() const { return _graph->arcNum(); } int edgeNum() const { return _graph->edgeNum(); } - typedef FindEdgeTagIndicator<Graph> FindEdgeTag; - Arc findArc(const Node& u, const Node& v, const Arc& prev = INVALID) { + typedef FindArcTagIndicator<Graph> FindArcTag; + Arc findArc(const Node& u, const Node& v, + const Arc& prev = INVALID) const { return _graph->findArc(u, v, prev); } - Edge findEdge(const Node& u, const Node& v, const Edge& prev = INVALID) { + + typedef FindEdgeTagIndicator<Graph> FindEdgeTag; + Edge findEdge(const Node& u, const Node& v, + const Edge& prev = INVALID) const { return _graph->findEdge(u, v, prev); } @@ -330,9 +336,9 @@ Arc addArc(const Node& u, const Node& v) { return Parent::addArc(v, u); } - typedef FindEdgeTagIndicator<Digraph> FindEdgeTag; + typedef FindArcTagIndicator<Digraph> FindArcTag; Arc findArc(const Node& u, const Node& v, - const Arc& prev = INVALID) { + const Arc& prev = INVALID) const { return Parent::findArc(v, u, prev); } @@ -340,41 +346,56 @@ /// \ingroup graph_adaptors /// - /// \brief A digraph adaptor which reverses the orientation of the arcs. + /// \brief Adaptor class for reversing the orientation of the arcs in + /// a digraph. /// - /// ReverseDigraph reverses the arcs in the adapted digraph. The - /// SubDigraph is conform to the \ref concepts::Digraph - /// "Digraph concept". + /// ReverseDigraph can be used for reversing the arcs in a digraph. + /// It conforms to the \ref concepts::Digraph "Digraph" concept. /// - /// \tparam _Digraph It must be conform to the \ref concepts::Digraph - /// "Digraph concept". The type can be specified to be const. - template<typename _Digraph> + /// The adapted digraph can also be modified through this adaptor + /// by adding or removing nodes or arcs, unless the \c GR template + /// parameter is set to be \c const. + /// + /// \tparam GR The type of the adapted digraph. + /// It must conform to the \ref concepts::Digraph "Digraph" concept. + /// It can also be specified to be \c const. + /// + /// \note The \c Node and \c Arc types of this adaptor and the adapted + /// digraph are convertible to each other. + template<typename GR> +#ifdef DOXYGEN + class ReverseDigraph { +#else class ReverseDigraph : - public DigraphAdaptorExtender<ReverseDigraphBase<_Digraph> > { + public DigraphAdaptorExtender<ReverseDigraphBase<GR> > { +#endif public: - typedef _Digraph Digraph; - typedef DigraphAdaptorExtender< - ReverseDigraphBase<_Digraph> > Parent; + /// The type of the adapted digraph. + typedef GR Digraph; + typedef DigraphAdaptorExtender<ReverseDigraphBase<GR> > Parent; protected: ReverseDigraph() { } public: /// \brief Constructor /// - /// Creates a reverse digraph adaptor for the given digraph + /// Creates a reverse digraph adaptor for the given digraph. explicit ReverseDigraph(Digraph& digraph) { Parent::setDigraph(digraph); } }; - /// \brief Just gives back a reverse digraph adaptor + /// \brief Returns a read-only ReverseDigraph adaptor /// - /// Just gives back a reverse digraph adaptor - template<typename Digraph> - ReverseDigraph<const Digraph> reverseDigraph(const Digraph& digraph) { - return ReverseDigraph<const Digraph>(digraph); + /// This function just returns a read-only \ref ReverseDigraph adaptor. + /// \ingroup graph_adaptors + /// \relates ReverseDigraph + template<typename GR> + ReverseDigraph<const GR> reverseDigraph(const GR& digraph) { + return ReverseDigraph<const GR>(digraph); } + template <typename _Digraph, typename _NodeFilterMap, typename _ArcFilterMap, bool _checked = true> class SubDigraphBase : public DigraphAdaptorBase<_Digraph> { @@ -457,21 +478,18 @@ Parent::nextOut(i); } - void hide(const Node& n) const { _node_filter->set(n, false); } - void hide(const Arc& a) const { _arc_filter->set(a, false); } - - void unHide(const Node& n) const { _node_filter->set(n, true); } - void unHide(const Arc& a) const { _arc_filter->set(a, true); } - - bool hidden(const Node& n) const { return !(*_node_filter)[n]; } - bool hidden(const Arc& a) const { return !(*_arc_filter)[a]; } + void status(const Node& n, bool v) const { _node_filter->set(n, v); } + void status(const Arc& a, bool v) const { _arc_filter->set(a, v); } + + bool status(const Node& n) const { return (*_node_filter)[n]; } + bool status(const Arc& a) const { return (*_arc_filter)[a]; } typedef False NodeNumTag; - typedef False EdgeNumTag; - - typedef FindEdgeTagIndicator<Digraph> FindEdgeTag; + typedef False ArcNumTag; + + typedef FindArcTagIndicator<Digraph> FindArcTag; Arc findArc(const Node& source, const Node& target, - const Arc& prev = INVALID) { + const Arc& prev = INVALID) const { if (!(*_node_filter)[source] || !(*_node_filter)[target]) { return INVALID; } @@ -600,21 +618,18 @@ while (i!=INVALID && !(*_arc_filter)[i]) Parent::nextOut(i); } - void hide(const Node& n) const { _node_filter->set(n, false); } - void hide(const Arc& e) const { _arc_filter->set(e, false); } - - void unHide(const Node& n) const { _node_filter->set(n, true); } - void unHide(const Arc& e) const { _arc_filter->set(e, true); } - - bool hidden(const Node& n) const { return !(*_node_filter)[n]; } - bool hidden(const Arc& e) const { return !(*_arc_filter)[e]; } + void status(const Node& n, bool v) const { _node_filter->set(n, v); } + void status(const Arc& a, bool v) const { _arc_filter->set(a, v); } + + bool status(const Node& n) const { return (*_node_filter)[n]; } + bool status(const Arc& a) const { return (*_arc_filter)[a]; } typedef False NodeNumTag; - typedef False EdgeNumTag; - - typedef FindEdgeTagIndicator<Digraph> FindEdgeTag; + typedef False ArcNumTag; + + typedef FindArcTagIndicator<Digraph> FindArcTag; Arc findArc(const Node& source, const Node& target, - const Arc& prev = INVALID) { + const Arc& prev = INVALID) const { if (!(*_node_filter)[source] || !(*_node_filter)[target]) { return INVALID; } @@ -679,42 +694,57 @@ /// \ingroup graph_adaptors /// - /// \brief An adaptor for hiding nodes and arcs in a digraph + /// \brief Adaptor class for hiding nodes and arcs in a digraph /// - /// SubDigraph hides nodes and arcs in a digraph. A bool node map - /// and a bool arc map must be specified, which define the filters - /// for nodes and arcs. Just the nodes and arcs with true value are - /// shown in the subdigraph. The SubDigraph is conform to the \ref - /// concepts::Digraph "Digraph concept". If the \c _checked parameter - /// is true, then the arcs incident to filtered nodes are also - /// filtered out. + /// SubDigraph can be used for hiding nodes and arcs in a digraph. + /// A \c bool node map and a \c bool arc map must be specified, which + /// define the filters for nodes and arcs. + /// Only the nodes and arcs with \c true filter value are + /// shown in the subdigraph. The arcs that are incident to hidden + /// nodes are also filtered out. + /// This adaptor conforms to the \ref concepts::Digraph "Digraph" concept. /// - /// \tparam _Digraph It must be conform to the \ref - /// concepts::Digraph "Digraph concept". The type can be specified - /// to const. - /// \tparam _NodeFilterMap A bool valued node map of the the adapted digraph. - /// \tparam _ArcFilterMap A bool valued arc map of the the adapted digraph. - /// \tparam _checked If the parameter is false then the arc filtering - /// is not checked with respect to node filter. Otherwise, each arc - /// is automatically filtered, which is incident to a filtered node. + /// The adapted digraph can also be modified through this adaptor + /// by adding or removing nodes or arcs, unless the \c GR template + /// parameter is set to be \c const. + /// + /// \tparam GR The type of the adapted digraph. + /// It must conform to the \ref concepts::Digraph "Digraph" concept. + /// It can also be specified to be \c const. + /// \tparam NF The type of the node filter map. + /// It must be a \c bool (or convertible) node map of the + /// adapted digraph. The default type is + /// \ref concepts::Digraph::NodeMap "GR::NodeMap<bool>". + /// \tparam AF The type of the arc filter map. + /// It must be \c bool (or convertible) arc map of the + /// adapted digraph. The default type is + /// \ref concepts::Digraph::ArcMap "GR::ArcMap<bool>". + /// + /// \note The \c Node and \c Arc types of this adaptor and the adapted + /// digraph are convertible to each other. /// /// \see FilterNodes /// \see FilterArcs - template<typename _Digraph, - typename _NodeFilterMap = typename _Digraph::template NodeMap<bool>, - typename _ArcFilterMap = typename _Digraph::template ArcMap<bool>, - bool _checked = true> - class SubDigraph - : public DigraphAdaptorExtender< - SubDigraphBase<_Digraph, _NodeFilterMap, _ArcFilterMap, _checked> > { +#ifdef DOXYGEN + template<typename GR, typename NF, typename AF> + class SubDigraph { +#else + template<typename GR, + typename NF = typename GR::template NodeMap<bool>, + typename AF = typename GR::template ArcMap<bool> > + class SubDigraph : + public DigraphAdaptorExtender<SubDigraphBase<GR, NF, AF, true> > { +#endif public: - typedef _Digraph Digraph; - typedef _NodeFilterMap NodeFilterMap; - typedef _ArcFilterMap ArcFilterMap; - - typedef DigraphAdaptorExtender< - SubDigraphBase<Digraph, NodeFilterMap, ArcFilterMap, _checked> > - Parent; + /// The type of the adapted digraph. + typedef GR Digraph; + /// The type of the node filter map. + typedef NF NodeFilterMap; + /// The type of the arc filter map. + typedef AF ArcFilterMap; + + typedef DigraphAdaptorExtender<SubDigraphBase<GR, NF, AF, true> > + Parent; typedef typename Parent::Node Node; typedef typename Parent::Arc Arc; @@ -725,8 +755,8 @@ /// \brief Constructor /// - /// Creates a subdigraph for the given digraph with - /// given node and arc map filters. + /// Creates a subdigraph for the given digraph with the + /// given node and arc filter maps. SubDigraph(Digraph& digraph, NodeFilterMap& node_filter, ArcFilterMap& arc_filter) { setDigraph(digraph); @@ -734,88 +764,106 @@ setArcFilterMap(arc_filter); } - /// \brief Hides the node of the graph + /// \brief Sets the status of the given node /// - /// This function hides \c n in the digraph, i.e. the iteration - /// jumps over it. This is done by simply setting the value of \c n - /// to be false in the corresponding node-map. - void hide(const Node& n) const { Parent::hide(n); } - - /// \brief Hides the arc of the graph + /// This function sets the status of the given node. + /// It is done by simply setting the assigned value of \c n + /// to \c v in the node filter map. + void status(const Node& n, bool v) const { Parent::status(n, v); } + + /// \brief Sets the status of the given arc /// - /// This function hides \c a in the digraph, i.e. the iteration - /// jumps over it. This is done by simply setting the value of \c a - /// to be false in the corresponding arc-map. - void hide(const Arc& a) const { Parent::hide(a); } - - /// \brief Unhides the node of the graph + /// This function sets the status of the given arc. + /// It is done by simply setting the assigned value of \c a + /// to \c v in the arc filter map. + void status(const Arc& a, bool v) const { Parent::status(a, v); } + + /// \brief Returns the status of the given node /// - /// The value of \c n is set to be true in the node-map which stores - /// hide information. If \c n was hidden previuosly, then it is shown - /// again - void unHide(const Node& n) const { Parent::unHide(n); } - - /// \brief Unhides the arc of the graph + /// This function returns the status of the given node. + /// It is \c true if the given node is enabled (i.e. not hidden). + bool status(const Node& n) const { return Parent::status(n); } + + /// \brief Returns the status of the given arc /// - /// The value of \c a is set to be true in the arc-map which stores - /// hide information. If \c a was hidden previuosly, then it is shown - /// again - void unHide(const Arc& a) const { Parent::unHide(a); } - - /// \brief Returns true if \c n is hidden. + /// This function returns the status of the given arc. + /// It is \c true if the given arc is enabled (i.e. not hidden). + bool status(const Arc& a) const { return Parent::status(a); } + + /// \brief Disables the given node /// - /// Returns true if \c n is hidden. + /// This function disables the given node in the subdigraph, + /// so the iteration jumps over it. + /// It is the same as \ref status() "status(n, false)". + void disable(const Node& n) const { Parent::status(n, false); } + + /// \brief Disables the given arc /// - bool hidden(const Node& n) const { return Parent::hidden(n); } - - /// \brief Returns true if \c a is hidden. + /// This function disables the given arc in the subdigraph, + /// so the iteration jumps over it. + /// It is the same as \ref status() "status(a, false)". + void disable(const Arc& a) const { Parent::status(a, false); } + + /// \brief Enables the given node /// - /// Returns true if \c a is hidden. + /// This function enables the given node in the subdigraph. + /// It is the same as \ref status() "status(n, true)". + void enable(const Node& n) const { Parent::status(n, true); } + + /// \brief Enables the given arc /// - bool hidden(const Arc& a) const { return Parent::hidden(a); } + /// This function enables the given arc in the subdigraph. + /// It is the same as \ref status() "status(a, true)". + void enable(const Arc& a) const { Parent::status(a, true); } }; - /// \brief Just gives back a subdigraph + /// \brief Returns a read-only SubDigraph adaptor /// - /// Just gives back a subdigraph - template<typename Digraph, typename NodeFilterMap, typename ArcFilterMap> - SubDigraph<const Digraph, NodeFilterMap, ArcFilterMap> - subDigraph(const Digraph& digraph, NodeFilterMap& nfm, ArcFilterMap& afm) { - return SubDigraph<const Digraph, NodeFilterMap, ArcFilterMap> - (digraph, nfm, afm); + /// This function just returns a read-only \ref SubDigraph adaptor. + /// \ingroup graph_adaptors + /// \relates SubDigraph + template<typename GR, typename NF, typename AF> + SubDigraph<const GR, NF, AF> + subDigraph(const GR& digraph, + NF& node_filter_map, AF& arc_filter_map) { + return SubDigraph<const GR, NF, AF> + (digraph, node_filter_map, arc_filter_map); } - template<typename Digraph, typename NodeFilterMap, typename ArcFilterMap> - SubDigraph<const Digraph, const NodeFilterMap, ArcFilterMap> - subDigraph(const Digraph& digraph, - const NodeFilterMap& nfm, ArcFilterMap& afm) { - return SubDigraph<const Digraph, const NodeFilterMap, ArcFilterMap> - (digraph, nfm, afm); + template<typename GR, typename NF, typename AF> + SubDigraph<const GR, const NF, AF> + subDigraph(const GR& digraph, + const NF& node_filter_map, AF& arc_filter_map) { + return SubDigraph<const GR, const NF, AF> + (digraph, node_filter_map, arc_filter_map); } - template<typename Digraph, typename NodeFilterMap, typename ArcFilterMap> - SubDigraph<const Digraph, NodeFilterMap, const ArcFilterMap> - subDigraph(const Digraph& digraph, - NodeFilterMap& nfm, const ArcFilterMap& afm) { - return SubDigraph<const Digraph, NodeFilterMap, const ArcFilterMap> - (digraph, nfm, afm); + template<typename GR, typename NF, typename AF> + SubDigraph<const GR, NF, const AF> + subDigraph(const GR& digraph, + NF& node_filter_map, const AF& arc_filter_map) { + return SubDigraph<const GR, NF, const AF> + (digraph, node_filter_map, arc_filter_map); } - template<typename Digraph, typename NodeFilterMap, typename ArcFilterMap> - SubDigraph<const Digraph, const NodeFilterMap, const ArcFilterMap> - subDigraph(const Digraph& digraph, - const NodeFilterMap& nfm, const ArcFilterMap& afm) { - return SubDigraph<const Digraph, const NodeFilterMap, - const ArcFilterMap>(digraph, nfm, afm); + template<typename GR, typename NF, typename AF> + SubDigraph<const GR, const NF, const AF> + subDigraph(const GR& digraph, + const NF& node_filter_map, const AF& arc_filter_map) { + return SubDigraph<const GR, const NF, const AF> + (digraph, node_filter_map, arc_filter_map); } - template <typename _Graph, typename NodeFilterMap, - typename EdgeFilterMap, bool _checked = true> + template <typename _Graph, typename _NodeFilterMap, + typename _EdgeFilterMap, bool _checked = true> class SubGraphBase : public GraphAdaptorBase<_Graph> { public: typedef _Graph Graph; + typedef _NodeFilterMap NodeFilterMap; + typedef _EdgeFilterMap EdgeFilterMap; + typedef SubGraphBase Adaptor; typedef GraphAdaptorBase<_Graph> Parent; protected: @@ -925,21 +973,19 @@ Parent::nextInc(i, d); } - void hide(const Node& n) const { _node_filter_map->set(n, false); } - void hide(const Edge& e) const { _edge_filter_map->set(e, false); } - - void unHide(const Node& n) const { _node_filter_map->set(n, true); } - void unHide(const Edge& e) const { _edge_filter_map->set(e, true); } - - bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; } - bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; } + void status(const Node& n, bool v) const { _node_filter_map->set(n, v); } + void status(const Edge& e, bool v) const { _edge_filter_map->set(e, v); } + + bool status(const Node& n) const { return (*_node_filter_map)[n]; } + bool status(const Edge& e) const { return (*_edge_filter_map)[e]; } typedef False NodeNumTag; + typedef False ArcNumTag; typedef False EdgeNumTag; - typedef FindEdgeTagIndicator<Graph> FindEdgeTag; + typedef FindArcTagIndicator<Graph> FindArcTag; Arc findArc(const Node& u, const Node& v, - const Arc& prev = INVALID) { + const Arc& prev = INVALID) const { if (!(*_node_filter_map)[u] || !(*_node_filter_map)[v]) { return INVALID; } @@ -949,8 +995,10 @@ } return arc; } + + typedef FindEdgeTagIndicator<Graph> FindEdgeTag; Edge findEdge(const Node& u, const Node& v, - const Edge& prev = INVALID) { + const Edge& prev = INVALID) const { if (!(*_node_filter_map)[u] || !(*_node_filter_map)[v]) { return INVALID; } @@ -1039,11 +1087,14 @@ }; - template <typename _Graph, typename NodeFilterMap, typename EdgeFilterMap> - class SubGraphBase<_Graph, NodeFilterMap, EdgeFilterMap, false> + template <typename _Graph, typename _NodeFilterMap, typename _EdgeFilterMap> + class SubGraphBase<_Graph, _NodeFilterMap, _EdgeFilterMap, false> : public GraphAdaptorBase<_Graph> { public: typedef _Graph Graph; + typedef _NodeFilterMap NodeFilterMap; + typedef _EdgeFilterMap EdgeFilterMap; + typedef SubGraphBase Adaptor; typedef GraphAdaptorBase<_Graph> Parent; protected: @@ -1121,29 +1172,29 @@ while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextInc(i, d); } - void hide(const Node& n) const { _node_filter_map->set(n, false); } - void hide(const Edge& e) const { _edge_filter_map->set(e, false); } - - void unHide(const Node& n) const { _node_filter_map->set(n, true); } - void unHide(const Edge& e) const { _edge_filter_map->set(e, true); } - - bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; } - bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; } + void status(const Node& n, bool v) const { _node_filter_map->set(n, v); } + void status(const Edge& e, bool v) const { _edge_filter_map->set(e, v); } + + bool status(const Node& n) const { return (*_node_filter_map)[n]; } + bool status(const Edge& e) const { return (*_edge_filter_map)[e]; } typedef False NodeNumTag; + typedef False ArcNumTag; typedef False EdgeNumTag; - typedef FindEdgeTagIndicator<Graph> FindEdgeTag; + typedef FindArcTagIndicator<Graph> FindArcTag; Arc findArc(const Node& u, const Node& v, - const Arc& prev = INVALID) { + const Arc& prev = INVALID) const { Arc arc = Parent::findArc(u, v, prev); while (arc != INVALID && !(*_edge_filter_map)[arc]) { arc = Parent::findArc(u, v, arc); } return arc; } + + typedef FindEdgeTagIndicator<Graph> FindEdgeTag; Edge findEdge(const Node& u, const Node& v, - const Edge& prev = INVALID) { + const Edge& prev = INVALID) const { Edge edge = Parent::findEdge(u, v, prev); while (edge != INVALID && !(*_edge_filter_map)[edge]) { edge = Parent::findEdge(u, v, edge); @@ -1231,37 +1282,58 @@ /// \ingroup graph_adaptors /// - /// \brief A graph adaptor for hiding nodes and edges in an - /// undirected graph. + /// \brief Adaptor class for hiding nodes and edges in an undirected + /// graph. /// - /// SubGraph hides nodes and edges in a graph. A bool node map and a - /// bool edge map must be specified, which define the filters for - /// nodes and edges. Just the nodes and edges with true value are - /// shown in the subgraph. The SubGraph is conform to the \ref - /// concepts::Graph "Graph concept". If the \c _checked parameter is - /// true, then the edges incident to filtered nodes are also - /// filtered out. + /// SubGraph can be used for hiding nodes and edges in a graph. + /// A \c bool node map and a \c bool edge map must be specified, which + /// define the filters for nodes and edges. + /// Only the nodes and edges with \c true filter value are + /// shown in the subgraph. The edges that are incident to hidden + /// nodes are also filtered out. + /// This adaptor conforms to the \ref concepts::Graph "Graph" concept. /// - /// \tparam _Graph It must be conform to the \ref - /// concepts::Graph "Graph concept". The type can be specified - /// to const. - /// \tparam _NodeFilterMap A bool valued node map of the the adapted graph. - /// \tparam _EdgeFilterMap A bool valued edge map of the the adapted graph. - /// \tparam _checked If the parameter is false then the edge filtering - /// is not checked with respect to node filter. Otherwise, each edge - /// is automatically filtered, which is incident to a filtered node. + /// The adapted graph can also be modified through this adaptor + /// by adding or removing nodes or edges, unless the \c GR template + /// parameter is set to be \c const. + /// + /// \tparam GR The type of the adapted graph. + /// It must conform to the \ref concepts::Graph "Graph" concept. + /// It can also be specified to be \c const. + /// \tparam NF The type of the node filter map. + /// It must be a \c bool (or convertible) node map of the + /// adapted graph. The default type is + /// \ref concepts::Graph::NodeMap "GR::NodeMap<bool>". + /// \tparam EF The type of the edge filter map. + /// It must be a \c bool (or convertible) edge map of the + /// adapted graph. The default type is + /// \ref concepts::Graph::EdgeMap "GR::EdgeMap<bool>". + /// + /// \note The \c Node, \c Edge and \c Arc types of this adaptor and the + /// adapted graph are convertible to each other. /// /// \see FilterNodes /// \see FilterEdges - template<typename _Graph, typename NodeFilterMap, - typename EdgeFilterMap, bool _checked = true> - class SubGraph - : public GraphAdaptorExtender< - SubGraphBase<_Graph, NodeFilterMap, EdgeFilterMap, _checked> > { +#ifdef DOXYGEN + template<typename GR, typename NF, typename EF> + class SubGraph { +#else + template<typename GR, + typename NF = typename GR::template NodeMap<bool>, + typename EF = typename GR::template EdgeMap<bool> > + class SubGraph : + public GraphAdaptorExtender<SubGraphBase<GR, NF, EF, true> > { +#endif public: - typedef _Graph Graph; - typedef GraphAdaptorExtender< - SubGraphBase<_Graph, NodeFilterMap, EdgeFilterMap> > Parent; + /// The type of the adapted graph. + typedef GR Graph; + /// The type of the node filter map. + typedef NF NodeFilterMap; + /// The type of the edge filter map. + typedef EF EdgeFilterMap; + + typedef GraphAdaptorExtender< SubGraphBase<GR, NF, EF, true> > + Parent; typedef typename Parent::Node Node; typedef typename Parent::Edge Edge; @@ -1272,132 +1344,153 @@ /// \brief Constructor /// - /// Creates a subgraph for the given graph with given node and - /// edge map filters. - SubGraph(Graph& _graph, NodeFilterMap& node_filter_map, + /// Creates a subgraph for the given graph with the given node + /// and edge filter maps. + SubGraph(Graph& graph, NodeFilterMap& node_filter_map, EdgeFilterMap& edge_filter_map) { - setGraph(_graph); + setGraph(graph); setNodeFilterMap(node_filter_map); setEdgeFilterMap(edge_filter_map); } - /// \brief Hides the node of the graph + /// \brief Sets the status of the given node /// - /// This function hides \c n in the graph, i.e. the iteration - /// jumps over it. This is done by simply setting the value of \c n - /// to be false in the corresponding node-map. - void hide(const Node& n) const { Parent::hide(n); } - - /// \brief Hides the edge of the graph + /// This function sets the status of the given node. + /// It is done by simply setting the assigned value of \c n + /// to \c v in the node filter map. + void status(const Node& n, bool v) const { Parent::status(n, v); } + + /// \brief Sets the status of the given edge /// - /// This function hides \c e in the graph, i.e. the iteration - /// jumps over it. This is done by simply setting the value of \c e - /// to be false in the corresponding edge-map. - void hide(const Edge& e) const { Parent::hide(e); } - - /// \brief Unhides the node of the graph + /// This function sets the status of the given edge. + /// It is done by simply setting the assigned value of \c e + /// to \c v in the edge filter map. + void status(const Edge& e, bool v) const { Parent::status(e, v); } + + /// \brief Returns the status of the given node /// - /// The value of \c n is set to be true in the node-map which stores - /// hide information. If \c n was hidden previuosly, then it is shown - /// again - void unHide(const Node& n) const { Parent::unHide(n); } - - /// \brief Unhides the edge of the graph + /// This function returns the status of the given node. + /// It is \c true if the given node is enabled (i.e. not hidden). + bool status(const Node& n) const { return Parent::status(n); } + + /// \brief Returns the status of the given edge /// - /// The value of \c e is set to be true in the edge-map which stores - /// hide information. If \c e was hidden previuosly, then it is shown - /// again - void unHide(const Edge& e) const { Parent::unHide(e); } - - /// \brief Returns true if \c n is hidden. + /// This function returns the status of the given edge. + /// It is \c true if the given edge is enabled (i.e. not hidden). + bool status(const Edge& e) const { return Parent::status(e); } + + /// \brief Disables the given node /// - /// Returns true if \c n is hidden. + /// This function disables the given node in the subdigraph, + /// so the iteration jumps over it. + /// It is the same as \ref status() "status(n, false)". + void disable(const Node& n) const { Parent::status(n, false); } + + /// \brief Disables the given edge /// - bool hidden(const Node& n) const { return Parent::hidden(n); } - - /// \brief Returns true if \c e is hidden. + /// This function disables the given edge in the subgraph, + /// so the iteration jumps over it. + /// It is the same as \ref status() "status(e, false)". + void disable(const Edge& e) const { Parent::status(e, false); } + + /// \brief Enables the given node /// - /// Returns true if \c e is hidden. + /// This function enables the given node in the subdigraph. + /// It is the same as \ref status() "status(n, true)". + void enable(const Node& n) const { Parent::status(n, true); } + + /// \brief Enables the given edge /// - bool hidden(const Edge& e) const { return Parent::hidden(e); } + /// This function enables the given edge in the subgraph. + /// It is the same as \ref status() "status(e, true)". + void enable(const Edge& e) const { Parent::status(e, true); } + }; - /// \brief Just gives back a subgraph + /// \brief Returns a read-only SubGraph adaptor /// - /// Just gives back a subgraph - template<typename Graph, typename NodeFilterMap, typename ArcFilterMap> - SubGraph<const Graph, NodeFilterMap, ArcFilterMap> - subGraph(const Graph& graph, NodeFilterMap& nfm, ArcFilterMap& efm) { - return SubGraph<const Graph, NodeFilterMap, ArcFilterMap>(graph, nfm, efm); + /// This function just returns a read-only \ref SubGraph adaptor. + /// \ingroup graph_adaptors + /// \relates SubGraph + template<typename GR, typename NF, typename EF> + SubGraph<const GR, NF, EF> + subGraph(const GR& graph, + NF& node_filter_map, EF& edge_filter_map) { + return SubGraph<const GR, NF, EF> + (graph, node_filter_map, edge_filter_map); } - template<typename Graph, typename NodeFilterMap, typename ArcFilterMap> - SubGraph<const Graph, const NodeFilterMap, ArcFilterMap> - subGraph(const Graph& graph, - const NodeFilterMap& nfm, ArcFilterMap& efm) { - return SubGraph<const Graph, const NodeFilterMap, ArcFilterMap> - (graph, nfm, efm); + template<typename GR, typename NF, typename EF> + SubGraph<const GR, const NF, EF> + subGraph(const GR& graph, + const NF& node_filter_map, EF& edge_filter_map) { + return SubGraph<const GR, const NF, EF> + (graph, node_filter_map, edge_filter_map); } - template<typename Graph, typename NodeFilterMap, typename ArcFilterMap> - SubGraph<const Graph, NodeFilterMap, const ArcFilterMap> - subGraph(const Graph& graph, - NodeFilterMap& nfm, const ArcFilterMap& efm) { - return SubGraph<const Graph, NodeFilterMap, const ArcFilterMap> - (graph, nfm, efm); + template<typename GR, typename NF, typename EF> + SubGraph<const GR, NF, const EF> + subGraph(const GR& graph, + NF& node_filter_map, const EF& edge_filter_map) { + return SubGraph<const GR, NF, const EF> + (graph, node_filter_map, edge_filter_map); } - template<typename Graph, typename NodeFilterMap, typename ArcFilterMap> - SubGraph<const Graph, const NodeFilterMap, const ArcFilterMap> - subGraph(const Graph& graph, - const NodeFilterMap& nfm, const ArcFilterMap& efm) { - return SubGraph<const Graph, const NodeFilterMap, const ArcFilterMap> - (graph, nfm, efm); + template<typename GR, typename NF, typename EF> + SubGraph<const GR, const NF, const EF> + subGraph(const GR& graph, + const NF& node_filter_map, const EF& edge_filter_map) { + return SubGraph<const GR, const NF, const EF> + (graph, node_filter_map, edge_filter_map); } + /// \ingroup graph_adaptors /// - /// \brief An adaptor for hiding nodes from a digraph or a graph. + /// \brief Adaptor class for hiding nodes in a digraph or a graph. /// - /// FilterNodes adaptor hides nodes in a graph or a digraph. A bool - /// node map must be specified, which defines the filters for - /// nodes. Just the unfiltered nodes and the arcs or edges incident - /// to unfiltered nodes are shown in the subdigraph or subgraph. The - /// FilterNodes is conform to the \ref concepts::Digraph - /// "Digraph concept" or \ref concepts::Graph "Graph concept" depending - /// on the \c _Digraph template parameter. If the \c _checked - /// parameter is true, then the arc or edges incident to filtered nodes - /// are also filtered out. + /// FilterNodes adaptor can be used for hiding nodes in a digraph or a + /// graph. A \c bool node map must be specified, which defines the filter + /// for the nodes. Only the nodes with \c true filter value and the + /// arcs/edges incident to nodes both with \c true filter value are shown + /// in the subgraph. This adaptor conforms to the \ref concepts::Digraph + /// "Digraph" concept or the \ref concepts::Graph "Graph" concept + /// depending on the \c GR template parameter. /// - /// \tparam _Digraph It must be conform to the \ref - /// concepts::Digraph "Digraph concept" or \ref concepts::Graph - /// "Graph concept". The type can be specified to be const. - /// \tparam _NodeFilterMap A bool valued node map of the the adapted graph. - /// \tparam _checked If the parameter is false then the arc or edge - /// filtering is not checked with respect to node filter. In this - /// case just isolated nodes can be filtered out from the - /// graph. + /// The adapted (di)graph can also be modified through this adaptor + /// by adding or removing nodes or arcs/edges, unless the \c GR template + /// parameter is set to be \c const. + /// + /// \tparam GR The type of the adapted digraph or graph. + /// It must conform to the \ref concepts::Digraph "Digraph" concept + /// or the \ref concepts::Graph "Graph" concept. + /// It can also be specified to be \c const. + /// \tparam NF The type of the node filter map. + /// It must be a \c bool (or convertible) node map of the + /// adapted (di)graph. The default type is + /// \ref concepts::Graph::NodeMap "GR::NodeMap<bool>". + /// + /// \note The \c Node and <tt>Arc/Edge</tt> types of this adaptor and the + /// adapted (di)graph are convertible to each other. #ifdef DOXYGEN - template<typename _Digraph, - typename _NodeFilterMap = typename _Digraph::template NodeMap<bool>, - bool _checked = true> + template<typename GR, typename NF> + class FilterNodes { #else - template<typename _Digraph, - typename _NodeFilterMap = typename _Digraph::template NodeMap<bool>, - bool _checked = true, + template<typename GR, + typename NF = typename GR::template NodeMap<bool>, typename Enable = void> + class FilterNodes : + public DigraphAdaptorExtender< + SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, bool>, true> > { #endif - class FilterNodes - : public SubDigraph<_Digraph, _NodeFilterMap, - ConstMap<typename _Digraph::Arc, bool>, _checked> { public: - typedef _Digraph Digraph; - typedef _NodeFilterMap NodeFilterMap; - - typedef SubDigraph<Digraph, NodeFilterMap, - ConstMap<typename Digraph::Arc, bool>, _checked> - Parent; + typedef GR Digraph; + typedef NF NodeFilterMap; + + typedef DigraphAdaptorExtender< + SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, bool>, true> > + Parent; typedef typename Parent::Node Node; @@ -1412,47 +1505,56 @@ /// \brief Constructor /// - /// Creates an adaptor for the given digraph or graph with + /// Creates a subgraph for the given digraph or graph with the /// given node filter map. - FilterNodes(Digraph& _digraph, NodeFilterMap& node_filter) : - Parent(), const_true_map(true) { - Parent::setDigraph(_digraph); + FilterNodes(GR& graph, NodeFilterMap& node_filter) : + Parent(), const_true_map(true) + { + Parent::setDigraph(graph); Parent::setNodeFilterMap(node_filter); Parent::setArcFilterMap(const_true_map); } - /// \brief Hides the node of the graph + /// \brief Sets the status of the given node /// - /// This function hides \c n in the digraph or graph, i.e. the iteration - /// jumps over it. This is done by simply setting the value of \c n - /// to be false in the corresponding node map. - void hide(const Node& n) const { Parent::hide(n); } - - /// \brief Unhides the node of the graph + /// This function sets the status of the given node. + /// It is done by simply setting the assigned value of \c n + /// to \c v in the node filter map. + void status(const Node& n, bool v) const { Parent::status(n, v); } + + /// \brief Returns the status of the given node /// - /// The value of \c n is set to be true in the node-map which stores - /// hide information. If \c n was hidden previuosly, then it is shown - /// again - void unHide(const Node& n) const { Parent::unHide(n); } - - /// \brief Returns true if \c n is hidden. + /// This function returns the status of the given node. + /// It is \c true if the given node is enabled (i.e. not hidden). + bool status(const Node& n) const { return Parent::status(n); } + + /// \brief Disables the given node /// - /// Returns true if \c n is hidden. + /// This function disables the given node, so the iteration + /// jumps over it. + /// It is the same as \ref status() "status(n, false)". + void disable(const Node& n) const { Parent::status(n, false); } + + /// \brief Enables the given node /// - bool hidden(const Node& n) const { return Parent::hidden(n); } + /// This function enables the given node. + /// It is the same as \ref status() "status(n, true)". + void enable(const Node& n) const { Parent::status(n, true); } }; - template<typename _Graph, typename _NodeFilterMap, bool _checked> - class FilterNodes<_Graph, _NodeFilterMap, _checked, - typename enable_if<UndirectedTagIndicator<_Graph> >::type> - : public SubGraph<_Graph, _NodeFilterMap, - ConstMap<typename _Graph::Edge, bool>, _checked> { + template<typename GR, typename NF> + class FilterNodes<GR, NF, + typename enable_if<UndirectedTagIndicator<GR> >::type> : + public GraphAdaptorExtender< + SubGraphBase<GR, NF, ConstMap<typename GR::Edge, bool>, true> > { + public: - typedef _Graph Graph; - typedef _NodeFilterMap NodeFilterMap; - typedef SubGraph<Graph, NodeFilterMap, - ConstMap<typename Graph::Edge, bool> > Parent; + typedef GR Graph; + typedef NF NodeFilterMap; + typedef GraphAdaptorExtender< + SubGraphBase<GR, NF, ConstMap<typename GR::Edge, bool>, true> > + Parent; typedef typename Parent::Node Node; protected: @@ -1471,51 +1573,75 @@ Parent::setEdgeFilterMap(const_true_map); } - void hide(const Node& n) const { Parent::hide(n); } - void unHide(const Node& n) const { Parent::unHide(n); } - bool hidden(const Node& n) const { return Parent::hidden(n); } + void status(const Node& n, bool v) const { Parent::status(n, v); } + bool status(const Node& n) const { return Parent::status(n); } + void disable(const Node& n) const { Parent::status(n, false); } + void enable(const Node& n) const { Parent::status(n, true); } }; - /// \brief Just gives back a FilterNodes adaptor + /// \brief Returns a read-only FilterNodes adaptor /// - /// Just gives back a FilterNodes adaptor - template<typename Digraph, typename NodeFilterMap> - FilterNodes<const Digraph, NodeFilterMap> - filterNodes(const Digraph& digraph, NodeFilterMap& nfm) { - return FilterNodes<const Digraph, NodeFilterMap>(digraph, nfm); + /// This function just returns a read-only \ref FilterNodes adaptor. + /// \ingroup graph_adaptors + /// \relates FilterNodes + template<typename GR, typename NF> + FilterNodes<const GR, NF> + filterNodes(const GR& graph, NF& node_filter_map) { + return FilterNodes<const GR, NF>(graph, node_filter_map); } - template<typename Digraph, typename NodeFilterMap> - FilterNodes<const Digraph, const NodeFilterMap> - filterNodes(const Digraph& digraph, const NodeFilterMap& nfm) { - return FilterNodes<const Digraph, const NodeFilterMap>(digraph, nfm); + template<typename GR, typename NF> + FilterNodes<const GR, const NF> + filterNodes(const GR& graph, const NF& node_filter_map) { + return FilterNodes<const GR, const NF>(graph, node_filter_map); } /// \ingroup graph_adaptors /// - /// \brief An adaptor for hiding arcs from a digraph. + /// \brief Adaptor class for hiding arcs in a digraph. /// - /// FilterArcs adaptor hides arcs in a digraph. A bool arc map must - /// be specified, which defines the filters for arcs. Just the - /// unfiltered arcs are shown in the subdigraph. The FilterArcs is - /// conform to the \ref concepts::Digraph "Digraph concept". + /// FilterArcs adaptor can be used for hiding arcs in a digraph. + /// A \c bool arc map must be specified, which defines the filter for + /// the arcs. Only the arcs with \c true filter value are shown in the + /// subdigraph. This adaptor conforms to the \ref concepts::Digraph + /// "Digraph" concept. /// - /// \tparam _Digraph It must be conform to the \ref concepts::Digraph - /// "Digraph concept". The type can be specified to be const. - /// \tparam _ArcFilterMap A bool valued arc map of the the adapted - /// graph. - template<typename _Digraph, typename _ArcFilterMap> + /// The adapted digraph can also be modified through this adaptor + /// by adding or removing nodes or arcs, unless the \c GR template + /// parameter is set to be \c const. + /// + /// \tparam GR The type of the adapted digraph. + /// It must conform to the \ref concepts::Digraph "Digraph" concept. + /// It can also be specified to be \c const. + /// \tparam AF The type of the arc filter map. + /// It must be a \c bool (or convertible) arc map of the + /// adapted digraph. The default type is + /// \ref concepts::Digraph::ArcMap "GR::ArcMap<bool>". + /// + /// \note The \c Node and \c Arc types of this adaptor and the adapted + /// digraph are convertible to each other. +#ifdef DOXYGEN + template<typename GR, + typename AF> + class FilterArcs { +#else + template<typename GR, + typename AF = typename GR::template ArcMap<bool> > class FilterArcs : - public SubDigraph<_Digraph, ConstMap<typename _Digraph::Node, bool>, - _ArcFilterMap, false> { + public DigraphAdaptorExtender< + SubDigraphBase<GR, ConstMap<typename GR::Node, bool>, AF, false> > { +#endif public: - typedef _Digraph Digraph; - typedef _ArcFilterMap ArcFilterMap; - - typedef SubDigraph<Digraph, ConstMap<typename Digraph::Node, bool>, - ArcFilterMap, false> Parent; + /// The type of the adapted digraph. + typedef GR Digraph; + /// The type of the arc filter map. + typedef AF ArcFilterMap; + + typedef DigraphAdaptorExtender< + SubDigraphBase<GR, ConstMap<typename GR::Node, bool>, AF, false> > + Parent; typedef typename Parent::Arc Arc; @@ -1530,8 +1656,8 @@ /// \brief Constructor /// - /// Creates a FilterArcs adaptor for the given graph with - /// given arc map filter. + /// Creates a subdigraph for the given digraph with the given arc + /// filter map. FilterArcs(Digraph& digraph, ArcFilterMap& arc_filter) : Parent(), const_true_map(true) { Parent::setDigraph(digraph); @@ -1539,66 +1665,98 @@ Parent::setArcFilterMap(arc_filter); } - /// \brief Hides the arc of the graph + /// \brief Sets the status of the given arc /// - /// This function hides \c a in the graph, i.e. the iteration - /// jumps over it. This is done by simply setting the value of \c a - /// to be false in the corresponding arc map. - void hide(const Arc& a) const { Parent::hide(a); } - - /// \brief Unhides the arc of the graph + /// This function sets the status of the given arc. + /// It is done by simply setting the assigned value of \c a + /// to \c v in the arc filter map. + void status(const Arc& a, bool v) const { Parent::status(a, v); } + + /// \brief Returns the status of the given arc /// - /// The value of \c a is set to be true in the arc-map which stores - /// hide information. If \c a was hidden previuosly, then it is shown - /// again - void unHide(const Arc& a) const { Parent::unHide(a); } - - /// \brief Returns true if \c a is hidden. + /// This function returns the status of the given arc. + /// It is \c true if the given arc is enabled (i.e. not hidden). + bool status(const Arc& a) const { return Parent::status(a); } + + /// \brief Disables the given arc /// - /// Returns true if \c a is hidden. + /// This function disables the given arc in the subdigraph, + /// so the iteration jumps over it. + /// It is the same as \ref status() "status(a, false)". + void disable(const Arc& a) const { Parent::status(a, false); } + + /// \brief Enables the given arc /// - bool hidden(const Arc& a) const { return Parent::hidden(a); } + /// This function enables the given arc in the subdigraph. + /// It is the same as \ref status() "status(a, true)". + void enable(const Arc& a) const { Parent::status(a, true); } }; - /// \brief Just gives back an FilterArcs adaptor + /// \brief Returns a read-only FilterArcs adaptor /// - /// Just gives back an FilterArcs adaptor - template<typename Digraph, typename ArcFilterMap> - FilterArcs<const Digraph, ArcFilterMap> - filterArcs(const Digraph& digraph, ArcFilterMap& afm) { - return FilterArcs<const Digraph, ArcFilterMap>(digraph, afm); + /// This function just returns a read-only \ref FilterArcs adaptor. + /// \ingroup graph_adaptors + /// \relates FilterArcs + template<typename GR, typename AF> + FilterArcs<const GR, AF> + filterArcs(const GR& digraph, AF& arc_filter_map) { + return FilterArcs<const GR, AF>(digraph, arc_filter_map); } - template<typename Digraph, typename ArcFilterMap> - FilterArcs<const Digraph, const ArcFilterMap> - filterArcs(const Digraph& digraph, const ArcFilterMap& afm) { - return FilterArcs<const Digraph, const ArcFilterMap>(digraph, afm); + template<typename GR, typename AF> + FilterArcs<const GR, const AF> + filterArcs(const GR& digraph, const AF& arc_filter_map) { + return FilterArcs<const GR, const AF>(digraph, arc_filter_map); } /// \ingroup graph_adaptors /// - /// \brief An adaptor for hiding edges from a graph. + /// \brief Adaptor class for hiding edges in a graph. /// - /// FilterEdges adaptor hides edges in a digraph. A bool edge map must - /// be specified, which defines the filters for edges. Just the - /// unfiltered edges are shown in the subdigraph. The FilterEdges is - /// conform to the \ref concepts::Graph "Graph concept". + /// FilterEdges adaptor can be used for hiding edges in a graph. + /// A \c bool edge map must be specified, which defines the filter for + /// the edges. Only the edges with \c true filter value are shown in the + /// subgraph. This adaptor conforms to the \ref concepts::Graph + /// "Graph" concept. /// - /// \tparam _Graph It must be conform to the \ref concepts::Graph - /// "Graph concept". The type can be specified to be const. - /// \tparam _EdgeFilterMap A bool valued edge map of the the adapted - /// graph. - template<typename _Graph, typename _EdgeFilterMap> + /// The adapted graph can also be modified through this adaptor + /// by adding or removing nodes or edges, unless the \c GR template + /// parameter is set to be \c const. + /// + /// \tparam GR The type of the adapted graph. + /// It must conform to the \ref concepts::Graph "Graph" concept. + /// It can also be specified to be \c const. + /// \tparam EF The type of the edge filter map. + /// It must be a \c bool (or convertible) edge map of the + /// adapted graph. The default type is + /// \ref concepts::Graph::EdgeMap "GR::EdgeMap<bool>". + /// + /// \note The \c Node, \c Edge and \c Arc types of this adaptor and the + /// adapted graph are convertible to each other. +#ifdef DOXYGEN + template<typename GR, + typename EF> + class FilterEdges { +#else + template<typename GR, + typename EF = typename GR::template EdgeMap<bool> > class FilterEdges : - public SubGraph<_Graph, ConstMap<typename _Graph::Node,bool>, - _EdgeFilterMap, false> { + public GraphAdaptorExtender< + SubGraphBase<GR, ConstMap<typename GR::Node,bool>, EF, false> > { +#endif public: - typedef _Graph Graph; - typedef _EdgeFilterMap EdgeFilterMap; - typedef SubGraph<Graph, ConstMap<typename Graph::Node,bool>, - EdgeFilterMap, false> Parent; + /// The type of the adapted graph. + typedef GR Graph; + /// The type of the edge filter map. + typedef EF EdgeFilterMap; + + typedef GraphAdaptorExtender< + SubGraphBase<GR, ConstMap<typename GR::Node,bool>, EF, false> > + Parent; + typedef typename Parent::Edge Edge; + protected: ConstMap<typename Graph::Node, bool> const_true_map; @@ -1610,52 +1768,61 @@ /// \brief Constructor /// - /// Creates a FilterEdges adaptor for the given graph with - /// given edge map filters. - FilterEdges(Graph& _graph, EdgeFilterMap& edge_filter_map) : + /// Creates a subgraph for the given graph with the given edge + /// filter map. + FilterEdges(Graph& graph, EdgeFilterMap& edge_filter_map) : Parent(), const_true_map(true) { - Parent::setGraph(_graph); + Parent::setGraph(graph); Parent::setNodeFilterMap(const_true_map); Parent::setEdgeFilterMap(edge_filter_map); } - /// \brief Hides the edge of the graph + /// \brief Sets the status of the given edge /// - /// This function hides \c e in the graph, i.e. the iteration - /// jumps over it. This is done by simply setting the value of \c e - /// to be false in the corresponding edge-map. - void hide(const Edge& e) const { Parent::hide(e); } - - /// \brief Unhides the edge of the graph + /// This function sets the status of the given edge. + /// It is done by simply setting the assigned value of \c e + /// to \c v in the edge filter map. + void status(const Edge& e, bool v) const { Parent::status(e, v); } + + /// \brief Returns the status of the given edge /// - /// The value of \c e is set to be true in the edge-map which stores - /// hide information. If \c e was hidden previuosly, then it is shown - /// again - void unHide(const Edge& e) const { Parent::unHide(e); } - - /// \brief Returns true if \c e is hidden. + /// This function returns the status of the given edge. + /// It is \c true if the given edge is enabled (i.e. not hidden). + bool status(const Edge& e) const { return Parent::status(e); } + + /// \brief Disables the given edge /// - /// Returns true if \c e is hidden. + /// This function disables the given edge in the subgraph, + /// so the iteration jumps over it. + /// It is the same as \ref status() "status(e, false)". + void disable(const Edge& e) const { Parent::status(e, false); } + + /// \brief Enables the given edge /// - bool hidden(const Edge& e) const { return Parent::hidden(e); } + /// This function enables the given edge in the subgraph. + /// It is the same as \ref status() "status(e, true)". + void enable(const Edge& e) const { Parent::status(e, true); } }; - /// \brief Just gives back a FilterEdges adaptor + /// \brief Returns a read-only FilterEdges adaptor /// - /// Just gives back a FilterEdges adaptor - template<typename Graph, typename EdgeFilterMap> - FilterEdges<const Graph, EdgeFilterMap> - filterEdges(const Graph& graph, EdgeFilterMap& efm) { - return FilterEdges<const Graph, EdgeFilterMap>(graph, efm); + /// This function just returns a read-only \ref FilterEdges adaptor. + /// \ingroup graph_adaptors + /// \relates FilterEdges + template<typename GR, typename EF> + FilterEdges<const GR, EF> + filterEdges(const GR& graph, EF& edge_filter_map) { + return FilterEdges<const GR, EF>(graph, edge_filter_map); } - template<typename Graph, typename EdgeFilterMap> - FilterEdges<const Graph, const EdgeFilterMap> - filterEdges(const Graph& graph, const EdgeFilterMap& efm) { - return FilterEdges<const Graph, const EdgeFilterMap>(graph, efm); + template<typename GR, typename EF> + FilterEdges<const GR, const EF> + filterEdges(const GR& graph, const EF& edge_filter_map) { + return FilterEdges<const GR, const EF>(graph, edge_filter_map); } + template <typename _Digraph> class UndirectorBase { public: @@ -1695,8 +1862,6 @@ } }; - - void first(Node& n) const { _digraph->first(n); } @@ -1845,12 +2010,15 @@ void clear() { _digraph->clear(); } typedef NodeNumTagIndicator<Digraph> NodeNumTag; - int nodeNum() const { return 2 * _digraph->arcNum(); } - typedef EdgeNumTagIndicator<Digraph> EdgeNumTag; + int nodeNum() const { return _digraph->nodeNum(); } + + typedef ArcNumTagIndicator<Digraph> ArcNumTag; int arcNum() const { return 2 * _digraph->arcNum(); } + + typedef ArcNumTag EdgeNumTag; int edgeNum() const { return _digraph->arcNum(); } - typedef FindEdgeTagIndicator<Digraph> FindEdgeTag; + typedef FindArcTagIndicator<Digraph> FindArcTag; Arc findArc(Node s, Node t, Arc p = INVALID) const { if (p == INVALID) { Edge arc = _digraph->findArc(s, t); @@ -1869,6 +2037,7 @@ return INVALID; } + typedef FindArcTag FindEdgeTag; Edge findEdge(Node s, Node t, Edge p = INVALID) const { if (s != t) { if (p == INVALID) { @@ -1876,7 +2045,7 @@ if (arc != INVALID) return arc; arc = _digraph->findArc(t, s); if (arc != INVALID) return arc; - } else if (_digraph->s(p) == s) { + } else if (_digraph->source(p) == s) { Edge arc = _digraph->findArc(s, t, p); if (arc != INVALID) return arc; arc = _digraph->findArc(t, s); @@ -1905,6 +2074,10 @@ typedef _Value Value; typedef Arc Key; + typedef typename MapTraits<MapImpl>::ConstReturnValue ConstReturnValue; + typedef typename MapTraits<MapImpl>::ReturnValue ReturnValue; + typedef typename MapTraits<MapImpl>::ConstReturnValue ConstReference; + typedef typename MapTraits<MapImpl>::ReturnValue Reference; ArcMapBase(const Adaptor& adaptor) : _forward(*adaptor._digraph), _backward(*adaptor._digraph) {} @@ -1920,8 +2093,7 @@ } } - typename MapTraits<MapImpl>::ConstReturnValue - operator[](const Arc& a) const { + ConstReturnValue operator[](const Arc& a) const { if (direction(a)) { return _forward[a]; } else { @@ -1929,8 +2101,7 @@ } } - typename MapTraits<MapImpl>::ReturnValue - operator[](const Arc& a) { + ReturnValue operator[](const Arc& a) { if (direction(a)) { return _forward[a]; } else { @@ -1980,7 +2151,7 @@ typedef _Value Value; typedef SubMapExtender<Adaptor, ArcMapBase<Value> > Parent; - ArcMap(const Adaptor& adaptor) + explicit ArcMap(const Adaptor& adaptor) : Parent(adaptor) {} ArcMap(const Adaptor& adaptor, const Value& value) @@ -2027,6 +2198,9 @@ typedef typename ItemSetTraits<Digraph, Node>::ItemNotifier NodeNotifier; NodeNotifier& notifier(Node) const { return _digraph->notifier(Node()); } + typedef typename ItemSetTraits<Digraph, Edge>::ItemNotifier EdgeNotifier; + EdgeNotifier& notifier(Edge) const { return _digraph->notifier(Edge()); } + protected: UndirectorBase() : _digraph(0) {} @@ -2041,59 +2215,76 @@ /// \ingroup graph_adaptors /// - /// \brief Undirect the graph + /// \brief Adaptor class for viewing a digraph as an undirected graph. /// - /// This adaptor makes an undirected graph from a directed - /// graph. All arcs of the underlying digraph will be showed in the - /// adaptor as an edge. The Orienter adaptor is conform to the \ref - /// concepts::Graph "Graph concept". + /// Undirector adaptor can be used for viewing a digraph as an undirected + /// graph. All arcs of the underlying digraph are showed in the + /// adaptor as an edge (and also as a pair of arcs, of course). + /// This adaptor conforms to the \ref concepts::Graph "Graph" concept. /// - /// \tparam _Digraph It must be conform to the \ref - /// concepts::Digraph "Digraph concept". The type can be specified - /// to const. - template<typename _Digraph> - class Undirector - : public GraphAdaptorExtender<UndirectorBase<_Digraph> > { + /// The adapted digraph can also be modified through this adaptor + /// by adding or removing nodes or edges, unless the \c GR template + /// parameter is set to be \c const. + /// + /// \tparam GR The type of the adapted digraph. + /// It must conform to the \ref concepts::Digraph "Digraph" concept. + /// It can also be specified to be \c const. + /// + /// \note The \c Node type of this adaptor and the adapted digraph are + /// convertible to each other, moreover the \c Edge type of the adaptor + /// and the \c Arc type of the adapted digraph are also convertible to + /// each other. + /// (Thus the \c Arc type of the adaptor is convertible to the \c Arc type + /// of the adapted digraph.) + template<typename GR> +#ifdef DOXYGEN + class Undirector { +#else + class Undirector : + public GraphAdaptorExtender<UndirectorBase<GR> > { +#endif public: - typedef _Digraph Digraph; - typedef GraphAdaptorExtender<UndirectorBase<Digraph> > Parent; + /// The type of the adapted digraph. + typedef GR Digraph; + typedef GraphAdaptorExtender<UndirectorBase<GR> > Parent; protected: Undirector() { } public: /// \brief Constructor /// - /// Creates a undirected graph from the given digraph - Undirector(_Digraph& digraph) { + /// Creates an undirected graph from the given digraph. + Undirector(Digraph& digraph) { setDigraph(digraph); } - /// \brief ArcMap combined from two original ArcMap + /// \brief Arc map combined from two original arc maps /// - /// This class adapts two original digraph ArcMap to - /// get an arc map on the undirected graph. - template <typename _ForwardMap, typename _BackwardMap> + /// This map adaptor class adapts two arc maps of the underlying + /// digraph to get an arc map of the undirected graph. + /// Its value type is inherited from the first arc map type + /// (\c %ForwardMap). + template <typename ForwardMap, typename BackwardMap> class CombinedArcMap { public: - typedef _ForwardMap ForwardMap; - typedef _BackwardMap BackwardMap; + /// The key type of the map + typedef typename Parent::Arc Key; + /// The value type of the map + typedef typename ForwardMap::Value Value; typedef typename MapTraits<ForwardMap>::ReferenceMapTag ReferenceMapTag; - typedef typename ForwardMap::Value Value; - typedef typename Parent::Arc Key; - - /// \brief Constructor - /// + typedef typename MapTraits<ForwardMap>::ReturnValue ReturnValue; + typedef typename MapTraits<ForwardMap>::ConstReturnValue ConstReturnValue; + typedef typename MapTraits<ForwardMap>::ReturnValue Reference; + typedef typename MapTraits<ForwardMap>::ConstReturnValue ConstReference; + /// Constructor CombinedArcMap(ForwardMap& forward, BackwardMap& backward) : _forward(&forward), _backward(&backward) {} - - /// \brief Sets the value associated with a key. - /// - /// Sets the value associated with a key. + /// Sets the value associated with the given key. void set(const Key& e, const Value& a) { if (Parent::direction(e)) { _forward->set(e, a); @@ -2102,11 +2293,8 @@ } } - /// \brief Returns the value associated with a key. - /// - /// Returns the value associated with a key. - typename MapTraits<ForwardMap>::ConstReturnValue - operator[](const Key& e) const { + /// Returns the value associated with the given key. + ConstReturnValue operator[](const Key& e) const { if (Parent::direction(e)) { return (*_forward)[e]; } else { @@ -2114,11 +2302,8 @@ } } - /// \brief Returns the value associated with a key. - /// - /// Returns the value associated with a key. - typename MapTraits<ForwardMap>::ReturnValue - operator[](const Key& e) { + /// Returns a reference to the value associated with the given key. + ReturnValue operator[](const Key& e) { if (Parent::direction(e)) { return (*_forward)[e]; } else { @@ -2133,9 +2318,9 @@ }; - /// \brief Just gives back a combined arc map + /// \brief Returns a combined arc map /// - /// Just gives back a combined arc map + /// This function just returns a combined arc map. template <typename ForwardMap, typename BackwardMap> static CombinedArcMap<ForwardMap, BackwardMap> combinedArcMap(ForwardMap& forward, BackwardMap& backward) { @@ -2165,15 +2350,17 @@ }; - /// \brief Just gives back an undirected view of the given digraph + /// \brief Returns a read-only Undirector adaptor /// - /// Just gives back an undirected view of the given digraph - template<typename Digraph> - Undirector<const Digraph> - undirector(const Digraph& digraph) { - return Undirector<const Digraph>(digraph); + /// This function just returns a read-only \ref Undirector adaptor. + /// \ingroup graph_adaptors + /// \relates Undirector + template<typename GR> + Undirector<const GR> undirector(const GR& digraph) { + return Undirector<const GR>(digraph); } + template <typename _Graph, typename _DirectionMap> class OrienterBase { public: @@ -2191,12 +2378,12 @@ void first(Node& i) const { _graph->first(i); } void first(Arc& i) const { _graph->first(i); } void firstIn(Arc& i, const Node& n) const { - bool d; + bool d = true; _graph->firstInc(i, d, n); while (i != INVALID && d == (*_direction)[i]) _graph->nextInc(i, d); } void firstOut(Arc& i, const Node& n ) const { - bool d; + bool d = true; _graph->firstInc(i, d, n); while (i != INVALID && d != (*_direction)[i]) _graph->nextInc(i, d); } @@ -2224,24 +2411,15 @@ typedef NodeNumTagIndicator<Graph> NodeNumTag; int nodeNum() const { return _graph->nodeNum(); } - typedef EdgeNumTagIndicator<Graph> EdgeNumTag; + typedef EdgeNumTagIndicator<Graph> ArcNumTag; int arcNum() const { return _graph->edgeNum(); } - typedef FindEdgeTagIndicator<Graph> FindEdgeTag; + typedef FindEdgeTagIndicator<Graph> FindArcTag; Arc findArc(const Node& u, const Node& v, - const Arc& prev = INVALID) { - Arc arc = prev; - bool d = arc == INVALID ? true : (*_direction)[arc]; - if (d) { + const Arc& prev = INVALID) const { + Arc arc = _graph->findEdge(u, v, prev); + while (arc != INVALID && source(arc) != u) { arc = _graph->findEdge(u, v, arc); - while (arc != INVALID && !(*_direction)[arc]) { - _graph->findEdge(u, v, arc); - } - if (arc != INVALID) return arc; - } - _graph->findEdge(v, u, arc); - while (arc != INVALID && (*_direction)[arc]) { - _graph->findEdge(u, v, arc); } return arc; } @@ -2251,8 +2429,8 @@ } Arc addArc(const Node& u, const Node& v) { - Arc arc = _graph->addArc(u, v); - _direction->set(arc, _graph->source(arc) == u); + Arc arc = _graph->addEdge(u, v); + _direction->set(arc, _graph->u(arc) == u); return arc; } @@ -2343,78 +2521,98 @@ /// \ingroup graph_adaptors /// - /// \brief Orients the edges of the graph to get a digraph + /// \brief Adaptor class for orienting the edges of a graph to get a digraph /// - /// This adaptor orients each edge in the undirected graph. The - /// direction of the arcs stored in an edge node map. The arcs can - /// be easily reverted by the \c reverseArc() member function in the - /// adaptor. The Orienter adaptor is conform to the \ref - /// concepts::Digraph "Digraph concept". + /// Orienter adaptor can be used for orienting the edges of a graph to + /// get a digraph. A \c bool edge map of the underlying graph must be + /// specified, which define the direction of the arcs in the adaptor. + /// The arcs can be easily reversed by the \c reverseArc() member function + /// of the adaptor. + /// This class conforms to the \ref concepts::Digraph "Digraph" concept. /// - /// \tparam _Graph It must be conform to the \ref concepts::Graph - /// "Graph concept". The type can be specified to be const. - /// \tparam _DirectionMap A bool valued edge map of the the adapted - /// graph. + /// The adapted graph can also be modified through this adaptor + /// by adding or removing nodes or arcs, unless the \c GR template + /// parameter is set to be \c const. /// - /// \sa orienter - template<typename _Graph, - typename DirectionMap = typename _Graph::template EdgeMap<bool> > + /// \tparam GR The type of the adapted graph. + /// It must conform to the \ref concepts::Graph "Graph" concept. + /// It can also be specified to be \c const. + /// \tparam DM The type of the direction map. + /// It must be a \c bool (or convertible) edge map of the + /// adapted graph. The default type is + /// \ref concepts::Graph::EdgeMap "GR::EdgeMap<bool>". + /// + /// \note The \c Node type of this adaptor and the adapted graph are + /// convertible to each other, moreover the \c Arc type of the adaptor + /// and the \c Edge type of the adapted graph are also convertible to + /// each other. +#ifdef DOXYGEN + template<typename GR, + typename DM> + class Orienter { +#else + template<typename GR, + typename DM = typename GR::template EdgeMap<bool> > class Orienter : - public DigraphAdaptorExtender<OrienterBase<_Graph, DirectionMap> > { + public DigraphAdaptorExtender<OrienterBase<GR, DM> > { +#endif public: - typedef _Graph Graph; - typedef DigraphAdaptorExtender< - OrienterBase<_Graph, DirectionMap> > Parent; + + /// The type of the adapted graph. + typedef GR Graph; + /// The type of the direction edge map. + typedef DM DirectionMap; + + typedef DigraphAdaptorExtender<OrienterBase<GR, DM> > Parent; typedef typename Parent::Arc Arc; protected: Orienter() { } public: - /// \brief Constructor of the adaptor + /// \brief Constructor /// - /// Constructor of the adaptor + /// Constructor of the adaptor. Orienter(Graph& graph, DirectionMap& direction) { setGraph(graph); setDirectionMap(direction); } - /// \brief Reverse arc + /// \brief Reverses the given arc /// - /// It reverse the given arc. It simply negate the direction in the map. + /// This function reverses the given arc. + /// It is done by simply negate the assigned value of \c a + /// in the direction map. void reverseArc(const Arc& a) { Parent::reverseArc(a); } }; - /// \brief Just gives back a Orienter + /// \brief Returns a read-only Orienter adaptor /// - /// Just gives back a Orienter - template<typename Graph, typename DirectionMap> - Orienter<const Graph, DirectionMap> - orienter(const Graph& graph, DirectionMap& dm) { - return Orienter<const Graph, DirectionMap>(graph, dm); + /// This function just returns a read-only \ref Orienter adaptor. + /// \ingroup graph_adaptors + /// \relates Orienter + template<typename GR, typename DM> + Orienter<const GR, DM> + orienter(const GR& graph, DM& direction_map) { + return Orienter<const GR, DM>(graph, direction_map); } - template<typename Graph, typename DirectionMap> - Orienter<const Graph, const DirectionMap> - orienter(const Graph& graph, const DirectionMap& dm) { - return Orienter<const Graph, const DirectionMap>(graph, dm); + template<typename GR, typename DM> + Orienter<const GR, const DM> + orienter(const GR& graph, const DM& direction_map) { + return Orienter<const GR, const DM>(graph, direction_map); } namespace _adaptor_bits { - template<typename _Digraph, - typename _CapacityMap = typename _Digraph::template ArcMap<int>, - typename _FlowMap = _CapacityMap, - typename _Tolerance = Tolerance<typename _CapacityMap::Value> > + template<typename Digraph, + typename CapacityMap, + typename FlowMap, + typename Tolerance> class ResForwardFilter { public: - typedef _Digraph Digraph; - typedef _CapacityMap CapacityMap; - typedef _FlowMap FlowMap; - typedef _Tolerance Tolerance; - typedef typename Digraph::Arc Key; typedef bool Value; @@ -2434,18 +2632,13 @@ } }; - template<typename _Digraph, - typename _CapacityMap = typename _Digraph::template ArcMap<int>, - typename _FlowMap = _CapacityMap, - typename _Tolerance = Tolerance<typename _CapacityMap::Value> > + template<typename Digraph, + typename CapacityMap, + typename FlowMap, + typename Tolerance> class ResBackwardFilter { public: - typedef _Digraph Digraph; - typedef _CapacityMap CapacityMap; - typedef _FlowMap FlowMap; - typedef _Tolerance Tolerance; - typedef typename Digraph::Arc Key; typedef bool Value; @@ -2470,50 +2663,71 @@ /// \ingroup graph_adaptors /// - /// \brief An adaptor for composing the residual graph for directed + /// \brief Adaptor class for composing the residual digraph for directed /// flow and circulation problems. /// - /// An adaptor for composing the residual graph for directed flow and - /// circulation problems. Let \f$ G=(V, A) \f$ be a directed graph - /// and let \f$ F \f$ be a number type. Let moreover \f$ f,c:A\to F \f$, - /// be functions on the arc-set. + /// Residual can be used for composing the \e residual digraph for directed + /// flow and circulation problems. Let \f$ G=(V, A) \f$ be a directed graph + /// and let \f$ F \f$ be a number type. Let \f$ flow, cap: A\to F \f$ be + /// functions on the arcs. + /// This adaptor implements a digraph structure with node set \f$ V \f$ + /// and arc set \f$ A_{forward}\cup A_{backward} \f$, + /// where \f$ A_{forward}=\{uv : uv\in A, flow(uv)<cap(uv)\} \f$ and + /// \f$ A_{backward}=\{vu : uv\in A, flow(uv)>0\} \f$, i.e. the so + /// called residual digraph. + /// When the union \f$ A_{forward}\cup A_{backward} \f$ is taken, + /// multiplicities are counted, i.e. the adaptor has exactly + /// \f$ |A_{forward}| + |A_{backward}|\f$ arcs (it may have parallel + /// arcs). + /// This class conforms to the \ref concepts::Digraph "Digraph" concept. /// - /// Then Residual implements the digraph structure with - /// node-set \f$ V \f$ and arc-set \f$ A_{forward}\cup A_{backward} \f$, - /// where \f$ A_{forward}=\{uv : uv\in A, f(uv)<c(uv)\} \f$ and - /// \f$ A_{backward}=\{vu : uv\in A, f(uv)>0\} \f$, i.e. the so - /// called residual graph. When we take the union - /// \f$ A_{forward}\cup A_{backward} \f$, multiplicities are counted, - /// i.e. if an arc is in both \f$ A_{forward} \f$ and - /// \f$ A_{backward} \f$, then in the adaptor it appears in both - /// orientation. + /// \tparam GR The type of the adapted digraph. + /// It must conform to the \ref concepts::Digraph "Digraph" concept. + /// It is implicitly \c const. + /// \tparam CM The type of the capacity map. + /// It must be an arc map of some numerical type, which defines + /// the capacities in the flow problem. It is implicitly \c const. + /// The default type is + /// \ref concepts::Digraph::ArcMap "GR::ArcMap<int>". + /// \tparam FM The type of the flow map. + /// It must be an arc map of some numerical type, which defines + /// the flow values in the flow problem. The default type is \c CM. + /// \tparam TL The tolerance type for handling inexact computation. + /// The default tolerance type depends on the value type of the + /// capacity map. /// - /// \tparam _Digraph It must be conform to the \ref concepts::Digraph - /// "Digraph concept". The type is implicitly const. - /// \tparam _CapacityMap An arc map of some numeric type, it defines - /// the capacities in the flow problem. The map is implicitly const. - /// \tparam _FlowMap An arc map of some numeric type, it defines - /// the capacities in the flow problem. - /// \tparam _Tolerance Handler for inexact computation. - template<typename _Digraph, - typename _CapacityMap = typename _Digraph::template ArcMap<int>, - typename _FlowMap = _CapacityMap, - typename _Tolerance = Tolerance<typename _CapacityMap::Value> > + /// \note This adaptor is implemented using Undirector and FilterArcs + /// adaptors. + /// + /// \note The \c Node type of this adaptor and the adapted digraph are + /// convertible to each other, moreover the \c Arc type of the adaptor + /// is convertible to the \c Arc type of the adapted digraph. +#ifdef DOXYGEN + template<typename GR, typename CM, typename FM, typename TL> + class Residual +#else + template<typename GR, + typename CM = typename GR::template ArcMap<int>, + typename FM = CM, + typename TL = Tolerance<typename CM::Value> > class Residual : public FilterArcs< - Undirector<const _Digraph>, - typename Undirector<const _Digraph>::template CombinedArcMap< - _adaptor_bits::ResForwardFilter<const _Digraph, _CapacityMap, - _FlowMap, _Tolerance>, - _adaptor_bits::ResBackwardFilter<const _Digraph, _CapacityMap, - _FlowMap, _Tolerance> > > + Undirector<const GR>, + typename Undirector<const GR>::template CombinedArcMap< + _adaptor_bits::ResForwardFilter<const GR, CM, FM, TL>, + _adaptor_bits::ResBackwardFilter<const GR, CM, FM, TL> > > +#endif { public: - typedef _Digraph Digraph; - typedef _CapacityMap CapacityMap; - typedef _FlowMap FlowMap; - typedef _Tolerance Tolerance; + /// The type of the underlying digraph. + typedef GR Digraph; + /// The type of the capacity map. + typedef CM CapacityMap; + /// The type of the flow map. + typedef FM FlowMap; + /// The tolerance type. + typedef TL Tolerance; typedef typename CapacityMap::Value Value; typedef Residual Adaptor; @@ -2529,7 +2743,7 @@ FlowMap, Tolerance> BackwardFilter; typedef typename Undirected:: - template CombinedArcMap<ForwardFilter, BackwardFilter> ArcFilter; + template CombinedArcMap<ForwardFilter, BackwardFilter> ArcFilter; typedef FilterArcs<Undirected, ArcFilter> Parent; @@ -2543,10 +2757,10 @@ public: - /// \brief Constructor of the residual digraph. + /// \brief Constructor /// - /// Constructor of the residual graph. The parameters are the digraph, - /// the flow map, the capacity map and a tolerance object. + /// Constructor of the residual digraph adaptor. The parameters are the + /// digraph, the capacity map, the flow map, and a tolerance object. Residual(const Digraph& digraph, const CapacityMap& capacity, FlowMap& flow, const Tolerance& tolerance = Tolerance()) : Parent(), _capacity(&capacity), _flow(&flow), _graph(digraph), @@ -2560,9 +2774,9 @@ typedef typename Parent::Arc Arc; - /// \brief Gives back the residual capacity of the arc. + /// \brief Returns the residual capacity of the given arc. /// - /// Gives back the residual capacity of the arc. + /// Returns the residual capacity of the given arc. Value residualCapacity(const Arc& a) const { if (Undirected::direction(a)) { return (*_capacity)[a] - (*_flow)[a]; @@ -2571,11 +2785,11 @@ } } - /// \brief Augment on the given arc in the residual graph. + /// \brief Augments on the given arc in the residual digraph. /// - /// Augment on the given arc in the residual graph. It increase - /// or decrease the flow on the original arc depend on the direction - /// of the residual arc. + /// Augments on the given arc in the residual digraph. It increases + /// or decreases the flow value on the original arc according to the + /// direction of the residual arc. void augment(const Arc& a, const Value& v) const { if (Undirected::direction(a)) { _flow->set(a, (*_flow)[a] + v); @@ -2584,59 +2798,84 @@ } } - /// \brief Returns the direction of the arc. + /// \brief Returns \c true if the given residual arc is a forward arc. /// - /// Returns true when the arc is same oriented as the original arc. + /// Returns \c true if the given residual arc has the same orientation + /// as the original arc, i.e. it is a so called forward arc. static bool forward(const Arc& a) { return Undirected::direction(a); } - /// \brief Returns the direction of the arc. + /// \brief Returns \c true if the given residual arc is a backward arc. /// - /// Returns true when the arc is opposite oriented as the original arc. + /// Returns \c true if the given residual arc has the opposite orientation + /// than the original arc, i.e. it is a so called backward arc. static bool backward(const Arc& a) { return !Undirected::direction(a); } - /// \brief Gives back the forward oriented residual arc. + /// \brief Returns the forward oriented residual arc. /// - /// Gives back the forward oriented residual arc. + /// Returns the forward oriented residual arc related to the given + /// arc of the underlying digraph. static Arc forward(const typename Digraph::Arc& a) { return Undirected::direct(a, true); } - /// \brief Gives back the backward oriented residual arc. + /// \brief Returns the backward oriented residual arc. /// - /// Gives back the backward oriented residual arc. + /// Returns the backward oriented residual arc related to the given + /// arc of the underlying digraph. static Arc backward(const typename Digraph::Arc& a) { return Undirected::direct(a, false); } /// \brief Residual capacity map. /// - /// In generic residual graph the residual capacity can be obtained - /// as a map. + /// This map adaptor class can be used for obtaining the residual + /// capacities as an arc map of the residual digraph. + /// Its value type is inherited from the capacity map. class ResidualCapacity { protected: const Adaptor* _adaptor; public: - /// The Key type + /// The key type of the map typedef Arc Key; - /// The Value type - typedef typename _CapacityMap::Value Value; + /// The value type of the map + typedef typename CapacityMap::Value Value; /// Constructor ResidualCapacity(const Adaptor& adaptor) : _adaptor(&adaptor) {} - /// \e + /// Returns the value associated with the given residual arc Value operator[](const Arc& a) const { return _adaptor->residualCapacity(a); } }; + /// \brief Returns a residual capacity map + /// + /// This function just returns a residual capacity map. + ResidualCapacity residualCapacity() const { + return ResidualCapacity(*this); + } + }; + /// \brief Returns a (read-only) Residual adaptor + /// + /// This function just returns a (read-only) \ref Residual adaptor. + /// \ingroup graph_adaptors + /// \relates Residual + template<typename GR, typename CM, typename FM> + Residual<GR, CM, FM> residual(const GR& digraph, + const CM& capacity_map, + FM& flow_map) { + return Residual<GR, CM, FM> (digraph, capacity_map, flow_map); + } + + template <typename _Digraph> class SplitNodesBase { public: @@ -2884,30 +3123,26 @@ } typedef True NodeNumTag; - int nodeNum() const { return 2 * countNodes(*_digraph); } - typedef True EdgeNumTag; + typedef True ArcNumTag; int arcNum() const { return countArcs(*_digraph) + countNodes(*_digraph); } - typedef True FindEdgeTag; + typedef True FindArcTag; Arc findArc(const Node& u, const Node& v, const Arc& prev = INVALID) const { - if (inNode(u)) { - if (outNode(v)) { - if (static_cast<const DigraphNode&>(u) == - static_cast<const DigraphNode&>(v) && prev == INVALID) { - return Arc(u); - } + if (inNode(u) && outNode(v)) { + if (static_cast<const DigraphNode&>(u) == + static_cast<const DigraphNode&>(v) && prev == INVALID) { + return Arc(u); } - } else { - if (inNode(v)) { - return Arc(::lemon::findArc(*_digraph, u, v, prev)); - } + } + else if (outNode(u) && inNode(v)) { + return Arc(::lemon::findArc(*_digraph, u, v, prev)); } return INVALID; } @@ -2921,6 +3156,11 @@ public: typedef Node Key; typedef _Value Value; + typedef typename MapTraits<NodeImpl>::ReferenceMapTag ReferenceMapTag; + typedef typename MapTraits<NodeImpl>::ReturnValue ReturnValue; + typedef typename MapTraits<NodeImpl>::ConstReturnValue ConstReturnValue; + typedef typename MapTraits<NodeImpl>::ReturnValue Reference; + typedef typename MapTraits<NodeImpl>::ConstReturnValue ConstReference; NodeMapBase(const Adaptor& adaptor) : _in_map(*adaptor._digraph), _out_map(*adaptor._digraph) {} @@ -2933,14 +3173,12 @@ else {_out_map.set(key, val); } } - typename MapTraits<NodeImpl>::ReturnValue - operator[](const Node& key) { + ReturnValue operator[](const Node& key) { if (Adaptor::inNode(key)) { return _in_map[key]; } else { return _out_map[key]; } } - typename MapTraits<NodeImpl>::ConstReturnValue - operator[](const Node& key) const { + ConstReturnValue operator[](const Node& key) const { if (Adaptor::inNode(key)) { return _in_map[key]; } else { return _out_map[key]; } } @@ -2957,6 +3195,11 @@ public: typedef Arc Key; typedef _Value Value; + typedef typename MapTraits<ArcImpl>::ReferenceMapTag ReferenceMapTag; + typedef typename MapTraits<ArcImpl>::ReturnValue ReturnValue; + typedef typename MapTraits<ArcImpl>::ConstReturnValue ConstReturnValue; + typedef typename MapTraits<ArcImpl>::ReturnValue Reference; + typedef typename MapTraits<ArcImpl>::ConstReturnValue ConstReference; ArcMapBase(const Adaptor& adaptor) : _arc_map(*adaptor._digraph), _node_map(*adaptor._digraph) {} @@ -2972,8 +3215,7 @@ } } - typename MapTraits<ArcImpl>::ReturnValue - operator[](const Arc& key) { + ReturnValue operator[](const Arc& key) { if (Adaptor::origArc(key)) { return _arc_map[key._item.first()]; } else { @@ -2981,8 +3223,7 @@ } } - typename MapTraits<ArcImpl>::ConstReturnValue - operator[](const Arc& key) const { + ConstReturnValue operator[](const Arc& key) const { if (Adaptor::origArc(key)) { return _arc_map[key._item.first()]; } else { @@ -3063,31 +3304,41 @@ /// \ingroup graph_adaptors /// - /// \brief Split the nodes of a directed graph + /// \brief Adaptor class for splitting the nodes of a digraph. /// - /// The SplitNodes adaptor splits each node into an in-node and an - /// out-node. Formaly, the adaptor replaces each \f$ u \f$ node in - /// the digraph with two nodes(namely node \f$ u_{in} \f$ and node - /// \f$ u_{out} \f$). If there is a \f$ (v, u) \f$ arc in the - /// original digraph the new target of the arc will be \f$ u_{in} \f$ - /// and similarly the source of the original \f$ (u, v) \f$ arc - /// will be \f$ u_{out} \f$. The adaptor will add for each node in - /// the original digraph an additional arc which connects - /// \f$ (u_{in}, u_{out}) \f$. + /// SplitNodes adaptor can be used for splitting each node into an + /// \e in-node and an \e out-node in a digraph. Formaly, the adaptor + /// replaces each node \f$ u \f$ in the digraph with two nodes, + /// namely node \f$ u_{in} \f$ and node \f$ u_{out} \f$. + /// If there is a \f$ (v, u) \f$ arc in the original digraph, then the + /// new target of the arc will be \f$ u_{in} \f$ and similarly the + /// source of each original \f$ (u, v) \f$ arc will be \f$ u_{out} \f$. + /// The adaptor adds an additional \e bind \e arc from \f$ u_{in} \f$ + /// to \f$ u_{out} \f$ for each node \f$ u \f$ of the original digraph. /// - /// The aim of this class is to run algorithm with node costs if the - /// algorithm can use directly just arc costs. In this case we should use - /// a \c SplitNodes and set the node cost of the graph to the - /// bind arc in the adapted graph. + /// The aim of this class is running an algorithm with respect to node + /// costs or capacities if the algorithm considers only arc costs or + /// capacities directly. + /// In this case you can use \c SplitNodes adaptor, and set the node + /// costs/capacities of the original digraph to the \e bind \e arcs + /// in the adaptor. /// - /// \tparam _Digraph It must be conform to the \ref concepts::Digraph - /// "Digraph concept". The type can be specified to be const. - template <typename _Digraph> + /// \tparam GR The type of the adapted digraph. + /// It must conform to the \ref concepts::Digraph "Digraph" concept. + /// It is implicitly \c const. + /// + /// \note The \c Node type of this adaptor is converible to the \c Node + /// type of the adapted digraph. + template <typename GR> +#ifdef DOXYGEN + class SplitNodes { +#else class SplitNodes - : public DigraphAdaptorExtender<SplitNodesBase<_Digraph> > { + : public DigraphAdaptorExtender<SplitNodesBase<const GR> > { +#endif public: - typedef _Digraph Digraph; - typedef DigraphAdaptorExtender<SplitNodesBase<Digraph> > Parent; + typedef GR Digraph; + typedef DigraphAdaptorExtender<SplitNodesBase<const GR> > Parent; typedef typename Digraph::Node DigraphNode; typedef typename Digraph::Arc DigraphArc; @@ -3095,89 +3346,110 @@ typedef typename Parent::Node Node; typedef typename Parent::Arc Arc; - /// \brief Constructor of the adaptor. + /// \brief Constructor /// /// Constructor of the adaptor. - SplitNodes(Digraph& g) { + SplitNodes(const Digraph& g) { Parent::setDigraph(g); } - /// \brief Returns true when the node is in-node. + /// \brief Returns \c true if the given node is an in-node. /// - /// Returns true when the node is in-node. + /// Returns \c true if the given node is an in-node. static bool inNode(const Node& n) { return Parent::inNode(n); } - /// \brief Returns true when the node is out-node. + /// \brief Returns \c true if the given node is an out-node. /// - /// Returns true when the node is out-node. + /// Returns \c true if the given node is an out-node. static bool outNode(const Node& n) { return Parent::outNode(n); } - /// \brief Returns true when the arc is arc in the original digraph. + /// \brief Returns \c true if the given arc is an original arc. /// - /// Returns true when the arc is arc in the original digraph. + /// Returns \c true if the given arc is one of the arcs in the + /// original digraph. static bool origArc(const Arc& a) { return Parent::origArc(a); } - /// \brief Returns true when the arc binds an in-node and an out-node. + /// \brief Returns \c true if the given arc is a bind arc. /// - /// Returns true when the arc binds an in-node and an out-node. + /// Returns \c true if the given arc is a bind arc, i.e. it connects + /// an in-node and an out-node. static bool bindArc(const Arc& a) { return Parent::bindArc(a); } - /// \brief Gives back the in-node created from the \c node. + /// \brief Returns the in-node created from the given original node. /// - /// Gives back the in-node created from the \c node. + /// Returns the in-node created from the given original node. static Node inNode(const DigraphNode& n) { return Parent::inNode(n); } - /// \brief Gives back the out-node created from the \c node. + /// \brief Returns the out-node created from the given original node. /// - /// Gives back the out-node created from the \c node. + /// Returns the out-node created from the given original node. static Node outNode(const DigraphNode& n) { return Parent::outNode(n); } - /// \brief Gives back the arc binds the two part of the node. + /// \brief Returns the bind arc that corresponds to the given + /// original node. /// - /// Gives back the arc binds the two part of the node. + /// Returns the bind arc in the adaptor that corresponds to the given + /// original node, i.e. the arc connecting the in-node and out-node + /// of \c n. static Arc arc(const DigraphNode& n) { return Parent::arc(n); } - /// \brief Gives back the arc of the original arc. + /// \brief Returns the arc that corresponds to the given original arc. /// - /// Gives back the arc of the original arc. + /// Returns the arc in the adaptor that corresponds to the given + /// original arc. static Arc arc(const DigraphArc& a) { return Parent::arc(a); } - /// \brief NodeMap combined from two original NodeMap + /// \brief Node map combined from two original node maps /// - /// This class adapt two of the original digraph NodeMap to - /// get a node map on the adapted digraph. + /// This map adaptor class adapts two node maps of the original digraph + /// to get a node map of the split digraph. + /// Its value type is inherited from the first node map type + /// (\c InNodeMap). template <typename InNodeMap, typename OutNodeMap> class CombinedNodeMap { public: + /// The key type of the map typedef Node Key; + /// The value type of the map typedef typename InNodeMap::Value Value; - /// \brief Constructor - /// - /// Constructor. + typedef typename MapTraits<InNodeMap>::ReferenceMapTag ReferenceMapTag; + typedef typename MapTraits<InNodeMap>::ReturnValue ReturnValue; + typedef typename MapTraits<InNodeMap>::ConstReturnValue ConstReturnValue; + typedef typename MapTraits<InNodeMap>::ReturnValue Reference; + typedef typename MapTraits<InNodeMap>::ConstReturnValue ConstReference; + + /// Constructor CombinedNodeMap(InNodeMap& in_map, OutNodeMap& out_map) : _in_map(in_map), _out_map(out_map) {} - /// \brief The subscript operator. - /// - /// The subscript operator. + /// Returns the value associated with the given key. + Value operator[](const Key& key) const { + if (Parent::inNode(key)) { + return _in_map[key]; + } else { + return _out_map[key]; + } + } + + /// Returns a reference to the value associated with the given key. Value& operator[](const Key& key) { if (Parent::inNode(key)) { return _in_map[key]; @@ -3186,20 +3458,7 @@ } } - /// \brief The const subscript operator. - /// - /// The const subscript operator. - Value operator[](const Key& key) const { - if (Parent::inNode(key)) { - return _in_map[key]; - } else { - return _out_map[key]; - } - } - - /// \brief The setter function of the map. - /// - /// The setter function of the map. + /// Sets the value associated with the given key. void set(const Key& key, const Value& value) { if (Parent::inNode(key)) { _in_map.set(key, value); @@ -3216,9 +3475,9 @@ }; - /// \brief Just gives back a combined node map + /// \brief Returns a combined node map /// - /// Just gives back a combined node map + /// This function just returns a combined node map. template <typename InNodeMap, typename OutNodeMap> static CombinedNodeMap<InNodeMap, OutNodeMap> combinedNodeMap(InNodeMap& in_map, OutNodeMap& out_map) { @@ -3244,26 +3503,51 @@ const OutNodeMap>(in_map, out_map); } - /// \brief ArcMap combined from an original ArcMap and a NodeMap + /// \brief Arc map combined from an arc map and a node map of the + /// original digraph. /// - /// This class adapt an original ArcMap and a NodeMap to get an - /// arc map on the adapted digraph - template <typename DigraphArcMap, typename DigraphNodeMap> + /// This map adaptor class adapts an arc map and a node map of the + /// original digraph to get an arc map of the split digraph. + /// Its value type is inherited from the original arc map type + /// (\c ArcMap). + template <typename ArcMap, typename NodeMap> class CombinedArcMap { public: + /// The key type of the map typedef Arc Key; - typedef typename DigraphArcMap::Value Value; - - /// \brief Constructor - /// - /// Constructor. - CombinedArcMap(DigraphArcMap& arc_map, DigraphNodeMap& node_map) + /// The value type of the map + typedef typename ArcMap::Value Value; + + typedef typename MapTraits<ArcMap>::ReferenceMapTag ReferenceMapTag; + typedef typename MapTraits<ArcMap>::ReturnValue ReturnValue; + typedef typename MapTraits<ArcMap>::ConstReturnValue ConstReturnValue; + typedef typename MapTraits<ArcMap>::ReturnValue Reference; + typedef typename MapTraits<ArcMap>::ConstReturnValue ConstReference; + + /// Constructor + CombinedArcMap(ArcMap& arc_map, NodeMap& node_map) : _arc_map(arc_map), _node_map(node_map) {} - /// \brief The subscript operator. - /// - /// The subscript operator. + /// Returns the value associated with the given key. + Value operator[](const Key& arc) const { + if (Parent::origArc(arc)) { + return _arc_map[arc]; + } else { + return _node_map[arc]; + } + } + + /// Returns a reference to the value associated with the given key. + Value& operator[](const Key& arc) { + if (Parent::origArc(arc)) { + return _arc_map[arc]; + } else { + return _node_map[arc]; + } + } + + /// Sets the value associated with the given key. void set(const Arc& arc, const Value& val) { if (Parent::origArc(arc)) { _arc_map.set(arc, val); @@ -3272,76 +3556,51 @@ } } - /// \brief The const subscript operator. - /// - /// The const subscript operator. - Value operator[](const Key& arc) const { - if (Parent::origArc(arc)) { - return _arc_map[arc]; - } else { - return _node_map[arc]; - } - } - - /// \brief The const subscript operator. - /// - /// The const subscript operator. - Value& operator[](const Key& arc) { - if (Parent::origArc(arc)) { - return _arc_map[arc]; - } else { - return _node_map[arc]; - } - } - private: - DigraphArcMap& _arc_map; - DigraphNodeMap& _node_map; + ArcMap& _arc_map; + NodeMap& _node_map; }; - /// \brief Just gives back a combined arc map + /// \brief Returns a combined arc map /// - /// Just gives back a combined arc map - template <typename DigraphArcMap, typename DigraphNodeMap> - static CombinedArcMap<DigraphArcMap, DigraphNodeMap> - combinedArcMap(DigraphArcMap& arc_map, DigraphNodeMap& node_map) { - return CombinedArcMap<DigraphArcMap, DigraphNodeMap>(arc_map, node_map); + /// This function just returns a combined arc map. + template <typename ArcMap, typename NodeMap> + static CombinedArcMap<ArcMap, NodeMap> + combinedArcMap(ArcMap& arc_map, NodeMap& node_map) { + return CombinedArcMap<ArcMap, NodeMap>(arc_map, node_map); } - template <typename DigraphArcMap, typename DigraphNodeMap> - static CombinedArcMap<const DigraphArcMap, DigraphNodeMap> - combinedArcMap(const DigraphArcMap& arc_map, DigraphNodeMap& node_map) { - return CombinedArcMap<const DigraphArcMap, - DigraphNodeMap>(arc_map, node_map); + template <typename ArcMap, typename NodeMap> + static CombinedArcMap<const ArcMap, NodeMap> + combinedArcMap(const ArcMap& arc_map, NodeMap& node_map) { + return CombinedArcMap<const ArcMap, NodeMap>(arc_map, node_map); } - template <typename DigraphArcMap, typename DigraphNodeMap> - static CombinedArcMap<DigraphArcMap, const DigraphNodeMap> - combinedArcMap(DigraphArcMap& arc_map, const DigraphNodeMap& node_map) { - return CombinedArcMap<DigraphArcMap, - const DigraphNodeMap>(arc_map, node_map); + template <typename ArcMap, typename NodeMap> + static CombinedArcMap<ArcMap, const NodeMap> + combinedArcMap(ArcMap& arc_map, const NodeMap& node_map) { + return CombinedArcMap<ArcMap, const NodeMap>(arc_map, node_map); } - template <typename DigraphArcMap, typename DigraphNodeMap> - static CombinedArcMap<const DigraphArcMap, const DigraphNodeMap> - combinedArcMap(const DigraphArcMap& arc_map, - const DigraphNodeMap& node_map) { - return CombinedArcMap<const DigraphArcMap, - const DigraphNodeMap>(arc_map, node_map); + template <typename ArcMap, typename NodeMap> + static CombinedArcMap<const ArcMap, const NodeMap> + combinedArcMap(const ArcMap& arc_map, const NodeMap& node_map) { + return CombinedArcMap<const ArcMap, const NodeMap>(arc_map, node_map); } }; - /// \brief Just gives back a node splitter + /// \brief Returns a (read-only) SplitNodes adaptor /// - /// Just gives back a node splitter - template<typename Digraph> - SplitNodes<Digraph> - splitNodes(const Digraph& digraph) { - return SplitNodes<Digraph>(digraph); + /// This function just returns a (read-only) \ref SplitNodes adaptor. + /// \ingroup graph_adaptors + /// \relates SplitNodes + template<typename GR> + SplitNodes<GR> + splitNodes(const GR& digraph) { + return SplitNodes<GR>(digraph); } - } //namespace lemon #endif //LEMON_ADAPTORS_H diff -r 75a5df083951 -r 5a1e9fdcfd3a lemon/bits/graph_adaptor_extender.h --- a/lemon/bits/graph_adaptor_extender.h Thu Jan 08 17:19:26 2009 +0000 +++ b/lemon/bits/graph_adaptor_extender.h Sun Jan 11 15:09:53 2009 +0000 @@ -173,10 +173,6 @@ }; - - /// \ingroup digraphbits - /// - /// \brief Extender for the GraphAdaptors template <typename _Graph> class GraphAdaptorExtender : public _Graph { public: