diff --git a/doc/groups.dox b/doc/groups.dox --- a/doc/groups.dox +++ b/doc/groups.dox @@ -20,7 +20,7 @@ /** @defgroup datas Data Structures -This group describes the several data structures implemented in LEMON. +This group contains the several data structures implemented in LEMON. */ /** @@ -142,7 +142,7 @@ @ingroup graphs \brief Graph types between real graphs and graph adaptors. -This group describes some graph types between real graphs and graph adaptors. +This group contains some graph types between real graphs and graph adaptors. These classes wrap graphs to give new functionality as the adaptors do it. On the other hand they are not light-weight structures as the adaptors. */ @@ -152,7 +152,7 @@ @ingroup datas \brief Map structures implemented in LEMON. -This group describes the map structures implemented in LEMON. +This group contains the map structures implemented in LEMON. LEMON provides several special purpose maps and map adaptors that e.g. combine new maps from existing ones. @@ -165,7 +165,7 @@ @ingroup maps \brief Special graph-related maps. -This group describes maps that are specifically designed to assign +This group contains maps that are specifically designed to assign values to the nodes and arcs/edges of graphs. If you are looking for the standard graph maps (\c NodeMap, \c ArcMap, @@ -177,7 +177,7 @@ \ingroup maps \brief Tools to create new maps from existing ones -This group describes map adaptors that are used to create "implicit" +This group contains map adaptors that are used to create "implicit" maps from other maps. Most of them are \ref concepts::ReadMap "read-only maps". @@ -240,7 +240,7 @@ @ingroup datas \brief Two dimensional data storages implemented in LEMON. -This group describes two dimensional data storages implemented in LEMON. +This group contains two dimensional data storages implemented in LEMON. */ /** @@ -248,7 +248,7 @@ @ingroup datas \brief %Path structures implemented in LEMON. -This group describes the path structures implemented in LEMON. +This group contains the path structures implemented in LEMON. LEMON provides flexible data structures to work with paths. All of them have similar interfaces and they can be copied easily with @@ -264,16 +264,16 @@ @ingroup datas \brief Auxiliary data structures implemented in LEMON. -This group describes some data structures implemented in LEMON in +This group contains some data structures implemented in LEMON in order to make it easier to implement combinatorial algorithms. */ /** @defgroup algs Algorithms -\brief This group describes the several algorithms +\brief This group contains the several algorithms implemented in LEMON. -This group describes the several algorithms +This group contains the several algorithms implemented in LEMON. */ @@ -282,7 +282,7 @@ @ingroup algs \brief Common graph search algorithms. -This group describes the common graph search algorithms, namely +This group contains the common graph search algorithms, namely \e breadth-first \e search (BFS) and \e depth-first \e search (DFS). */ @@ -291,7 +291,7 @@ @ingroup algs \brief Algorithms for finding shortest paths. -This group describes the algorithms for finding shortest paths in digraphs. +This group contains the algorithms for finding shortest paths in digraphs. - \ref Dijkstra algorithm for finding shortest paths from a source node when all arc lengths are non-negative. @@ -312,7 +312,7 @@ @ingroup algs \brief Algorithms for finding maximum flows. -This group describes the algorithms for finding maximum flows and +This group contains the algorithms for finding maximum flows and feasible circulations. The \e maximum \e flow \e problem is to find a flow of maximum value between @@ -345,7 +345,7 @@ \brief Algorithms for finding minimum cost flows and circulations. -This group describes the algorithms for finding minimum cost flows and +This group contains the algorithms for finding minimum cost flows and circulations. The \e minimum \e cost \e flow \e problem is to find a feasible flow of @@ -382,7 +382,7 @@ \brief Algorithms for finding minimum cut in graphs. -This group describes the algorithms for finding minimum cut in graphs. +This group contains the algorithms for finding minimum cut in graphs. The \e minimum \e cut \e problem is to find a non-empty and non-complete \f$X\f$ subset of the nodes with minimum overall capacity on @@ -399,7 +399,7 @@ in directed graphs. - \ref NagamochiIbaraki "Nagamochi-Ibaraki algorithm" for calculating minimum cut in undirected graphs. -- \ref GomoryHuTree "Gomory-Hu tree computation" for calculating +- \ref GomoryHu "Gomory-Hu tree computation" for calculating all-pairs minimum cut in undirected graphs. If you want to find minimum cut just between two distinict nodes, @@ -411,7 +411,7 @@ @ingroup algs \brief Algorithms for discovering the graph properties -This group describes the algorithms for discovering the graph properties +This group contains the algorithms for discovering the graph properties like connectivity, bipartiteness, euler property, simplicity etc. \image html edge_biconnected_components.png @@ -423,7 +423,7 @@ @ingroup algs \brief Algorithms for planarity checking, embedding and drawing -This group describes the algorithms for planarity checking, +This group contains the algorithms for planarity checking, embedding and drawing. \image html planar.png @@ -474,7 +474,7 @@ @ingroup algs \brief Algorithms for finding a minimum cost spanning tree in a graph. -This group describes the algorithms for finding a minimum cost spanning +This group contains the algorithms for finding a minimum cost spanning tree in a graph. */ @@ -483,7 +483,7 @@ @ingroup algs \brief Auxiliary algorithms implemented in LEMON. -This group describes some algorithms implemented in LEMON +This group contains some algorithms implemented in LEMON in order to make it easier to implement complex algorithms. */ @@ -492,16 +492,16 @@ @ingroup algs \brief Approximation algorithms. -This group describes the approximation and heuristic algorithms +This group contains the approximation and heuristic algorithms implemented in LEMON. */ /** @defgroup gen_opt_group General Optimization Tools -\brief This group describes some general optimization frameworks +\brief This group contains some general optimization frameworks implemented in LEMON. -This group describes some general optimization frameworks +This group contains some general optimization frameworks implemented in LEMON. */ @@ -510,7 +510,7 @@ @ingroup gen_opt_group \brief Lp and Mip solver interfaces for LEMON. -This group describes Lp and Mip solver interfaces for LEMON. The +This group contains Lp and Mip solver interfaces for LEMON. The various LP solvers could be used in the same manner with this interface. */ @@ -529,7 +529,7 @@ @ingroup gen_opt_group \brief Metaheuristics for LEMON library. -This group describes some metaheuristic optimization tools. +This group contains some metaheuristic optimization tools. */ /** @@ -544,7 +544,7 @@ @ingroup utils \brief Simple basic graph utilities. -This group describes some simple basic graph utilities. +This group contains some simple basic graph utilities. */ /** @@ -552,7 +552,7 @@ @ingroup utils \brief Tools for development, debugging and testing. -This group describes several useful tools for development, +This group contains several useful tools for development, debugging and testing. */ @@ -561,7 +561,7 @@ @ingroup misc \brief Simple tools for measuring the performance of algorithms. -This group describes simple tools for measuring the performance +This group contains simple tools for measuring the performance of algorithms. */ @@ -570,14 +570,14 @@ @ingroup utils \brief Exceptions defined in LEMON. -This group describes the exceptions defined in LEMON. +This group contains the exceptions defined in LEMON. */ /** @defgroup io_group Input-Output \brief Graph Input-Output methods -This group describes the tools for importing and exporting graphs +This group contains the tools for importing and exporting graphs and graph related data. Now it supports the \ref lgf-format "LEMON Graph Format", the \c DIMACS format and the encapsulated postscript (EPS) format. @@ -588,7 +588,7 @@ @ingroup io_group \brief Reading and writing LEMON Graph Format. -This group describes methods for reading and writing +This group contains methods for reading and writing \ref lgf-format "LEMON Graph Format". */ @@ -597,7 +597,7 @@ @ingroup io_group \brief General \c EPS drawer and graph exporter -This group describes general \c EPS drawing methods and special +This group contains general \c EPS drawing methods and special graph exporting tools. */ @@ -621,7 +621,7 @@ @defgroup concept Concepts \brief Skeleton classes and concept checking classes -This group describes the data/algorithm skeletons and concept checking +This group contains the data/algorithm skeletons and concept checking classes implemented in LEMON. The purpose of the classes in this group is fourfold. @@ -651,7 +651,7 @@ @ingroup concept \brief Skeleton and concept checking classes for graph structures -This group describes the skeletons and concept checking classes of LEMON's +This group contains the skeletons and concept checking classes of LEMON's graph structures and helper classes used to implement these. */ @@ -660,7 +660,7 @@ @ingroup concept \brief Skeleton and concept checking classes for maps -This group describes the skeletons and concept checking classes of maps. +This group contains the skeletons and concept checking classes of maps. */ /** diff --git a/doc/mainpage.dox b/doc/mainpage.dox --- a/doc/mainpage.dox +++ b/doc/mainpage.dox @@ -45,16 +45,11 @@ take a look at our \ref quicktour "Quick Tour to LEMON" which will guide you along. -If you already feel like using our library, see the page that tells you -\ref getstart "How to start using LEMON". - -If you -want to see how LEMON works, see -some \ref demoprograms "demo programs". +If you already feel like using our library, see the +LEMON Tutorial. If you know what you are looking for then try to find it under the -Modules -section. +Modules section. If you are a user of the old (0.x) series of LEMON, please check out the \ref migration "Migration Guide" for the backward incompatibilities. diff --git a/lemon/adaptors.h b/lemon/adaptors.h --- a/lemon/adaptors.h +++ b/lemon/adaptors.h @@ -2254,26 +2254,27 @@ /// /// 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 + /// Its value type is inherited from the first arc map type (\c FW). + /// \tparam FW The type of the "foward" arc map. + /// \tparam BK The type of the "backward" arc map. + template class CombinedArcMap { public: /// 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::ReferenceMapTag ReferenceMapTag; - - typedef typename MapTraits::ReturnValue ReturnValue; - typedef typename MapTraits::ConstReturnValue ConstReturnValue; - typedef typename MapTraits::ReturnValue Reference; - typedef typename MapTraits::ConstReturnValue ConstReference; + typedef typename FW::Value Value; + + typedef typename MapTraits::ReferenceMapTag ReferenceMapTag; + + typedef typename MapTraits::ReturnValue ReturnValue; + typedef typename MapTraits::ConstReturnValue ConstReturnValue; + typedef typename MapTraits::ReturnValue Reference; + typedef typename MapTraits::ConstReturnValue ConstReference; /// Constructor - CombinedArcMap(ForwardMap& forward, BackwardMap& backward) + CombinedArcMap(FW& forward, BK& backward) : _forward(&forward), _backward(&backward) {} /// Sets the value associated with the given key. @@ -2305,39 +2306,36 @@ protected: - ForwardMap* _forward; - BackwardMap* _backward; + FW* _forward; + BK* _backward; }; /// \brief Returns a combined arc map /// /// This function just returns a combined arc map. - template - static CombinedArcMap - combinedArcMap(ForwardMap& forward, BackwardMap& backward) { - return CombinedArcMap(forward, backward); + template + static CombinedArcMap + combinedArcMap(FW& forward, BK& backward) { + return CombinedArcMap(forward, backward); } - template - static CombinedArcMap - combinedArcMap(const ForwardMap& forward, BackwardMap& backward) { - return CombinedArcMap(forward, backward); + template + static CombinedArcMap + combinedArcMap(const FW& forward, BK& backward) { + return CombinedArcMap(forward, backward); } - template - static CombinedArcMap - combinedArcMap(ForwardMap& forward, const BackwardMap& backward) { - return CombinedArcMap(forward, backward); + template + static CombinedArcMap + combinedArcMap(FW& forward, const BK& backward) { + return CombinedArcMap(forward, backward); } - template - static CombinedArcMap - combinedArcMap(const ForwardMap& forward, const BackwardMap& backward) { - return CombinedArcMap(forward, backward); + template + static CombinedArcMap + combinedArcMap(const FW& forward, const BK& backward) { + return CombinedArcMap(forward, backward); } }; @@ -3406,25 +3404,26 @@ /// /// 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 + /// Its value type is inherited from the first node map type (\c IN). + /// \tparam IN The type of the node map for the in-nodes. + /// \tparam OUT The type of the node map for the out-nodes. + template class CombinedNodeMap { public: /// The key type of the map typedef Node Key; /// The value type of the map - typedef typename InNodeMap::Value Value; - - typedef typename MapTraits::ReferenceMapTag ReferenceMapTag; - typedef typename MapTraits::ReturnValue ReturnValue; - typedef typename MapTraits::ConstReturnValue ConstReturnValue; - typedef typename MapTraits::ReturnValue Reference; - typedef typename MapTraits::ConstReturnValue ConstReference; + typedef typename IN::Value Value; + + typedef typename MapTraits::ReferenceMapTag ReferenceMapTag; + typedef typename MapTraits::ReturnValue ReturnValue; + typedef typename MapTraits::ConstReturnValue ConstReturnValue; + typedef typename MapTraits::ReturnValue Reference; + typedef typename MapTraits::ConstReturnValue ConstReference; /// Constructor - CombinedNodeMap(InNodeMap& in_map, OutNodeMap& out_map) + CombinedNodeMap(IN& in_map, OUT& out_map) : _in_map(in_map), _out_map(out_map) {} /// Returns the value associated with the given key. @@ -3456,8 +3455,8 @@ private: - InNodeMap& _in_map; - OutNodeMap& _out_map; + IN& _in_map; + OUT& _out_map; }; @@ -3465,29 +3464,28 @@ /// \brief Returns a combined node map /// /// This function just returns a combined node map. - template - static CombinedNodeMap - combinedNodeMap(InNodeMap& in_map, OutNodeMap& out_map) { - return CombinedNodeMap(in_map, out_map); + template + static CombinedNodeMap + combinedNodeMap(IN& in_map, OUT& out_map) { + return CombinedNodeMap(in_map, out_map); } - template - static CombinedNodeMap - combinedNodeMap(const InNodeMap& in_map, OutNodeMap& out_map) { - return CombinedNodeMap(in_map, out_map); + template + static CombinedNodeMap + combinedNodeMap(const IN& in_map, OUT& out_map) { + return CombinedNodeMap(in_map, out_map); } - template - static CombinedNodeMap - combinedNodeMap(InNodeMap& in_map, const OutNodeMap& out_map) { - return CombinedNodeMap(in_map, out_map); + template + static CombinedNodeMap + combinedNodeMap(IN& in_map, const OUT& out_map) { + return CombinedNodeMap(in_map, out_map); } - template - static CombinedNodeMap - combinedNodeMap(const InNodeMap& in_map, const OutNodeMap& out_map) { - return CombinedNodeMap(in_map, out_map); + template + static CombinedNodeMap + combinedNodeMap(const IN& in_map, const OUT& out_map) { + return CombinedNodeMap(in_map, out_map); } /// \brief Arc map combined from an arc map and a node map of the @@ -3495,25 +3493,26 @@ /// /// 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 + /// Its value type is inherited from the original arc map type (\c AM). + /// \tparam AM The type of the arc map. + /// \tparam NM the type of the node map. + template class CombinedArcMap { public: /// The key type of the map typedef Arc Key; /// The value type of the map - typedef typename ArcMap::Value Value; - - typedef typename MapTraits::ReferenceMapTag ReferenceMapTag; - typedef typename MapTraits::ReturnValue ReturnValue; - typedef typename MapTraits::ConstReturnValue ConstReturnValue; - typedef typename MapTraits::ReturnValue Reference; - typedef typename MapTraits::ConstReturnValue ConstReference; + typedef typename AM::Value Value; + + typedef typename MapTraits::ReferenceMapTag ReferenceMapTag; + typedef typename MapTraits::ReturnValue ReturnValue; + typedef typename MapTraits::ConstReturnValue ConstReturnValue; + typedef typename MapTraits::ReturnValue Reference; + typedef typename MapTraits::ConstReturnValue ConstReference; /// Constructor - CombinedArcMap(ArcMap& arc_map, NodeMap& node_map) + CombinedArcMap(AM& arc_map, NM& node_map) : _arc_map(arc_map), _node_map(node_map) {} /// Returns the value associated with the given key. @@ -3544,8 +3543,10 @@ } private: - ArcMap& _arc_map; - NodeMap& _node_map; + + AM& _arc_map; + NM& _node_map; + }; /// \brief Returns a combined arc map diff --git a/lemon/bin_heap.h b/lemon/bin_heap.h --- a/lemon/bin_heap.h +++ b/lemon/bin_heap.h @@ -33,35 +33,36 @@ /// ///\brief A Binary Heap implementation. /// - ///This class implements the \e binary \e heap data structure. A \e heap - ///is a data structure for storing items with specified values called \e - ///priorities in such a way that finding the item with minimum priority is - ///efficient. \c Compare specifies the ordering of the priorities. In a heap - ///one can change the priority of an item, add or erase an item, etc. + ///This class implements the \e binary \e heap data structure. + /// + ///A \e heap is a data structure for storing items with specified values + ///called \e priorities in such a way that finding the item with minimum + ///priority is efficient. \c Comp specifies the ordering of the priorities. + ///In a heap one can change the priority of an item, add or erase an + ///item, etc. /// - ///\tparam _Prio Type of the priority of the items. - ///\tparam _ItemIntMap A read and writable Item int map, used internally + ///\tparam PR Type of the priority of the items. + ///\tparam IM A read and writable item map with int values, used internally ///to handle the cross references. - ///\tparam _Compare A class for the ordering of the priorities. The - ///default is \c std::less<_Prio>. + ///\tparam Comp A functor class for the ordering of the priorities. + ///The default is \c std::less. /// ///\sa FibHeap ///\sa Dijkstra - template > + template > class BinHeap { public: ///\e - typedef _ItemIntMap ItemIntMap; + typedef IM ItemIntMap; ///\e - typedef _Prio Prio; + typedef PR Prio; ///\e typedef typename ItemIntMap::Key Item; ///\e typedef std::pair Pair; ///\e - typedef _Compare Compare; + typedef Comp Compare; /// \brief Type to represent the items states. /// @@ -69,49 +70,49 @@ /// "pre heap" or "post heap". The latter two are indifferent from the /// heap's point of view, but may be useful to the user. /// - /// The ItemIntMap \e should be initialized in such way that it maps - /// PRE_HEAP (-1) to any element to be put in the heap... + /// The item-int map must be initialized in such way that it assigns + /// \c PRE_HEAP (-1) to any element to be put in the heap. enum State { - IN_HEAP = 0, - PRE_HEAP = -1, - POST_HEAP = -2 + IN_HEAP = 0, ///< \e + PRE_HEAP = -1, ///< \e + POST_HEAP = -2 ///< \e }; private: - std::vector data; - Compare comp; - ItemIntMap &iim; + std::vector _data; + Compare _comp; + ItemIntMap &_iim; public: /// \brief The constructor. /// /// The constructor. - /// \param _iim should be given to the constructor, since it is used + /// \param map should be given to the constructor, since it is used /// internally to handle the cross references. The value of the map - /// should be PRE_HEAP (-1) for each element. - explicit BinHeap(ItemIntMap &_iim) : iim(_iim) {} + /// must be \c PRE_HEAP (-1) for every item. + explicit BinHeap(ItemIntMap &map) : _iim(map) {} /// \brief The constructor. /// /// The constructor. - /// \param _iim should be given to the constructor, since it is used + /// \param map should be given to the constructor, since it is used /// internally to handle the cross references. The value of the map /// should be PRE_HEAP (-1) for each element. /// - /// \param _comp The comparator function object. - BinHeap(ItemIntMap &_iim, const Compare &_comp) - : iim(_iim), comp(_comp) {} + /// \param comp The comparator function object. + BinHeap(ItemIntMap &map, const Compare &comp) + : _iim(map), _comp(comp) {} /// The number of items stored in the heap. /// /// \brief Returns the number of items stored in the heap. - int size() const { return data.size(); } + int size() const { return _data.size(); } /// \brief Checks if the heap stores no items. /// /// Returns \c true if and only if the heap stores no items. - bool empty() const { return data.empty(); } + bool empty() const { return _data.empty(); } /// \brief Make empty this heap. /// @@ -120,7 +121,7 @@ /// the heap and after that you should set the cross reference map for /// each item to \c PRE_HEAP. void clear() { - data.clear(); + _data.clear(); } private: @@ -128,13 +129,13 @@ static int second_child(int i) { return 2*i+2; } bool less(const Pair &p1, const Pair &p2) const { - return comp(p1.second, p2.second); + return _comp(p1.second, p2.second); } int bubble_up(int hole, Pair p) { int par = parent(hole); - while( hole>0 && less(p,data[par]) ) { - move(data[par],hole); + while( hole>0 && less(p,_data[par]) ) { + move(_data[par],hole); hole = par; par = parent(hole); } @@ -145,18 +146,18 @@ int bubble_down(int hole, Pair p, int length) { int child = second_child(hole); while(child < length) { - if( less(data[child-1], data[child]) ) { + if( less(_data[child-1], _data[child]) ) { --child; } - if( !less(data[child], p) ) + if( !less(_data[child], p) ) goto ok; - move(data[child], hole); + move(_data[child], hole); hole = child; child = second_child(hole); } child--; - if( child 0) { - bubble_down(0, data[n], n); + bubble_down(0, _data[n], n); } - data.pop_back(); + _data.pop_back(); } /// \brief Deletes \c i from the heap. @@ -224,26 +225,26 @@ /// \param i The item to erase. /// \pre The item should be in the heap. void erase(const Item &i) { - int h = iim[i]; - int n = data.size()-1; - iim.set(data[h].first, POST_HEAP); + int h = _iim[i]; + int n = _data.size()-1; + _iim.set(_data[h].first, POST_HEAP); if( h < n ) { - if ( bubble_up(h, data[n]) == h) { - bubble_down(h, data[n], n); + if ( bubble_up(h, _data[n]) == h) { + bubble_down(h, _data[n], n); } } - data.pop_back(); + _data.pop_back(); } /// \brief Returns the priority of \c i. /// /// This function returns the priority of item \c i. + /// \param i The item. /// \pre \c i must be in the heap. - /// \param i The item. Prio operator[](const Item &i) const { - int idx = iim[i]; - return data[idx].second; + int idx = _iim[i]; + return _data[idx].second; } /// \brief \c i gets to the heap with priority \c p independently @@ -254,40 +255,40 @@ /// \param i The item. /// \param p The priority. void set(const Item &i, const Prio &p) { - int idx = iim[i]; + int idx = _iim[i]; if( idx < 0 ) { push(i,p); } - else if( comp(p, data[idx].second) ) { + else if( _comp(p, _data[idx].second) ) { bubble_up(idx, Pair(i,p)); } else { - bubble_down(idx, Pair(i,p), data.size()); + bubble_down(idx, Pair(i,p), _data.size()); } } /// \brief Decreases the priority of \c i to \c p. /// /// This method decreases the priority of item \c i to \c p. + /// \param i The item. + /// \param p The priority. /// \pre \c i must be stored in the heap with priority at least \c /// p relative to \c Compare. - /// \param i The item. - /// \param p The priority. void decrease(const Item &i, const Prio &p) { - int idx = iim[i]; + int idx = _iim[i]; bubble_up(idx, Pair(i,p)); } /// \brief Increases the priority of \c i to \c p. /// /// This method sets the priority of item \c i to \c p. + /// \param i The item. + /// \param p The priority. /// \pre \c i must be stored in the heap with priority at most \c /// p relative to \c Compare. - /// \param i The item. - /// \param p The priority. void increase(const Item &i, const Prio &p) { - int idx = iim[i]; - bubble_down(idx, Pair(i,p), data.size()); + int idx = _iim[i]; + bubble_down(idx, Pair(i,p), _data.size()); } /// \brief Returns if \c item is in, has already been in, or has @@ -299,7 +300,7 @@ /// get back to the heap again. /// \param i The item. State state(const Item &i) const { - int s = iim[i]; + int s = _iim[i]; if( s>=0 ) s=0; return State(s); @@ -319,7 +320,7 @@ if (state(i) == IN_HEAP) { erase(i); } - iim[i] = st; + _iim[i] = st; break; case IN_HEAP: break; @@ -333,10 +334,10 @@ /// \c i item will out of the heap and \c j will be in the heap /// with the same prioriority as prevoiusly the \c i item. void replace(const Item& i, const Item& j) { - int idx = iim[i]; - iim.set(i, iim[j]); - iim.set(j, idx); - data[idx].first = j; + int idx = _iim[i]; + _iim.set(i, _iim[j]); + _iim.set(j, idx); + _data[idx].first = j; } }; // class BinHeap diff --git a/lemon/bits/edge_set_extender.h b/lemon/bits/edge_set_extender.h --- a/lemon/bits/edge_set_extender.h +++ b/lemon/bits/edge_set_extender.h @@ -24,14 +24,14 @@ #include #include -///\ingroup digraphbits -///\file -///\brief Extenders for the arc set types +//\ingroup digraphbits +//\file +//\brief Extenders for the arc set types namespace lemon { - /// \ingroup digraphbits - /// - /// \brief Extender for the ArcSets + // \ingroup digraphbits + // + // \brief Extender for the ArcSets template class ArcSetExtender : public Base { public: @@ -72,7 +72,7 @@ // Alteration notifier extensions - /// The arc observer registry. + // The arc observer registry. typedef AlterationNotifier ArcNotifier; protected: @@ -83,9 +83,7 @@ using Parent::notifier; - /// \brief Gives back the arc alteration notifier. - /// - /// Gives back the arc alteration notifier. + // Gives back the arc alteration notifier. ArcNotifier& notifier(Arc) const { return arc_notifier; } @@ -185,30 +183,30 @@ }; - /// \brief Base node of the iterator - /// - /// Returns the base node (ie. the source in this case) of the iterator + // \brief Base node of the iterator + // + // Returns the base node (ie. the source in this case) of the iterator Node baseNode(const OutArcIt &e) const { return Parent::source(static_cast(e)); } - /// \brief Running node of the iterator - /// - /// Returns the running node (ie. the target in this case) of the - /// iterator + // \brief Running node of the iterator + // + // Returns the running node (ie. the target in this case) of the + // iterator Node runningNode(const OutArcIt &e) const { return Parent::target(static_cast(e)); } - /// \brief Base node of the iterator - /// - /// Returns the base node (ie. the target in this case) of the iterator + // \brief Base node of the iterator + // + // Returns the base node (ie. the target in this case) of the iterator Node baseNode(const InArcIt &e) const { return Parent::target(static_cast(e)); } - /// \brief Running node of the iterator - /// - /// Returns the running node (ie. the source in this case) of the - /// iterator + // \brief Running node of the iterator + // + // Returns the running node (ie. the source in this case) of the + // iterator Node runningNode(const InArcIt &e) const { return Parent::source(static_cast(e)); } @@ -271,9 +269,9 @@ }; - /// \ingroup digraphbits - /// - /// \brief Extender for the EdgeSets + // \ingroup digraphbits + // + // \brief Extender for the EdgeSets template class EdgeSetExtender : public Base { @@ -492,43 +490,43 @@ } }; - /// \brief Base node of the iterator - /// - /// Returns the base node (ie. the source in this case) of the iterator + // \brief Base node of the iterator + // + // Returns the base node (ie. the source in this case) of the iterator Node baseNode(const OutArcIt &e) const { return Parent::source(static_cast(e)); } - /// \brief Running node of the iterator - /// - /// Returns the running node (ie. the target in this case) of the - /// iterator + // \brief Running node of the iterator + // + // Returns the running node (ie. the target in this case) of the + // iterator Node runningNode(const OutArcIt &e) const { return Parent::target(static_cast(e)); } - /// \brief Base node of the iterator - /// - /// Returns the base node (ie. the target in this case) of the iterator + // \brief Base node of the iterator + // + // Returns the base node (ie. the target in this case) of the iterator Node baseNode(const InArcIt &e) const { return Parent::target(static_cast(e)); } - /// \brief Running node of the iterator - /// - /// Returns the running node (ie. the source in this case) of the - /// iterator + // \brief Running node of the iterator + // + // Returns the running node (ie. the source in this case) of the + // iterator Node runningNode(const InArcIt &e) const { return Parent::source(static_cast(e)); } - /// Base node of the iterator - /// - /// Returns the base node of the iterator + // Base node of the iterator + // + // Returns the base node of the iterator Node baseNode(const IncEdgeIt &e) const { return e.direction ? u(e) : v(e); } - /// Running node of the iterator - /// - /// Returns the running node of the iterator + // Running node of the iterator + // + // Returns the running node of the iterator Node runningNode(const IncEdgeIt &e) const { return e.direction ? v(e) : u(e); } diff --git a/lemon/circulation.h b/lemon/circulation.h --- a/lemon/circulation.h +++ b/lemon/circulation.h @@ -215,9 +215,9 @@ ///@{ - template + template struct SetFlowMapTraits : public Traits { - typedef _FlowMap FlowMap; + typedef T FlowMap; static FlowMap *createFlowMap(const Digraph&) { LEMON_ASSERT(false, "FlowMap is not initialized"); return 0; // ignore warnings @@ -229,17 +229,17 @@ /// /// \ref named-templ-param "Named parameter" for setting FlowMap /// type. - template + template struct SetFlowMap : public Circulation > { + SetFlowMapTraits > { typedef Circulation > Create; + SetFlowMapTraits > Create; }; - template + template struct SetElevatorTraits : public Traits { - typedef _Elevator Elevator; + typedef T Elevator; static Elevator *createElevator(const Digraph&, int) { LEMON_ASSERT(false, "Elevator is not initialized"); return 0; // ignore warnings @@ -255,17 +255,17 @@ /// \ref elevator(Elevator&) "elevator()" function before calling /// \ref run() or \ref init(). /// \sa SetStandardElevator - template + template struct SetElevator : public Circulation > { + SetElevatorTraits > { typedef Circulation > Create; + SetElevatorTraits > Create; }; - template + template struct SetStandardElevatorTraits : public Traits { - typedef _Elevator Elevator; + typedef T Elevator; static Elevator *createElevator(const Digraph& digraph, int max_level) { return new Elevator(digraph, max_level); } @@ -283,12 +283,12 @@ /// algorithm with the \ref elevator(Elevator&) "elevator()" function /// before calling \ref run() or \ref init(). /// \sa SetElevator - template + template struct SetStandardElevator : public Circulation > { + SetStandardElevatorTraits > { typedef Circulation > Create; + SetStandardElevatorTraits > Create; }; /// @} @@ -682,7 +682,7 @@ /// empty set, so \c bar[v] will be \c false for all nodes \c v. /// /// \note This function calls \ref barrier() for each node, - /// so it runs in \f$O(n)\f$ time. + /// so it runs in O(n) time. /// /// \pre Either \ref run() or \ref init() must be called before /// using this function. diff --git a/lemon/concepts/graph.h b/lemon/concepts/graph.h --- a/lemon/concepts/graph.h +++ b/lemon/concepts/graph.h @@ -601,23 +601,35 @@ /// \brief Opposite node on an arc /// - /// \return the opposite of the given Node on the given Edge + /// \return The opposite of the given node on the given edge. Node oppositeNode(Node, Edge) const { return INVALID; } /// \brief First node of the edge. /// - /// \return the first node of the given Edge. + /// \return The first node of the given edge. /// /// Naturally edges don't have direction and thus - /// don't have source and target node. But we use these two methods - /// to query the two nodes of the arc. The direction of the arc - /// which arises this way is called the inherent direction of the + /// don't have source and target node. However we use \c u() and \c v() + /// methods to query the two nodes of the arc. The direction of the + /// arc which arises this way is called the inherent direction of the /// edge, and is used to define the "default" direction /// of the directed versions of the arcs. - /// \sa direction + /// \sa v() + /// \sa direction() Node u(Edge) const { return INVALID; } /// \brief Second node of the edge. + /// + /// \return The second node of the given edge. + /// + /// Naturally edges don't have direction and thus + /// don't have source and target node. However we use \c u() and \c v() + /// methods to query the two nodes of the arc. The direction of the + /// arc which arises this way is called the inherent direction of the + /// edge, and is used to define the "default" direction + /// of the directed versions of the arcs. + /// \sa u() + /// \sa direction() Node v(Edge) const { return INVALID; } /// \brief Source node of the directed arc. diff --git a/lemon/concepts/graph_components.h b/lemon/concepts/graph_components.h --- a/lemon/concepts/graph_components.h +++ b/lemon/concepts/graph_components.h @@ -20,7 +20,6 @@ ///\file ///\brief The concept of graph components. - #ifndef LEMON_CONCEPTS_GRAPH_COMPONENTS_H #define LEMON_CONCEPTS_GRAPH_COMPONENTS_H @@ -44,7 +43,7 @@ /// with 'a'. #ifndef DOXYGEN - template + template #endif class GraphItem { public: @@ -296,11 +295,11 @@ /// core id functions for the digraph structure. /// The most of the base digraphs should conform to this concept. /// The id's are unique and immutable. - template - class IDableDigraphComponent : public _Base { + template + class IDableDigraphComponent : public BAS { public: - typedef _Base Base; + typedef BAS Base; typedef typename Base::Node Node; typedef typename Base::Arc Arc; @@ -374,14 +373,14 @@ /// core id functions for the undirected graph structure. The /// most of the base undirected graphs should conform to this /// concept. The id's are unique and immutable. - template - class IDableGraphComponent : public IDableDigraphComponent<_Base> { + template + class IDableGraphComponent : public IDableDigraphComponent { public: - typedef _Base Base; + typedef BAS Base; typedef typename Base::Edge Edge; - using IDableDigraphComponent<_Base>::id; + using IDableDigraphComponent::id; /// \brief Gives back an unique integer id for the Edge. /// @@ -425,8 +424,8 @@ /// /// Skeleton class for graph NodeIt and ArcIt. /// - template - class GraphItemIt : public _Item { + template + class GraphItemIt : public Item { public: /// \brief Default constructor. /// @@ -442,7 +441,7 @@ /// /// Sets the iterator to the first item of \c the graph. /// - explicit GraphItemIt(const _Graph&) {} + explicit GraphItemIt(const GR&) {} /// \brief Invalid constructor \& conversion. /// /// This constructor initializes the item to be invalid. @@ -479,24 +478,24 @@ ++it2 = it1; ++(++it1); - _Item bi = it1; + Item bi = it1; bi = it2; } - _Graph& g; + GR& g; }; }; /// \brief Skeleton class for graph InArcIt and OutArcIt /// /// \note Because InArcIt and OutArcIt may not inherit from the same - /// base class, the _selector is a additional template parameter. For - /// InArcIt you should instantiate it with character 'i' and for + /// base class, the \c sel is a additional template parameter (selector). + /// For InArcIt you should instantiate it with character 'i' and for /// OutArcIt with 'o'. - template - class GraphIncIt : public _Item { + template + class GraphIncIt : public Item { public: /// \brief Default constructor. /// @@ -507,14 +506,14 @@ /// /// Copy constructor. /// - GraphIncIt(GraphIncIt const& gi) : _Item(gi) {} + GraphIncIt(GraphIncIt const& gi) : Item(gi) {} /// \brief Sets the iterator to the first arc incoming into or outgoing /// from the node. /// /// Sets the iterator to the first arc incoming into or outgoing /// from the node. /// - explicit GraphIncIt(const _Graph&, const _Base&) {} + explicit GraphIncIt(const GR&, const Base&) {} /// \brief Invalid constructor \& conversion. /// /// This constructor initializes the item to be invalid. @@ -546,21 +545,21 @@ template struct Constraints { void constraints() { - checkConcept, _GraphIncIt>(); + checkConcept, _GraphIncIt>(); _GraphIncIt it1(graph, node); _GraphIncIt it2; it2 = ++it1; ++it2 = it1; ++(++it1); - _Item e = it1; + Item e = it1; e = it2; } - _Item arc; - _Base node; - _Graph graph; + Item arc; + Base node; + GR graph; _GraphIncIt it; }; }; @@ -571,12 +570,12 @@ /// This class provides beside the core digraph features /// iterator based iterable interface for the digraph structure. /// This concept is part of the Digraph concept. - template - class IterableDigraphComponent : public _Base { + template + class IterableDigraphComponent : public BAS { public: - typedef _Base Base; + typedef BAS Base; typedef typename Base::Node Node; typedef typename Base::Arc Arc; @@ -756,11 +755,11 @@ /// This class provides beside the core graph features iterator /// based iterable interface for the undirected graph structure. /// This concept is part of the Graph concept. - template - class IterableGraphComponent : public IterableDigraphComponent<_Base> { + template + class IterableGraphComponent : public IterableDigraphComponent { public: - typedef _Base Base; + typedef BAS Base; typedef typename Base::Node Node; typedef typename Base::Arc Arc; typedef typename Base::Edge Edge; @@ -773,8 +772,8 @@ /// This interface provides functions for iteration on graph items /// @{ - using IterableDigraphComponent<_Base>::first; - using IterableDigraphComponent<_Base>::next; + using IterableDigraphComponent::first; + using IterableDigraphComponent::next; /// \brief Gives back the first edge in the iterating /// order. @@ -808,8 +807,8 @@ /// use it. void nextInc(Edge&, bool&) const {} - using IterableDigraphComponent<_Base>::baseNode; - using IterableDigraphComponent<_Base>::runningNode; + using IterableDigraphComponent::baseNode; + using IterableDigraphComponent::runningNode; /// @} @@ -875,7 +874,6 @@ } const _Graph& graph; - }; }; @@ -887,11 +885,11 @@ /// obsevers can be registered into the notifier and whenever an /// alteration occured in the digraph all the observers will /// notified about it. - template - class AlterableDigraphComponent : public _Base { + template + class AlterableDigraphComponent : public BAS { public: - typedef _Base Base; + typedef BAS Base; typedef typename Base::Node Node; typedef typename Base::Arc Arc; @@ -945,11 +943,11 @@ /// obsevers can be registered into the notifier and whenever an /// alteration occured in the graph all the observers will /// notified about it. - template - class AlterableGraphComponent : public AlterableDigraphComponent<_Base> { + template + class AlterableGraphComponent : public AlterableDigraphComponent { public: - typedef _Base Base; + typedef BAS Base; typedef typename Base::Edge Edge; @@ -974,9 +972,7 @@ } const _Graph& graph; - }; - }; /// \brief Class describing the concept of graph maps @@ -984,18 +980,18 @@ /// This class describes the common interface of the graph maps /// (NodeMap, ArcMap), that is maps that can be used to /// associate data to graph descriptors (nodes or arcs). - template - class GraphMap : public ReadWriteMap<_Item, _Value> { + template + class GraphMap : public ReadWriteMap { public: - typedef ReadWriteMap<_Item, _Value> Parent; + typedef ReadWriteMap Parent; /// The graph type of the map. - typedef _Graph Graph; + typedef GR Graph; /// The key type of the map. - typedef _Item Key; + typedef K Key; /// The value type of the map. - typedef _Value Value; + typedef V Value; /// \brief Construct a new map. /// @@ -1055,11 +1051,11 @@ /// This class provides beside the core digraph features /// map interface for the digraph structure. /// This concept is part of the Digraph concept. - template - class MappableDigraphComponent : public _Base { + template + class MappableDigraphComponent : public BAS { public: - typedef _Base Base; + typedef BAS Base; typedef typename Base::Node Node; typedef typename Base::Arc Arc; @@ -1069,10 +1065,10 @@ /// /// ReadWrite map of the nodes. /// - template - class NodeMap : public GraphMap { + template + class NodeMap : public GraphMap { public: - typedef GraphMap Parent; + typedef GraphMap Parent; /// \brief Construct a new map. /// @@ -1083,7 +1079,7 @@ /// \brief Construct a new map with default value. /// /// Construct a new map for the digraph and initalise the values. - NodeMap(const MappableDigraphComponent& digraph, const _Value& value) + NodeMap(const MappableDigraphComponent& digraph, const V& value) : Parent(digraph, value) {} private: @@ -1097,7 +1093,7 @@ /// Assign operator. template NodeMap& operator=(const CMap&) { - checkConcept, CMap>(); + checkConcept, CMap>(); return *this; } @@ -1107,10 +1103,10 @@ /// /// ReadWrite map of the arcs. /// - template - class ArcMap : public GraphMap { + template + class ArcMap : public GraphMap { public: - typedef GraphMap Parent; + typedef GraphMap Parent; /// \brief Construct a new map. /// @@ -1121,7 +1117,7 @@ /// \brief Construct a new map with default value. /// /// Construct a new map for the digraph and initalise the values. - ArcMap(const MappableDigraphComponent& digraph, const _Value& value) + ArcMap(const MappableDigraphComponent& digraph, const V& value) : Parent(digraph, value) {} private: @@ -1135,7 +1131,7 @@ /// Assign operator. template ArcMap& operator=(const CMap&) { - checkConcept, CMap>(); + checkConcept, CMap>(); return *this; } @@ -1191,11 +1187,11 @@ /// This class provides beside the core graph features /// map interface for the graph structure. /// This concept is part of the Graph concept. - template - class MappableGraphComponent : public MappableDigraphComponent<_Base> { + template + class MappableGraphComponent : public MappableDigraphComponent { public: - typedef _Base Base; + typedef BAS Base; typedef typename Base::Edge Edge; typedef MappableGraphComponent Graph; @@ -1204,10 +1200,10 @@ /// /// ReadWrite map of the edges. /// - template - class EdgeMap : public GraphMap { + template + class EdgeMap : public GraphMap { public: - typedef GraphMap Parent; + typedef GraphMap Parent; /// \brief Construct a new map. /// @@ -1218,7 +1214,7 @@ /// \brief Construct a new map with default value. /// /// Construct a new map for the graph and initalise the values. - EdgeMap(const MappableGraphComponent& graph, const _Value& value) + EdgeMap(const MappableGraphComponent& graph, const V& value) : Parent(graph, value) {} private: @@ -1232,7 +1228,7 @@ /// Assign operator. template EdgeMap& operator=(const CMap&) { - checkConcept, CMap>(); + checkConcept, CMap>(); return *this; } @@ -1276,13 +1272,13 @@ /// extendable interface for the digraph structure. The main /// difference between the base and this interface is that the /// digraph alterations should handled already on this level. - template - class ExtendableDigraphComponent : public _Base { + template + class ExtendableDigraphComponent : public BAS { public: - typedef _Base Base; + typedef BAS Base; - typedef typename _Base::Node Node; - typedef typename _Base::Arc Arc; + typedef typename Base::Node Node; + typedef typename Base::Arc Arc; /// \brief Adds a new node to the digraph. /// @@ -1321,13 +1317,13 @@ /// The main difference between the base and this interface is /// that the graph alterations should handled already on this /// level. - template - class ExtendableGraphComponent : public _Base { + template + class ExtendableGraphComponent : public BAS { public: - typedef _Base Base; - typedef typename _Base::Node Node; - typedef typename _Base::Edge Edge; + typedef BAS Base; + typedef typename Base::Node Node; + typedef typename Base::Edge Edge; /// \brief Adds a new node to the graph. /// @@ -1365,11 +1361,11 @@ /// functions for the digraph structure. The main difference between /// the base and this interface is that the digraph alterations /// should handled already on this level. - template - class ErasableDigraphComponent : public _Base { + template + class ErasableDigraphComponent : public BAS { public: - typedef _Base Base; + typedef BAS Base; typedef typename Base::Node Node; typedef typename Base::Arc Arc; @@ -1405,11 +1401,11 @@ /// core erase functions for the undirceted graph structure. The /// main difference between the base and this interface is that /// the graph alterations should handled already on this level. - template - class ErasableGraphComponent : public _Base { + template + class ErasableGraphComponent : public BAS { public: - typedef _Base Base; + typedef BAS Base; typedef typename Base::Node Node; typedef typename Base::Edge Edge; @@ -1445,11 +1441,11 @@ /// functions for the digraph structure. The main difference between /// the base and this interface is that the digraph alterations /// should handled already on this level. - template - class ClearableDigraphComponent : public _Base { + template + class ClearableDigraphComponent : public BAS { public: - typedef _Base Base; + typedef BAS Base; /// \brief Erase all nodes and arcs from the digraph. /// @@ -1474,11 +1470,11 @@ /// core clear functions for the undirected graph structure. The /// main difference between the base and this interface is that /// the graph alterations should handled already on this level. - template - class ClearableGraphComponent : public ClearableDigraphComponent<_Base> { + template + class ClearableGraphComponent : public ClearableDigraphComponent { public: - typedef _Base Base; + typedef BAS Base; template struct Constraints { diff --git a/lemon/concepts/heap.h b/lemon/concepts/heap.h --- a/lemon/concepts/heap.h +++ b/lemon/concepts/heap.h @@ -35,17 +35,32 @@ /// \brief The heap concept. /// - /// Concept class describing the main interface of heaps. - template + /// Concept class describing the main interface of heaps. A \e heap + /// is a data structure for storing items with specified values called + /// \e priorities in such a way that finding the item with minimum + /// priority is efficient. In a heap one can change the priority of an + /// item, add or erase an item, etc. + /// + /// \tparam PR Type of the priority of the items. + /// \tparam IM A read and writable item map with int values, used + /// internally to handle the cross references. + /// \tparam Comp A functor class for the ordering of the priorities. + /// The default is \c std::less. +#ifdef DOXYGEN + template > +#else + template +#endif class Heap { public: + /// Type of the item-int map. + typedef IM ItemIntMap; + /// Type of the priorities. + typedef PR Prio; /// Type of the items stored in the heap. typedef typename ItemIntMap::Key Item; - /// Type of the priorities. - typedef Priority Prio; - /// \brief Type to represent the states of the items. /// /// Each item has a state associated to it. It can be "in heap", @@ -53,12 +68,12 @@ /// from the point of view of the heap, but may be useful for /// the user. /// - /// The \c ItemIntMap must be initialized in such a way, that it - /// assigns \c PRE_HEAP (-1) to every item. + /// The item-int map must be initialized in such way that it assigns + /// \c PRE_HEAP (-1) to any element to be put in the heap. enum State { - IN_HEAP = 0, - PRE_HEAP = -1, - POST_HEAP = -2 + IN_HEAP = 0, ///< The "in heap" state constant. + PRE_HEAP = -1, ///< The "pre heap" state constant. + POST_HEAP = -2 ///< The "post heap" state constant. }; /// \brief The constructor. @@ -119,8 +134,8 @@ /// \brief The priority of an item. /// /// Returns the priority of the given item. + /// \param i The item. /// \pre \c i must be in the heap. - /// \param i The item. Prio operator[](const Item &i) const {} /// \brief Sets the priority of an item or inserts it, if it is @@ -137,17 +152,17 @@ /// \brief Decreases the priority of an item to the given value. /// /// Decreases the priority of an item to the given value. - /// \pre \c i must be stored in the heap with priority at least \c p. /// \param i The item. /// \param p The priority. + /// \pre \c i must be stored in the heap with priority at least \c p. void decrease(const Item &i, const Prio &p) {} /// \brief Increases the priority of an item to the given value. /// /// Increases the priority of an item to the given value. - /// \pre \c i must be stored in the heap with priority at most \c p. /// \param i The item. /// \param p The priority. + /// \pre \c i must be stored in the heap with priority at most \c p. void increase(const Item &i, const Prio &p) {} /// \brief Returns if an item is in, has already been in, or has diff --git a/lemon/concepts/path.h b/lemon/concepts/path.h --- a/lemon/concepts/path.h +++ b/lemon/concepts/path.h @@ -38,19 +38,19 @@ /// /// A skeleton structure for representing directed paths in a /// digraph. - /// \tparam _Digraph The digraph type in which the path is. + /// \tparam GR The digraph type in which the path is. /// /// In a sense, the path can be treated as a list of arcs. The /// lemon path type stores just this list. As a consequence it /// cannot enumerate the nodes in the path and the zero length /// paths cannot store the source. /// - template + template class Path { public: /// Type of the underlying digraph. - typedef _Digraph Digraph; + typedef GR Digraph; /// Arc type of the underlying digraph. typedef typename Digraph::Arc Arc; @@ -205,18 +205,17 @@ /// LEMON such algorithms gives back a path dumper what can /// assigned to a real path and the dumpers can be implemented as /// an adaptor class to the predecessor map. - - /// \tparam _Digraph The digraph type in which the path is. + /// + /// \tparam GR The digraph type in which the path is. /// /// The paths can be constructed from any path type by a /// template constructor or a template assignment operator. - /// - template + template class PathDumper { public: /// Type of the underlying digraph. - typedef _Digraph Digraph; + typedef GR Digraph; /// Arc type of the underlying digraph. typedef typename Digraph::Arc Arc; diff --git a/lemon/connectivity.h b/lemon/connectivity.h --- a/lemon/connectivity.h +++ b/lemon/connectivity.h @@ -46,7 +46,7 @@ /// /// Check whether the given undirected graph is connected. /// \param graph The undirected graph. - /// \return %True when there is path between any two nodes in the graph. + /// \return \c true when there is path between any two nodes in the graph. /// \note By definition, the empty graph is connected. template bool connected(const Graph& graph) { @@ -234,7 +234,7 @@ /// Check whether the given directed graph is strongly connected. The /// graph is strongly connected when any two nodes of the graph are /// connected with directed paths in both direction. - /// \return %False when the graph is not strongly connected. + /// \return \c false when the graph is not strongly connected. /// \see connected /// /// \note By definition, the empty graph is strongly connected. @@ -709,7 +709,7 @@ /// on same circle. /// /// \param graph The graph. - /// \return %True when the graph bi-node-connected. + /// \return \c true when the graph bi-node-connected. template bool biNodeConnected(const Graph& graph) { return countBiNodeConnectedComponents(graph) <= 1; @@ -1230,7 +1230,7 @@ /// from 0 to the number of the nodes in the graph minus one. Each values /// of the map will be set exactly once, the values will be set descending /// order. - /// \return %False when the graph is not DAG. + /// \return \c false when the graph is not DAG. /// /// \see topologicalSort /// \see dag @@ -1279,7 +1279,7 @@ /// /// Check that the given directed graph is a DAG. The DAG is /// an Directed Acyclic Digraph. - /// \return %False when the graph is not DAG. + /// \return \c false when the graph is not DAG. /// \see acyclic template bool dag(const Digraph& digraph) { @@ -1321,7 +1321,7 @@ /// /// Check that the given undirected graph acyclic. /// \param graph The undirected graph. - /// \return %True when there is no circle in the graph. + /// \return \c true when there is no circle in the graph. /// \see dag template bool acyclic(const Graph& graph) { @@ -1355,7 +1355,7 @@ /// /// Check that the given undirected graph is tree. /// \param graph The undirected graph. - /// \return %True when the graph is acyclic and connected. + /// \return \c true when the graph is acyclic and connected. template bool tree(const Graph& graph) { checkConcept(); @@ -1448,7 +1448,7 @@ /// The function checks if the given undirected \c graph graph is bipartite /// or not. The \ref Bfs algorithm is used to calculate the result. /// \param graph The undirected graph. - /// \return %True if \c graph is bipartite, %false otherwise. + /// \return \c true if \c graph is bipartite, \c false otherwise. /// \sa bipartitePartitions template inline bool bipartite(const Graph &graph){ @@ -1489,7 +1489,7 @@ /// \param graph The undirected graph. /// \retval partMap A writable bool map of nodes. It will be set as the /// two partitions of the graph. - /// \return %True if \c graph is bipartite, %false otherwise. + /// \return \c true if \c graph is bipartite, \c false otherwise. template inline bool bipartitePartitions(const Graph &graph, NodeMap &partMap){ using namespace _connectivity_bits; diff --git a/lemon/core.h b/lemon/core.h --- a/lemon/core.h +++ b/lemon/core.h @@ -1034,11 +1034,11 @@ /// ///\sa findArc() ///\sa ArcLookUp, AllArcLookUp, DynArcLookUp - template - class ConArcIt : public _Graph::Arc { + template + class ConArcIt : public GR::Arc { public: - typedef _Graph Graph; + typedef GR Graph; typedef typename Graph::Arc Parent; typedef typename Graph::Arc Arc; @@ -1157,11 +1157,11 @@ ///\endcode /// ///\sa findEdge() - template - class ConEdgeIt : public _Graph::Edge { + template + class ConEdgeIt : public GR::Edge { public: - typedef _Graph Graph; + typedef GR Graph; typedef typename Graph::Edge Parent; typedef typename Graph::Edge Edge; @@ -1211,29 +1211,29 @@ ///optimal time bound in a constant factor for any distribution of ///queries. /// - ///\tparam G The type of the underlying digraph. + ///\tparam GR The type of the underlying digraph. /// ///\sa ArcLookUp ///\sa AllArcLookUp - template + template class DynArcLookUp - : protected ItemSetTraits::ItemNotifier::ObserverBase + : protected ItemSetTraits::ItemNotifier::ObserverBase { public: - typedef typename ItemSetTraits + typedef typename ItemSetTraits ::ItemNotifier::ObserverBase Parent; - TEMPLATE_DIGRAPH_TYPEDEFS(G); - typedef G Digraph; + TEMPLATE_DIGRAPH_TYPEDEFS(GR); + typedef GR Digraph; protected: - class AutoNodeMap : public ItemSetTraits::template Map::Type { + class AutoNodeMap : public ItemSetTraits::template Map::Type { public: - typedef typename ItemSetTraits::template Map::Type Parent; + typedef typename ItemSetTraits::template Map::Type Parent; - AutoNodeMap(const G& digraph) : Parent(digraph, INVALID) {} + AutoNodeMap(const GR& digraph) : Parent(digraph, INVALID) {} virtual void add(const Node& node) { Parent::add(node); @@ -1623,16 +1623,16 @@ ///digraph changes. This is a time consuming (superlinearly proportional ///(O(m logm)) to the number of arcs). /// - ///\tparam G The type of the underlying digraph. + ///\tparam GR The type of the underlying digraph. /// ///\sa DynArcLookUp ///\sa AllArcLookUp - template + template class ArcLookUp { public: - TEMPLATE_DIGRAPH_TYPEDEFS(G); - typedef G Digraph; + TEMPLATE_DIGRAPH_TYPEDEFS(GR); + typedef GR Digraph; protected: const Digraph &_g; @@ -1733,20 +1733,20 @@ ///digraph changes. This is a time consuming (superlinearly proportional ///(O(m logm)) to the number of arcs). /// - ///\tparam G The type of the underlying digraph. + ///\tparam GR The type of the underlying digraph. /// ///\sa DynArcLookUp ///\sa ArcLookUp - template - class AllArcLookUp : public ArcLookUp + template + class AllArcLookUp : public ArcLookUp { - using ArcLookUp::_g; - using ArcLookUp::_right; - using ArcLookUp::_left; - using ArcLookUp::_head; + using ArcLookUp::_g; + using ArcLookUp::_right; + using ArcLookUp::_left; + using ArcLookUp::_head; - TEMPLATE_DIGRAPH_TYPEDEFS(G); - typedef G Digraph; + TEMPLATE_DIGRAPH_TYPEDEFS(GR); + typedef GR Digraph; typename Digraph::template ArcMap _next; @@ -1773,7 +1773,7 @@ /// ///It builds up the search database, which remains valid until the digraph ///changes. - AllArcLookUp(const Digraph &g) : ArcLookUp(g), _next(g) {refreshNext();} + AllArcLookUp(const Digraph &g) : ArcLookUp(g), _next(g) {refreshNext();} ///Refresh the data structure at a node. @@ -1783,7 +1783,7 @@ ///the number of the outgoing arcs of \c n. void refresh(Node n) { - ArcLookUp::refresh(n); + ArcLookUp::refresh(n); refreshNext(_head[n]); } @@ -1830,7 +1830,7 @@ #ifdef DOXYGEN Arc operator()(Node s, Node t, Arc prev=INVALID) const {} #else - using ArcLookUp::operator() ; + using ArcLookUp::operator() ; Arc operator()(Node s, Node t, Arc prev) const { return prev==INVALID?(*this)(s,t):_next[prev]; diff --git a/lemon/dijkstra.h b/lemon/dijkstra.h --- a/lemon/dijkstra.h +++ b/lemon/dijkstra.h @@ -38,8 +38,10 @@ /// /// This operation traits class defines all computational operations and /// constants which are used in the Dijkstra algorithm. - template + template struct DijkstraDefaultOperationTraits { + /// \e + typedef V Value; /// \brief Gives back the zero value of the type. static Value zero() { return static_cast(0); @@ -58,8 +60,8 @@ ///Default traits class of Dijkstra class. ///\tparam GR The type of the digraph. - ///\tparam LM The type of the length map. - template + ///\tparam LEN The type of the length map. + template struct DijkstraDefaultTraits { ///The type of the digraph the algorithm runs on. @@ -69,9 +71,9 @@ ///The type of the map that stores the arc lengths. ///It must meet the \ref concepts::ReadMap "ReadMap" concept. - typedef LM LengthMap; + typedef LEN LengthMap; ///The type of the length of the arcs. - typedef typename LM::Value Value; + typedef typename LEN::Value Value; /// Operation traits for %Dijkstra algorithm. @@ -100,7 +102,7 @@ /// ///\sa BinHeap ///\sa Dijkstra - typedef BinHeap > Heap; + typedef BinHeap > Heap; ///Instantiates a \c Heap. ///This function instantiates a \ref Heap. @@ -150,7 +152,7 @@ ///The type of the map that stores the distances of the nodes. ///It must meet the \ref concepts::WriteMap "WriteMap" concept. - typedef typename Digraph::template NodeMap DistMap; + typedef typename Digraph::template NodeMap DistMap; ///Instantiates a \c DistMap. ///This function instantiates a \ref DistMap. @@ -180,18 +182,18 @@ /// ///\tparam GR The type of the digraph the algorithm runs on. ///The default type is \ref ListDigraph. - ///\tparam LM A \ref concepts::ReadMap "readable" arc map that specifies + ///\tparam LEN A \ref concepts::ReadMap "readable" arc map that specifies ///the lengths of the arcs. ///It is read once for each arc, so the map may involve in ///relatively time consuming process to compute the arc lengths if ///it is necessary. The default map type is \ref ///concepts::Digraph::ArcMap "GR::ArcMap". #ifdef DOXYGEN - template + template #else template , - typename TR=DijkstraDefaultTraits > + typename LEN=typename GR::template ArcMap, + typename TR=DijkstraDefaultTraits > #endif class Dijkstra { public: @@ -913,8 +915,8 @@ ///Default traits class of dijkstra() function. ///\tparam GR The type of the digraph. - ///\tparam LM The type of the length map. - template + ///\tparam LEN The type of the length map. + template struct DijkstraWizardDefaultTraits { ///The type of the digraph the algorithm runs on. @@ -923,9 +925,9 @@ ///The type of the map that stores the arc lengths. ///It must meet the \ref concepts::ReadMap "ReadMap" concept. - typedef LM LengthMap; + typedef LEN LengthMap; ///The type of the length of the arcs. - typedef typename LM::Value Value; + typedef typename LEN::Value Value; /// Operation traits for Dijkstra algorithm. @@ -1007,7 +1009,7 @@ ///The type of the map that stores the distances of the nodes. ///It must meet the \ref concepts::WriteMap "WriteMap" concept. - typedef typename Digraph::template NodeMap DistMap; + typedef typename Digraph::template NodeMap DistMap; ///Instantiates a DistMap. ///This function instantiates a DistMap. @@ -1033,10 +1035,10 @@ /// as well as the \ref Dijkstra class. /// The \ref DijkstraWizardBase is a class to be the default traits of the /// \ref DijkstraWizard class. - template - class DijkstraWizardBase : public DijkstraWizardDefaultTraits + template + class DijkstraWizardBase : public DijkstraWizardDefaultTraits { - typedef DijkstraWizardDefaultTraits Base; + typedef DijkstraWizardDefaultTraits Base; protected: //The type of the nodes in the digraph. typedef typename Base::Digraph::Node Node; @@ -1070,9 +1072,9 @@ /// others are initiated to \c 0. /// \param g The digraph the algorithm runs on. /// \param l The length map. - DijkstraWizardBase(const GR &g,const LM &l) : + DijkstraWizardBase(const GR &g,const LEN &l) : _g(reinterpret_cast(const_cast(&g))), - _length(reinterpret_cast(const_cast(&l))), + _length(reinterpret_cast(const_cast(&l))), _processed(0), _pred(0), _dist(0), _path(0), _di(0) {} }; @@ -1281,11 +1283,11 @@ ///to the end of the parameter list. ///\sa DijkstraWizard ///\sa Dijkstra - template - DijkstraWizard > - dijkstra(const GR &digraph, const LM &length) + template + DijkstraWizard > + dijkstra(const GR &digraph, const LEN &length) { - return DijkstraWizard >(digraph,length); + return DijkstraWizard >(digraph,length); } } //END OF NAMESPACE LEMON diff --git a/lemon/edge_set.h b/lemon/edge_set.h --- a/lemon/edge_set.h +++ b/lemon/edge_set.h @@ -255,7 +255,7 @@ /// \ref concepts::Digraph "Digraph" or \ref concepts::Graph "Graph" /// concept. /// - /// This class is fully conform to the \ref concepts::Digraph + /// This class fully conforms to the \ref concepts::Digraph /// "Digraph" concept. template class ListArcSet : public ArcSetExtender > { @@ -336,7 +336,7 @@ /// /// Add a new arc to the digraph with source node \c s /// and target node \c t. - /// \return the new arc. + /// \return The new arc. Arc addArc(const Node& s, const Node& t) { return Parent::addArc(s, t); } @@ -684,7 +684,7 @@ /// \ref concepts::Digraph "Digraph" or \ref concepts::Graph "Graph" /// concept. /// - /// This class is fully conform to the \ref concepts::Graph "Graph" + /// This class fully conforms to the \ref concepts::Graph "Graph" /// concept. template class ListEdgeSet : public EdgeSetExtender > { @@ -761,7 +761,7 @@ /// /// Add a new edge to the graph with node \c u /// and node \c v endpoints. - /// \return the new edge. + /// \return The new edge. Edge addEdge(const Node& u, const Node& v) { return Parent::addEdge(u, v); } @@ -952,7 +952,7 @@ /// the arc set is invalidated, and it cannot be used anymore. The /// validity can be checked with the \c valid() member function. /// - /// This class is fully conform to the \ref concepts::Digraph + /// This class fully conforms to the \ref concepts::Digraph /// "Digraph" concept. template class SmartArcSet : public ArcSetExtender > { @@ -1041,7 +1041,7 @@ /// /// Add a new arc to the digraph with source node \c s /// and target node \c t. - /// \return the new arc. + /// \return The new arc. Arc addArc(const Node& s, const Node& t) { return Parent::addArc(s, t); } @@ -1300,7 +1300,7 @@ /// is invalidated, and it cannot be used anymore. The validity can /// be checked with the \c valid() member function. /// - /// This class is fully conform to the \ref concepts::Graph + /// This class fully conforms to the \ref concepts::Graph /// "Graph" concept. template class SmartEdgeSet : public EdgeSetExtender > { @@ -1389,7 +1389,7 @@ /// /// Add a new edge to the graph with node \c u /// and node \c v endpoints. - /// \return the new edge. + /// \return The new edge. Edge addEdge(const Node& u, const Node& v) { return Parent::addEdge(u, v); } diff --git a/lemon/elevator.h b/lemon/elevator.h --- a/lemon/elevator.h +++ b/lemon/elevator.h @@ -46,10 +46,10 @@ /// ///\sa LinkedElevator /// - ///\param Graph Type of the underlying graph. - ///\param Item Type of the items the data is assigned to (Graph::Node, - ///Graph::Arc, Graph::Edge). - template + ///\param GR Type of the underlying graph. + ///\param Item Type of the items the data is assigned to (\c GR::Node, + ///\c GR::Arc or \c GR::Edge). + template class Elevator { public: @@ -60,10 +60,10 @@ private: typedef Item *Vit; - typedef typename ItemSetTraits::template Map::Type VitMap; - typedef typename ItemSetTraits::template Map::Type IntMap; + typedef typename ItemSetTraits::template Map::Type VitMap; + typedef typename ItemSetTraits::template Map::Type IntMap; - const Graph &_g; + const GR &_g; int _max_level; int _item_num; VitMap _where; @@ -105,7 +105,7 @@ ///\param graph The underlying graph. ///\param max_level The maximum allowed level. ///Set the range of the possible labels to [0..max_level]. - Elevator(const Graph &graph,int max_level) : + Elevator(const GR &graph,int max_level) : _g(graph), _max_level(max_level), _item_num(_max_level), @@ -122,9 +122,9 @@ ///\param graph The underlying graph. ///Set the range of the possible labels to [0..max_level], ///where \c max_level is equal to the number of labeled items in the graph. - Elevator(const Graph &graph) : + Elevator(const GR &graph) : _g(graph), - _max_level(countItems(graph)), + _max_level(countItems(graph)), _item_num(_max_level), _where(graph), _level(graph,0), @@ -430,7 +430,7 @@ _first[0]=&_items[0]; _last_active[0]=&_items[0]-1; Vit n=&_items[0]; - for(typename ItemSetTraits::ItemIt i(_g);i!=INVALID;++i) + for(typename ItemSetTraits::ItemIt i(_g);i!=INVALID;++i) { *n=i; _where.set(i,n); @@ -489,10 +489,10 @@ /// ///\sa Elevator /// - ///\param Graph Type of the underlying graph. - ///\param Item Type of the items the data is assigned to (Graph::Node, - ///Graph::Arc, Graph::Edge). - template + ///\param GR Type of the underlying graph. + ///\param Item Type of the items the data is assigned to (\c GR::Node, + ///\c GR::Arc or \c GR::Edge). + template class LinkedElevator { public: @@ -501,14 +501,14 @@ private: - typedef typename ItemSetTraits:: + typedef typename ItemSetTraits:: template Map::Type ItemMap; - typedef typename ItemSetTraits:: + typedef typename ItemSetTraits:: template Map::Type IntMap; - typedef typename ItemSetTraits:: + typedef typename ItemSetTraits:: template Map::Type BoolMap; - const Graph &_graph; + const GR &_graph; int _max_level; int _item_num; std::vector _first, _last; @@ -525,7 +525,7 @@ ///\param graph The underlying graph. ///\param max_level The maximum allowed level. ///Set the range of the possible labels to [0..max_level]. - LinkedElevator(const Graph& graph, int max_level) + LinkedElevator(const GR& graph, int max_level) : _graph(graph), _max_level(max_level), _item_num(_max_level), _first(_max_level + 1), _last(_max_level + 1), _prev(graph), _next(graph), @@ -538,8 +538,8 @@ ///\param graph The underlying graph. ///Set the range of the possible labels to [0..max_level], ///where \c max_level is equal to the number of labeled items in the graph. - LinkedElevator(const Graph& graph) - : _graph(graph), _max_level(countItems(graph)), + LinkedElevator(const GR& graph) + : _graph(graph), _max_level(countItems(graph)), _item_num(_max_level), _first(_max_level + 1), _last(_max_level + 1), _prev(graph, INVALID), _next(graph, INVALID), @@ -935,7 +935,7 @@ _first[i] = _last[i] = INVALID; } _init_level = 0; - for(typename ItemSetTraits::ItemIt i(_graph); + for(typename ItemSetTraits::ItemIt i(_graph); i != INVALID; ++i) { _level.set(i, _max_level); _active.set(i, false); diff --git a/lemon/euler.h b/lemon/euler.h --- a/lemon/euler.h +++ b/lemon/euler.h @@ -54,29 +54,29 @@ ///\endcode ///If \c g is not Euler then the resulted tour will not be full or closed. ///\sa EulerIt - template + template class DiEulerIt { - typedef typename Digraph::Node Node; - typedef typename Digraph::NodeIt NodeIt; - typedef typename Digraph::Arc Arc; - typedef typename Digraph::ArcIt ArcIt; - typedef typename Digraph::OutArcIt OutArcIt; - typedef typename Digraph::InArcIt InArcIt; + typedef typename GR::Node Node; + typedef typename GR::NodeIt NodeIt; + typedef typename GR::Arc Arc; + typedef typename GR::ArcIt ArcIt; + typedef typename GR::OutArcIt OutArcIt; + typedef typename GR::InArcIt InArcIt; - const Digraph &g; - typename Digraph::template NodeMap nedge; + const GR &g; + typename GR::template NodeMap nedge; std::list euler; public: ///Constructor - ///\param _g A digraph. + ///\param gr A digraph. ///\param start The starting point of the tour. If it is not given /// the tour will start from the first node. - DiEulerIt(const Digraph &_g,typename Digraph::Node start=INVALID) - : g(_g), nedge(g) + DiEulerIt(const GR &gr, typename GR::Node start = INVALID) + : g(gr), nedge(g) { if(start==INVALID) start=NodeIt(g); for(NodeIt n(g);n!=INVALID;++n) nedge[n]=OutArcIt(g,n); @@ -145,31 +145,31 @@ /// ///If \c g is not Euler then the resulted tour will not be full or closed. ///\sa EulerIt - template + template class EulerIt { - typedef typename Digraph::Node Node; - typedef typename Digraph::NodeIt NodeIt; - typedef typename Digraph::Arc Arc; - typedef typename Digraph::Edge Edge; - typedef typename Digraph::ArcIt ArcIt; - typedef typename Digraph::OutArcIt OutArcIt; - typedef typename Digraph::InArcIt InArcIt; + typedef typename GR::Node Node; + typedef typename GR::NodeIt NodeIt; + typedef typename GR::Arc Arc; + typedef typename GR::Edge Edge; + typedef typename GR::ArcIt ArcIt; + typedef typename GR::OutArcIt OutArcIt; + typedef typename GR::InArcIt InArcIt; - const Digraph &g; - typename Digraph::template NodeMap nedge; - typename Digraph::template EdgeMap visited; + const GR &g; + typename GR::template NodeMap nedge; + typename GR::template EdgeMap visited; std::list euler; public: ///Constructor - ///\param _g An graph. + ///\param gr An graph. ///\param start The starting point of the tour. If it is not given /// the tour will start from the first node. - EulerIt(const Digraph &_g,typename Digraph::Node start=INVALID) - : g(_g), nedge(g), visited(g,false) + EulerIt(const GR &gr, typename GR::Node start = INVALID) + : g(gr), nedge(g), visited(g, false) { if(start==INVALID) start=NodeIt(g); for(NodeIt n(g);n!=INVALID;++n) nedge[n]=OutArcIt(g,n); @@ -238,25 +238,25 @@ ///and only if it is connected and the number of incident arcs is even ///for each node. Therefore, there are digraphs which are not Eulerian, ///but still have an Euler tour. - template + template #ifdef DOXYGEN bool #else - typename enable_if,bool>::type - eulerian(const Digraph &g) + typename enable_if,bool>::type + eulerian(const GR &g) { - for(typename Digraph::NodeIt n(g);n!=INVALID;++n) + for(typename GR::NodeIt n(g);n!=INVALID;++n) if(countIncEdges(g,n)%2) return false; return connected(g); } - template - typename disable_if,bool>::type + template + typename disable_if,bool>::type #endif - eulerian(const Digraph &g) + eulerian(const GR &g) { - for(typename Digraph::NodeIt n(g);n!=INVALID;++n) + for(typename GR::NodeIt n(g);n!=INVALID;++n) if(countInArcs(g,n)!=countOutArcs(g,n)) return false; - return connected(Undirector(g)); + return connected(Undirector(g)); } } diff --git a/lemon/graph_to_eps.h b/lemon/graph_to_eps.h --- a/lemon/graph_to_eps.h +++ b/lemon/graph_to_eps.h @@ -64,11 +64,11 @@ ///Default traits class of \ref GraphToEps. /// -///\c G is the type of the underlying graph. -template +///\param GR is the type of the underlying graph. +template struct DefaultGraphToEpsTraits { - typedef G Graph; + typedef GR Graph; typedef typename Graph::Node Node; typedef typename Graph::NodeIt NodeIt; typedef typename Graph::Arc Arc; @@ -139,15 +139,14 @@ ///Constructor ///Constructor - ///\param _g Reference to the graph to be printed. - ///\param _os Reference to the output stream. - ///\param _os Reference to the output stream. + ///\param gr Reference to the graph to be printed. + ///\param ost Reference to the output stream. ///By default it is std::cout. - ///\param _pros If it is \c true, then the \c ostream referenced by \c _os + ///\param pros If it is \c true, then the \c ostream referenced by \c os ///will be explicitly deallocated by the destructor. - DefaultGraphToEpsTraits(const G &_g,std::ostream& _os=std::cout, - bool _pros=false) : - g(_g), os(_os), + DefaultGraphToEpsTraits(const GR &gr, std::ostream& ost = std::cout, + bool pros = false) : + g(gr), os(ost), _coords(dim2::Point(1,1)), _nodeSizes(1), _nodeShapes(0), _nodeColors(WHITE), _arcColors(BLACK), _arcWidths(1.0), _arcWidthScale(0.003), @@ -158,8 +157,8 @@ _enableParallel(false), _parArcDist(1), _showNodeText(false), _nodeTexts(false), _nodeTextSize(1), _showNodePsText(false), _nodePsTexts(false), _nodePsTextsPreamble(0), - _undirected(lemon::UndirectedTagIndicator::value), - _pleaseRemoveOsStream(_pros), _scaleToA4(false), + _undirected(lemon::UndirectedTagIndicator::value), + _pleaseRemoveOsStream(pros), _scaleToA4(false), _nodeTextColorType(SAME_COL), _nodeTextColors(BLACK), _autoNodeScale(false), _autoArcWidthScale(false), @@ -1134,55 +1133,55 @@ ///\warning Don't forget to put the \ref GraphToEps::run() "run()" ///to the end of the parameter list. ///\sa GraphToEps -///\sa graphToEps(G &g, const char *file_name) -template -GraphToEps > -graphToEps(G &g, std::ostream& os=std::cout) +///\sa graphToEps(GR &g, const char *file_name) +template +GraphToEps > +graphToEps(GR &g, std::ostream& os=std::cout) { return - GraphToEps >(DefaultGraphToEpsTraits(g,os)); + GraphToEps >(DefaultGraphToEpsTraits(g,os)); } ///Generates an EPS file from a graph ///\ingroup eps_io ///This function does the same as -///\ref graphToEps(G &g,std::ostream& os) +///\ref graphToEps(GR &g,std::ostream& os) ///but it writes its output into the file \c file_name ///instead of a stream. -///\sa graphToEps(G &g, std::ostream& os) -template -GraphToEps > -graphToEps(G &g,const char *file_name) +///\sa graphToEps(GR &g, std::ostream& os) +template +GraphToEps > +graphToEps(GR &g,const char *file_name) { std::ostream* os = new std::ofstream(file_name); if (!(*os)) { delete os; throw IoError("Cannot write file", file_name); } - return GraphToEps > - (DefaultGraphToEpsTraits(g,*os,true)); + return GraphToEps > + (DefaultGraphToEpsTraits(g,*os,true)); } ///Generates an EPS file from a graph ///\ingroup eps_io ///This function does the same as -///\ref graphToEps(G &g,std::ostream& os) +///\ref graphToEps(GR &g,std::ostream& os) ///but it writes its output into the file \c file_name ///instead of a stream. -///\sa graphToEps(G &g, std::ostream& os) -template -GraphToEps > -graphToEps(G &g,const std::string& file_name) +///\sa graphToEps(GR &g, std::ostream& os) +template +GraphToEps > +graphToEps(GR &g,const std::string& file_name) { std::ostream* os = new std::ofstream(file_name.c_str()); if (!(*os)) { delete os; throw IoError("Cannot write file", file_name); } - return GraphToEps > - (DefaultGraphToEpsTraits(g,*os,true)); + return GraphToEps > + (DefaultGraphToEpsTraits(g,*os,true)); } } //END OF NAMESPACE LEMON diff --git a/lemon/grid_graph.h b/lemon/grid_graph.h --- a/lemon/grid_graph.h +++ b/lemon/grid_graph.h @@ -496,7 +496,7 @@ /// } ///\endcode /// - /// This graph type is fully conform to the \ref concepts::Graph + /// This graph type fully conforms to the \ref concepts::Graph /// "Graph" concept, and it also has an important extra feature /// that its maps are real \ref concepts::ReferenceMap /// "reference map"s. diff --git a/lemon/hao_orlin.h b/lemon/hao_orlin.h --- a/lemon/hao_orlin.h +++ b/lemon/hao_orlin.h @@ -57,27 +57,27 @@ /// undirected graph you can run just the first phase of the /// algorithm or you can use the algorithm of Nagamochi and Ibaraki /// which solves the undirected problem in - /// \f$ O(nm + n^2 \log(n)) \f$ time: it is implemented in the + /// \f$ O(nm + n^2 \log n) \f$ time: it is implemented in the /// NagamochiIbaraki algorithm class. /// - /// \param _Digraph is the graph type of the algorithm. - /// \param _CapacityMap is an edge map of capacities which should - /// be any numreric type. The default type is _Digraph::ArcMap. - /// \param _Tolerance is the handler of the inexact computation. The - /// default type for this is Tolerance. + /// \param GR The digraph class the algorithm runs on. + /// \param CAP An arc map of capacities which can be any numreric type. + /// The default type is \ref concepts::Digraph::ArcMap "GR::ArcMap". + /// \param TOL Tolerance class for handling inexact computations. The + /// default tolerance type is \ref Tolerance "Tolerance". #ifdef DOXYGEN - template + template #else - template , - typename _Tolerance = Tolerance > + template , + typename TOL = Tolerance > #endif class HaoOrlin { private: - typedef _Digraph Digraph; - typedef _CapacityMap CapacityMap; - typedef _Tolerance Tolerance; + typedef GR Digraph; + typedef CAP CapacityMap; + typedef TOL Tolerance; typedef typename CapacityMap::Value Value; @@ -817,7 +817,7 @@ /// \name Execution control /// The simplest way to execute the algorithm is to use - /// one of the member functions called \c run(...). + /// one of the member functions called \ref run(). /// \n /// If you need more control on the execution, /// first you must call \ref init(), then the \ref calculateIn() or diff --git a/lemon/hypercube_graph.h b/lemon/hypercube_graph.h --- a/lemon/hypercube_graph.h +++ b/lemon/hypercube_graph.h @@ -291,7 +291,7 @@ /// reasons. Thus the maximum dimension of this implementation is 26 /// (assuming that the size of \c int is 32 bit). /// - /// This graph type is fully conform to the \ref concepts::Graph + /// This graph type fully conforms to the \ref concepts::Graph /// "Graph" concept, and it also has an important extra feature /// that its maps are real \ref concepts::ReferenceMap /// "reference map"s. diff --git a/lemon/lgf_reader.h b/lemon/lgf_reader.h --- a/lemon/lgf_reader.h +++ b/lemon/lgf_reader.h @@ -448,16 +448,16 @@ /// It is impossible to read this in /// a single pass, because the arcs are not constructed when the node /// maps are read. - template + template class DigraphReader { public: - typedef _Digraph Digraph; + typedef GR Digraph; + + private: + TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); - private: - - std::istream* _is; bool local_is; std::string _filename; @@ -1246,15 +1246,16 @@ /// prefixed with \c '+' and \c '-', then these can be read into an /// arc map. Similarly, an attribute can be read into an arc, if /// it's value is an edge label prefixed with \c '+' or \c '-'. - template + template class GraphReader { public: - typedef _Graph Graph; + typedef GR Graph; + + private: + TEMPLATE_GRAPH_TYPEDEFS(Graph); - private: - std::istream* _is; bool local_is; std::string _filename; @@ -1356,12 +1357,12 @@ } private: - template - friend GraphReader graphReader(GR& graph, std::istream& is); - template - friend GraphReader graphReader(GR& graph, const std::string& fn); - template - friend GraphReader graphReader(GR& graph, const char *fn); + template + friend GraphReader graphReader(Graph& graph, std::istream& is); + template + friend GraphReader graphReader(Graph& graph, const std::string& fn); + template + friend GraphReader graphReader(Graph& graph, const char *fn); GraphReader(GraphReader& other) : _is(other._is), local_is(other.local_is), _graph(other._graph), diff --git a/lemon/lgf_writer.h b/lemon/lgf_writer.h --- a/lemon/lgf_writer.h +++ b/lemon/lgf_writer.h @@ -406,11 +406,11 @@ /// section to the stream. The output stream can be retrieved with /// the \c ostream() function, hence the second pass can append its /// output to the output of the first pass. - template + template class DigraphWriter { public: - typedef _Digraph Digraph; + typedef GR Digraph; TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); private: @@ -974,11 +974,11 @@ /// '+' and \c '-'. The arcs are written into the \c \@attributes /// section as a \c '+' or a \c '-' prefix (depends on the direction /// of the arc) and the label of corresponding edge. - template + template class GraphWriter { public: - typedef _Graph Graph; + typedef GR Graph; TEMPLATE_GRAPH_TYPEDEFS(Graph); private: @@ -1073,15 +1073,15 @@ private: - template - friend GraphWriter graphWriter(const GR& graph, - std::ostream& os); - template - friend GraphWriter graphWriter(const GR& graph, - const std::string& fn); - template - friend GraphWriter graphWriter(const GR& graph, - const char *fn); + template + friend GraphWriter graphWriter(const Graph& graph, + std::ostream& os); + template + friend GraphWriter graphWriter(const Graph& graph, + const std::string& fn); + template + friend GraphWriter graphWriter(const Graph& graph, + const char *fn); GraphWriter(GraphWriter& other) : _os(other._os), local_os(other.local_os), _graph(other._graph), diff --git a/lemon/list_graph.h b/lemon/list_graph.h --- a/lemon/list_graph.h +++ b/lemon/list_graph.h @@ -351,14 +351,14 @@ ///Add a new node to the digraph. ///Add a new node to the digraph. - ///\return the new node. + ///\return The new node. Node addNode() { return Parent::addNode(); } ///Add a new arc to the digraph. ///Add a new arc to the digraph with source node \c s ///and target node \c t. - ///\return the new arc. + ///\return The new arc. Arc addArc(const Node& s, const Node& t) { return Parent::addArc(s, t); } @@ -1208,14 +1208,14 @@ /// \brief Add a new node to the graph. /// /// Add a new node to the graph. - /// \return the new node. + /// \return The new node. Node addNode() { return Parent::addNode(); } /// \brief Add a new edge to the graph. /// /// Add a new edge to the graph with source node \c s /// and target node \c t. - /// \return the new edge. + /// \return The new edge. Edge addEdge(const Node& s, const Node& t) { return Parent::addEdge(s, t); } diff --git a/lemon/maps.h b/lemon/maps.h --- a/lemon/maps.h +++ b/lemon/maps.h @@ -63,9 +63,10 @@ template class NullMap : public MapBase { public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef K Key; + ///\e + typedef V Value; /// Gives back a default constructed element. Value operator[](const Key&) const { return Value(); } @@ -102,9 +103,10 @@ private: V _value; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef K Key; + ///\e + typedef V Value; /// Default constructor @@ -168,9 +170,10 @@ template class ConstMap > : public MapBase { public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef K Key; + ///\e + typedef V Value; /// Constructor. ConstMap() {} @@ -202,9 +205,10 @@ template class IdentityMap : public MapBase { public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef T Key; + ///\e + typedef T Value; /// Gives back the given value without any modification. Value operator[](const Key &k) const { @@ -245,11 +249,10 @@ public: - typedef MapBase Parent; /// Key type - typedef typename Parent::Key Key; + typedef int Key; /// Value type - typedef typename Parent::Value Value; + typedef V Value; /// Reference type typedef typename Vector::reference Reference; /// Const reference type @@ -353,17 +356,16 @@ /// /// The simplest way of using this map is through the sparseMap() /// function. - template > + template > class SparseMap : public MapBase { template friend class SparseMap; public: - typedef MapBase Parent; /// Key type - typedef typename Parent::Key Key; + typedef K Key; /// Value type - typedef typename Parent::Value Value; + typedef V Value; /// Reference type typedef Value& Reference; /// Const reference type @@ -373,7 +375,7 @@ private: - typedef std::map Map; + typedef std::map Map; Map _map; Value _value; @@ -489,14 +491,15 @@ const M1 &_m1; const M2 &_m2; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M2::Key Key; + ///\e + typedef typename M1::Value Value; /// Constructor ComposeMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} - /// \e + ///\e typename MapTraits::ConstReturnValue operator[](const Key &k) const { return _m1[_m2[k]]; } }; @@ -545,14 +548,15 @@ const M2 &_m2; F _f; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M1::Key Key; + ///\e + typedef V Value; /// Constructor CombineMap(const M1 &m1, const M2 &m2, const F &f = F()) : _m1(m1), _m2(m2), _f(f) {} - /// \e + ///\e Value operator[](const Key &k) const { return _f(_m1[k],_m2[k]); } }; @@ -615,13 +619,14 @@ class FunctorToMap : public MapBase { F _f; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef K Key; + ///\e + typedef V Value; /// Constructor FunctorToMap(const F &f = F()) : _f(f) {} - /// \e + ///\e Value operator[](const Key &k) const { return _f(k); } }; @@ -669,18 +674,19 @@ class MapToFunctor : public MapBase { const M &_m; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; - - typedef typename Parent::Key argument_type; - typedef typename Parent::Value result_type; + ///\e + typedef typename M::Key Key; + ///\e + typedef typename M::Value Value; + + typedef typename M::Key argument_type; + typedef typename M::Value result_type; /// Constructor MapToFunctor(const M &m) : _m(m) {} - /// \e + ///\e Value operator()(const Key &k) const { return _m[k]; } - /// \e + ///\e Value operator[](const Key &k) const { return _m[k]; } }; @@ -709,9 +715,10 @@ class ConvertMap : public MapBase { const M &_m; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M::Key Key; + ///\e + typedef V Value; /// Constructor @@ -719,7 +726,7 @@ /// \param m The underlying map. ConvertMap(const M &m) : _m(m) {} - /// \e + ///\e Value operator[](const Key &k) const { return _m[k]; } }; @@ -751,9 +758,10 @@ M1 &_m1; M2 &_m2; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M1::Key Key; + ///\e + typedef typename M1::Value Value; /// Constructor ForkMap(M1 &m1, M2 &m2) : _m1(m1), _m2(m2) {} @@ -797,13 +805,14 @@ const M1 &_m1; const M2 &_m2; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M1::Key Key; + ///\e + typedef typename M1::Value Value; /// Constructor AddMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} - /// \e + ///\e Value operator[](const Key &k) const { return _m1[k]+_m2[k]; } }; @@ -845,13 +854,14 @@ const M1 &_m1; const M2 &_m2; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M1::Key Key; + ///\e + typedef typename M1::Value Value; /// Constructor SubMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} - /// \e + ///\e Value operator[](const Key &k) const { return _m1[k]-_m2[k]; } }; @@ -894,13 +904,14 @@ const M1 &_m1; const M2 &_m2; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M1::Key Key; + ///\e + typedef typename M1::Value Value; /// Constructor MulMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {} - /// \e + ///\e Value operator[](const Key &k) const { return _m1[k]*_m2[k]; } }; @@ -942,13 +953,14 @@ const M1 &_m1; const M2 &_m2; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M1::Key Key; + ///\e + typedef typename M1::Value Value; /// Constructor DivMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {} - /// \e + ///\e Value operator[](const Key &k) const { return _m1[k]/_m2[k]; } }; @@ -992,9 +1004,10 @@ const M &_m; C _v; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M::Key Key; + ///\e + typedef typename M::Value Value; /// Constructor @@ -1002,7 +1015,7 @@ /// \param m The undelying map. /// \param v The constant value. ShiftMap(const M &m, const C &v) : _m(m), _v(v) {} - /// \e + ///\e Value operator[](const Key &k) const { return _m[k]+_v; } }; @@ -1022,9 +1035,10 @@ M &_m; C _v; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M::Key Key; + ///\e + typedef typename M::Value Value; /// Constructor @@ -1032,9 +1046,9 @@ /// \param m The undelying map. /// \param v The constant value. ShiftWriteMap(M &m, const C &v) : _m(m), _v(v) {} - /// \e + ///\e Value operator[](const Key &k) const { return _m[k]+_v; } - /// \e + ///\e void set(const Key &k, const Value &v) { _m.set(k, v-_v); } }; @@ -1093,9 +1107,10 @@ const M &_m; C _v; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M::Key Key; + ///\e + typedef typename M::Value Value; /// Constructor @@ -1103,7 +1118,7 @@ /// \param m The undelying map. /// \param v The constant value. ScaleMap(const M &m, const C &v) : _m(m), _v(v) {} - /// \e + ///\e Value operator[](const Key &k) const { return _v*_m[k]; } }; @@ -1124,9 +1139,10 @@ M &_m; C _v; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M::Key Key; + ///\e + typedef typename M::Value Value; /// Constructor @@ -1134,9 +1150,9 @@ /// \param m The undelying map. /// \param v The constant value. ScaleWriteMap(M &m, const C &v) : _m(m), _v(v) {} - /// \e + ///\e Value operator[](const Key &k) const { return _v*_m[k]; } - /// \e + ///\e void set(const Key &k, const Value &v) { _m.set(k, v/_v); } }; @@ -1193,13 +1209,14 @@ class NegMap : public MapBase { const M& _m; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M::Key Key; + ///\e + typedef typename M::Value Value; /// Constructor NegMap(const M &m) : _m(m) {} - /// \e + ///\e Value operator[](const Key &k) const { return -_m[k]; } }; @@ -1228,15 +1245,16 @@ class NegWriteMap : public MapBase { M &_m; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M::Key Key; + ///\e + typedef typename M::Value Value; /// Constructor NegWriteMap(M &m) : _m(m) {} - /// \e + ///\e Value operator[](const Key &k) const { return -_m[k]; } - /// \e + ///\e void set(const Key &k, const Value &v) { _m.set(k, -v); } }; @@ -1282,13 +1300,14 @@ class AbsMap : public MapBase { const M &_m; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M::Key Key; + ///\e + typedef typename M::Value Value; /// Constructor AbsMap(const M &m) : _m(m) {} - /// \e + ///\e Value operator[](const Key &k) const { Value tmp = _m[k]; return tmp >= 0 ? tmp : -tmp; @@ -1337,9 +1356,10 @@ template class TrueMap : public MapBase { public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef K Key; + ///\e + typedef bool Value; /// Gives back \c true. Value operator[](const Key&) const { return true; } @@ -1374,9 +1394,10 @@ template class FalseMap : public MapBase { public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef K Key; + ///\e + typedef bool Value; /// Gives back \c false. Value operator[](const Key&) const { return false; } @@ -1419,13 +1440,14 @@ const M1 &_m1; const M2 &_m2; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M1::Key Key; + ///\e + typedef bool Value; /// Constructor AndMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} - /// \e + ///\e Value operator[](const Key &k) const { return _m1[k]&&_m2[k]; } }; @@ -1467,13 +1489,14 @@ const M1 &_m1; const M2 &_m2; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M1::Key Key; + ///\e + typedef bool Value; /// Constructor OrMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} - /// \e + ///\e Value operator[](const Key &k) const { return _m1[k]||_m2[k]; } }; @@ -1506,13 +1529,14 @@ class NotMap : public MapBase { const M &_m; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M::Key Key; + ///\e + typedef bool Value; /// Constructor NotMap(const M &m) : _m(m) {} - /// \e + ///\e Value operator[](const Key &k) const { return !_m[k]; } }; @@ -1532,15 +1556,16 @@ class NotWriteMap : public MapBase { M &_m; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M::Key Key; + ///\e + typedef bool Value; /// Constructor NotWriteMap(M &m) : _m(m) {} - /// \e + ///\e Value operator[](const Key &k) const { return !_m[k]; } - /// \e + ///\e void set(const Key &k, bool v) { _m.set(k, !v); } }; @@ -1595,13 +1620,14 @@ const M1 &_m1; const M2 &_m2; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M1::Key Key; + ///\e + typedef bool Value; /// Constructor EqualMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} - /// \e + ///\e Value operator[](const Key &k) const { return _m1[k]==_m2[k]; } }; @@ -1643,13 +1669,14 @@ const M1 &_m1; const M2 &_m2; public: - typedef MapBase Parent; - typedef typename Parent::Key Key; - typedef typename Parent::Value Value; + ///\e + typedef typename M1::Key Key; + ///\e + typedef bool Value; /// Constructor LessMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} - /// \e + ///\e Value operator[](const Key &k) const { return _m1[k]<_m2[k]; } }; @@ -1705,24 +1732,27 @@ /// The simplest way of using this map is through the loggerBoolMap() /// function. /// - /// \tparam It The type of the iterator. - /// \tparam Ke The key type of the map. The default value set + /// \tparam IT The type of the iterator. + /// \tparam KEY The key type of the map. The default value set /// according to the iterator type should work in most cases. /// /// \note The container of the iterator must contain enough space /// for the elements or the iterator should be an inserter iterator. #ifdef DOXYGEN - template + template #else - template ::Value> + template ::Value> #endif - class LoggerBoolMap { + class LoggerBoolMap : public MapBase { public: - typedef It Iterator; - - typedef Ke Key; + + ///\e + typedef KEY Key; + ///\e typedef bool Value; + ///\e + typedef IT Iterator; /// Constructor LoggerBoolMap(Iterator it) @@ -1785,23 +1815,35 @@ /// \addtogroup graph_maps /// @{ - /// Provides an immutable and unique id for each item in the graph. - - /// The IdMap class provides a unique and immutable id for each item of the - /// same type (e.g. node) in the graph. This id is
  • \b unique: - /// different items (nodes) get different ids
  • \b immutable: the id of an - /// item (node) does not change (even if you delete other nodes).
- /// Through this map you get access (i.e. can read) the inner id values of - /// the items stored in the graph. This map can be inverted with its member + /// \brief Provides an immutable and unique id for each item in a graph. + /// + /// IdMap provides a unique and immutable id for each item of the + /// same type (\c Node, \c Arc or \c Edge) in a graph. This id is + /// - \b unique: different items get different ids, + /// - \b immutable: the id of an item does not change (even if you + /// delete other nodes). + /// + /// Using this map you get access (i.e. can read) the inner id values of + /// the items stored in the graph, which is returned by the \c id() + /// function of the graph. This map can be inverted with its member /// class \c InverseMap or with the \c operator() member. /// - template - class IdMap { + /// \tparam GR The graph type. + /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or + /// \c GR::Edge). + /// + /// \see DescriptorMap + template + class IdMap : public MapBase { public: - typedef _Graph Graph; + /// The graph type of IdMap. + typedef GR Graph; + /// The key type of IdMap (\c Node, \c Arc or \c Edge). + typedef K Item; + /// The key type of IdMap (\c Node, \c Arc or \c Edge). + typedef K Key; + /// The value type of IdMap. typedef int Value; - typedef _Item Item; - typedef _Item Key; /// \brief Constructor. /// @@ -1813,9 +1855,9 @@ /// Gives back the immutable and unique \e id of the item. int operator[](const Item& item) const { return _graph->id(item);} - /// \brief Gives back the item by its id. + /// \brief Gives back the \e item by its id. /// - /// Gives back the item by its id. + /// Gives back the \e item by its id. Item operator()(int id) { return _graph->fromId(id, Item()); } private: @@ -1823,9 +1865,9 @@ public: - /// \brief The class represents the inverse of its owner (IdMap). + /// \brief This class represents the inverse of its owner (IdMap). /// - /// The class represents the inverse of its owner (IdMap). + /// This class represents the inverse of its owner (IdMap). /// \see inverse() class InverseMap { public: @@ -1843,7 +1885,6 @@ /// \brief Gives back the given item from its id. /// /// Gives back the given item from its id. - /// Item operator[](int id) const { return _graph->fromId(id, Item());} private: @@ -1854,56 +1895,57 @@ /// /// Gives back the inverse of the IdMap. InverseMap inverse() const { return InverseMap(*_graph);} - }; - /// \brief General invertable graph-map type. - - /// This type provides simple invertable graph-maps. - /// The InvertableMap wraps an arbitrary ReadWriteMap + /// \brief General invertable graph map type. + + /// This class provides simple invertable graph maps. + /// It wraps an arbitrary \ref concepts::ReadWriteMap "ReadWriteMap" /// and if a key is set to a new value then store it /// in the inverse map. /// /// The values of the map can be accessed /// with stl compatible forward iterator. /// - /// \tparam _Graph The graph type. - /// \tparam _Item The item type of the graph. - /// \tparam _Value The value type of the map. + /// \tparam GR The graph type. + /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or + /// \c GR::Edge). + /// \tparam V The value type of the map. /// /// \see IterableValueMap - template + template class InvertableMap - : protected ItemSetTraits<_Graph, _Item>::template Map<_Value>::Type { + : protected ItemSetTraits::template Map::Type { private: - typedef typename ItemSetTraits<_Graph, _Item>:: - template Map<_Value>::Type Map; - typedef _Graph Graph; - - typedef std::map<_Value, _Item> Container; + typedef typename ItemSetTraits:: + template Map::Type Map; + + typedef std::map Container; Container _inv_map; public: - /// The key type of InvertableMap (Node, Arc, Edge). - typedef typename Map::Key Key; - /// The value type of the InvertableMap. - typedef typename Map::Value Value; + /// The graph type of InvertableMap. + typedef GR Graph; + /// The key type of InvertableMap (\c Node, \c Arc or \c Edge). + typedef K Item; + /// The key type of InvertableMap (\c Node, \c Arc or \c Edge). + typedef K Key; + /// The value type of InvertableMap. + typedef V Value; /// \brief Constructor. /// - /// Construct a new InvertableMap for the graph. - /// + /// Construct a new InvertableMap for the given graph. explicit InvertableMap(const Graph& graph) : Map(graph) {} /// \brief Forward iterator for values. /// /// This iterator is an stl compatible forward /// iterator on the values of the map. The values can - /// be accessed in the [beginValue, endValue) range. - /// + /// be accessed in the [beginValue, endValue) range. class ValueIterator : public std::iterator { friend class InvertableMap; @@ -1935,7 +1977,7 @@ /// /// Returns an stl compatible iterator to the /// first value of the map. The values of the - /// map can be accessed in the [beginValue, endValue) + /// map can be accessed in the [beginValue, endValue) /// range. ValueIterator beginValue() const { return ValueIterator(_inv_map.begin()); @@ -1945,15 +1987,15 @@ /// /// Returns an stl compatible iterator after the /// last value of the map. The values of the - /// map can be accessed in the [beginValue, endValue) + /// map can be accessed in the [beginValue, endValue) /// range. ValueIterator endValue() const { return ValueIterator(_inv_map.end()); } - /// \brief The setter function of the map. + /// \brief Sets the value associated with the given key. /// - /// Sets the mapped value. + /// Sets the value associated with the given key. void set(const Key& key, const Value& val) { Value oldval = Map::operator[](key); typename Container::iterator it = _inv_map.find(oldval); @@ -1964,9 +2006,9 @@ Map::set(key, val); } - /// \brief The getter function of the map. + /// \brief Returns the value associated with the given key. /// - /// It gives back the value associated with the key. + /// Returns the value associated with the given key. typename MapTraits::ConstReturnValue operator[](const Key& key) const { return Map::operator[](key); @@ -1982,9 +2024,9 @@ protected: - /// \brief Erase the key from the map. + /// \brief Erase the key from the map and the inverse map. /// - /// Erase the key to the map. It is called by the + /// Erase the key from the map and the inverse map. It is called by the /// \c AlterationNotifier. virtual void erase(const Key& key) { Value val = Map::operator[](key); @@ -1995,9 +2037,9 @@ Map::erase(key); } - /// \brief Erase more keys from the map. + /// \brief Erase more keys from the map and the inverse map. /// - /// Erase more keys from the map. It is called by the + /// Erase more keys from the map and the inverse map. It is called by the /// \c AlterationNotifier. virtual void erase(const std::vector& keys) { for (int i = 0; i < int(keys.size()); ++i) { @@ -2010,9 +2052,9 @@ Map::erase(keys); } - /// \brief Clear the keys from the map and inverse map. + /// \brief Clear the keys from the map and the inverse map. /// - /// Clear the keys from the map and inverse map. It is called by the + /// Clear the keys from the map and the inverse map. It is called by the /// \c AlterationNotifier. virtual void clear() { _inv_map.clear(); @@ -2024,10 +2066,10 @@ /// \brief The inverse map type. /// /// The inverse of this map. The subscript operator of the map - /// gives back always the item what was last assigned to the value. + /// gives back the item that was last assigned to the value. class InverseMap { public: - /// \brief Constructor of the InverseMap. + /// \brief Constructor /// /// Constructor of the InverseMap. explicit InverseMap(const InvertableMap& inverted) @@ -2040,8 +2082,8 @@ /// \brief Subscript operator. /// - /// Subscript operator. It gives back always the item - /// what was last assigned to the value. + /// Subscript operator. It gives back the item + /// that was last assigned to the given value. Value operator[](const Key& key) const { return _inverted(key); } @@ -2050,9 +2092,9 @@ const InvertableMap& _inverted; }; - /// \brief It gives back the just readable inverse map. + /// \brief It gives back the read-only inverse map. /// - /// It gives back the just readable inverse map. + /// It gives back the read-only inverse map. InverseMap inverse() const { return InverseMap(*this); } @@ -2060,40 +2102,48 @@ }; /// \brief Provides a mutable, continuous and unique descriptor for each - /// item in the graph. + /// item in a graph. /// - /// The DescriptorMap class provides a unique and continuous (but mutable) - /// descriptor (id) for each item of the same type (e.g. node) in the - /// graph. This id is
  • \b unique: different items (nodes) get - /// different ids
  • \b continuous: the range of the ids is the set of - /// integers between 0 and \c n-1, where \c n is the number of the items of - /// this type (e.g. nodes) (so the id of a node can change if you delete an - /// other node, i.e. this id is mutable).
This map can be inverted - /// with its member class \c InverseMap, or with the \c operator() member. + /// DescriptorMap provides a unique and continuous (but mutable) + /// descriptor (id) for each item of the same type (\c Node, \c Arc or + /// \c Edge) in a graph. This id is + /// - \b unique: different items get different ids, + /// - \b continuous: the range of the ids is the set of integers + /// between 0 and \c n-1, where \c n is the number of the items of + /// this type (\c Node, \c Arc or \c Edge). So the id of an item can + /// change if you delete an other item of the same type, i.e. this + /// id is mutable. /// - /// \tparam _Graph The graph class the \c DescriptorMap belongs to. - /// \tparam _Item The Item is the Key of the Map. It may be Node, Arc or - /// Edge. - template + /// Thus this id is not (necessarily) the same as what can get using + /// the \c id() function of the graph or \ref IdMap. + /// This map can be inverted with its member class \c InverseMap, + /// or with the \c operator() member. + /// + /// \tparam GR The graph type. + /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or + /// \c GR::Edge). + /// + /// \see IdMap + template class DescriptorMap - : protected ItemSetTraits<_Graph, _Item>::template Map::Type { - - typedef _Item Item; - typedef typename ItemSetTraits<_Graph, _Item>::template Map::Type Map; + : protected ItemSetTraits::template Map::Type { + + typedef typename ItemSetTraits::template Map::Type Map; public: - /// The graph class of DescriptorMap. - typedef _Graph Graph; - - /// The key type of DescriptorMap (Node, Arc, Edge). - typedef typename Map::Key Key; + /// The graph type of DescriptorMap. + typedef GR Graph; + /// The key type of DescriptorMap (\c Node, \c Arc or \c Edge). + typedef K Item; + /// The key type of DescriptorMap (\c Node, \c Arc or \c Edge). + typedef K Key; /// The value type of DescriptorMap. - typedef typename Map::Value Value; + typedef int Value; /// \brief Constructor. /// /// Constructor for descriptor map. - explicit DescriptorMap(const Graph& _graph) : Map(_graph) { + explicit DescriptorMap(const Graph& gr) : Map(gr) { Item it; const typename Map::Notifier* nf = Map::notifier(); for (nf->first(it); it != INVALID; nf->next(it)) { @@ -2104,7 +2154,7 @@ protected: - /// \brief Add a new key to the map. + /// \brief Adds a new key to the map. /// /// Add a new key to the map. It is called by the /// \c AlterationNotifier. @@ -2214,12 +2264,13 @@ Container _inv_map; public: + /// \brief The inverse map type of DescriptorMap. /// /// The inverse map type of DescriptorMap. class InverseMap { public: - /// \brief Constructor of the InverseMap. + /// \brief Constructor /// /// Constructor of the InverseMap. explicit InverseMap(const DescriptorMap& inverted) @@ -2234,7 +2285,7 @@ /// \brief Subscript operator. /// /// Subscript operator. It gives back the item - /// that the descriptor belongs to currently. + /// that the descriptor currently belongs to. Value operator[](const Key& key) const { return _inverted(key); } @@ -2258,230 +2309,198 @@ } }; - /// \brief Returns the source of the given arc. + /// \brief Map of the source nodes of arcs in a digraph. /// - /// The SourceMap gives back the source Node of the given arc. + /// SourceMap provides access for the source node of each arc in a digraph, + /// which is returned by the \c source() function of the digraph. + /// \tparam GR The digraph type. /// \see TargetMap - template + template class SourceMap { public: - typedef typename Digraph::Node Value; - typedef typename Digraph::Arc Key; + ///\e + typedef typename GR::Arc Key; + ///\e + typedef typename GR::Node Value; /// \brief Constructor /// - /// Constructor + /// Constructor. /// \param digraph The digraph that the map belongs to. - explicit SourceMap(const Digraph& digraph) : _digraph(digraph) {} - - /// \brief The subscript operator. + explicit SourceMap(const GR& digraph) : _graph(digraph) {} + + /// \brief Returns the source node of the given arc. /// - /// The subscript operator. - /// \param arc The arc - /// \return The source of the arc + /// Returns the source node of the given arc. Value operator[](const Key& arc) const { - return _digraph.source(arc); + return _graph.source(arc); } private: - const Digraph& _digraph; + const GR& _graph; }; /// \brief Returns a \c SourceMap class. /// /// This function just returns an \c SourceMap class. /// \relates SourceMap - template - inline SourceMap sourceMap(const Digraph& digraph) { - return SourceMap(digraph); + template + inline SourceMap sourceMap(const GR& graph) { + return SourceMap(graph); } - /// \brief Returns the target of the given arc. + /// \brief Map of the target nodes of arcs in a digraph. /// - /// The TargetMap gives back the target Node of the given arc. + /// TargetMap provides access for the target node of each arc in a digraph, + /// which is returned by the \c target() function of the digraph. + /// \tparam GR The digraph type. /// \see SourceMap - template + template class TargetMap { public: - typedef typename Digraph::Node Value; - typedef typename Digraph::Arc Key; + ///\e + typedef typename GR::Arc Key; + ///\e + typedef typename GR::Node Value; /// \brief Constructor /// - /// Constructor + /// Constructor. /// \param digraph The digraph that the map belongs to. - explicit TargetMap(const Digraph& digraph) : _digraph(digraph) {} - - /// \brief The subscript operator. + explicit TargetMap(const GR& digraph) : _graph(digraph) {} + + /// \brief Returns the target node of the given arc. /// - /// The subscript operator. - /// \param e The arc - /// \return The target of the arc + /// Returns the target node of the given arc. Value operator[](const Key& e) const { - return _digraph.target(e); + return _graph.target(e); } private: - const Digraph& _digraph; + const GR& _graph; }; /// \brief Returns a \c TargetMap class. /// /// This function just returns a \c TargetMap class. /// \relates TargetMap - template - inline TargetMap targetMap(const Digraph& digraph) { - return TargetMap(digraph); + template + inline TargetMap targetMap(const GR& graph) { + return TargetMap(graph); } - /// \brief Returns the "forward" directed arc view of an edge. + /// \brief Map of the "forward" directed arc view of edges in a graph. /// - /// Returns the "forward" directed arc view of an edge. + /// ForwardMap provides access for the "forward" directed arc view of + /// each edge in a graph, which is returned by the \c direct() function + /// of the graph with \c true parameter. + /// \tparam GR The graph type. /// \see BackwardMap - template + template class ForwardMap { public: - typedef typename Graph::Arc Value; - typedef typename Graph::Edge Key; + typedef typename GR::Arc Value; + typedef typename GR::Edge Key; /// \brief Constructor /// - /// Constructor + /// Constructor. /// \param graph The graph that the map belongs to. - explicit ForwardMap(const Graph& graph) : _graph(graph) {} - - /// \brief The subscript operator. + explicit ForwardMap(const GR& graph) : _graph(graph) {} + + /// \brief Returns the "forward" directed arc view of the given edge. /// - /// The subscript operator. - /// \param key An edge - /// \return The "forward" directed arc view of edge + /// Returns the "forward" directed arc view of the given edge. Value operator[](const Key& key) const { return _graph.direct(key, true); } private: - const Graph& _graph; + const GR& _graph; }; /// \brief Returns a \c ForwardMap class. /// /// This function just returns an \c ForwardMap class. /// \relates ForwardMap - template - inline ForwardMap forwardMap(const Graph& graph) { - return ForwardMap(graph); + template + inline ForwardMap forwardMap(const GR& graph) { + return ForwardMap(graph); } - /// \brief Returns the "backward" directed arc view of an edge. + /// \brief Map of the "backward" directed arc view of edges in a graph. /// - /// Returns the "backward" directed arc view of an edge. + /// BackwardMap provides access for the "backward" directed arc view of + /// each edge in a graph, which is returned by the \c direct() function + /// of the graph with \c false parameter. + /// \tparam GR The graph type. /// \see ForwardMap - template + template class BackwardMap { public: - typedef typename Graph::Arc Value; - typedef typename Graph::Edge Key; + typedef typename GR::Arc Value; + typedef typename GR::Edge Key; /// \brief Constructor /// - /// Constructor + /// Constructor. /// \param graph The graph that the map belongs to. - explicit BackwardMap(const Graph& graph) : _graph(graph) {} - - /// \brief The subscript operator. + explicit BackwardMap(const GR& graph) : _graph(graph) {} + + /// \brief Returns the "backward" directed arc view of the given edge. /// - /// The subscript operator. - /// \param key An edge - /// \return The "backward" directed arc view of edge + /// Returns the "backward" directed arc view of the given edge. Value operator[](const Key& key) const { return _graph.direct(key, false); } private: - const Graph& _graph; + const GR& _graph; }; /// \brief Returns a \c BackwardMap class /// This function just returns a \c BackwardMap class. /// \relates BackwardMap - template - inline BackwardMap backwardMap(const Graph& graph) { - return BackwardMap(graph); + template + inline BackwardMap backwardMap(const GR& graph) { + return BackwardMap(graph); } - /// \brief Potential difference map - /// - /// If there is an potential map on the nodes then we - /// can get an arc map as we get the substraction of the - /// values of the target and source. - template - class PotentialDifferenceMap { - public: - typedef typename Digraph::Arc Key; - typedef typename NodeMap::Value Value; - - /// \brief Constructor - /// - /// Contructor of the map - explicit PotentialDifferenceMap(const Digraph& digraph, - const NodeMap& potential) - : _digraph(digraph), _potential(potential) {} - - /// \brief Const subscription operator - /// - /// Const subscription operator - Value operator[](const Key& arc) const { - return _potential[_digraph.target(arc)] - - _potential[_digraph.source(arc)]; - } - - private: - const Digraph& _digraph; - const NodeMap& _potential; - }; - - /// \brief Returns a PotentialDifferenceMap. - /// - /// This function just returns a PotentialDifferenceMap. - /// \relates PotentialDifferenceMap - template - PotentialDifferenceMap - potentialDifferenceMap(const Digraph& digraph, const NodeMap& potential) { - return PotentialDifferenceMap(digraph, potential); - } - - /// \brief Map of the node in-degrees. + /// \brief Map of the in-degrees of nodes in a digraph. /// /// This map returns the in-degree of a node. Once it is constructed, - /// the degrees are stored in a standard NodeMap, so each query is done + /// the degrees are stored in a standard \c NodeMap, so each query is done /// in constant time. On the other hand, the values are updated automatically /// whenever the digraph changes. /// - /// \warning Besides addNode() and addArc(), a digraph structure may provide - /// alternative ways to modify the digraph. The correct behavior of InDegMap - /// is not guarantied if these additional features are used. For example - /// the functions \ref ListDigraph::changeSource() "changeSource()", + /// \warning Besides \c addNode() and \c addArc(), a digraph structure + /// may provide alternative ways to modify the digraph. + /// The correct behavior of InDegMap is not guarantied if these additional + /// features are used. For example the functions + /// \ref ListDigraph::changeSource() "changeSource()", /// \ref ListDigraph::changeTarget() "changeTarget()" and /// \ref ListDigraph::reverseArc() "reverseArc()" /// of \ref ListDigraph will \e not update the degree values correctly. /// /// \sa OutDegMap - - template + template class InDegMap - : protected ItemSetTraits<_Digraph, typename _Digraph::Arc> + : protected ItemSetTraits ::ItemNotifier::ObserverBase { public: - - typedef _Digraph Digraph; + + /// The digraph type + typedef GR Digraph; + /// The key type + typedef typename Digraph::Node Key; + /// The value type typedef int Value; - typedef typename Digraph::Node Key; typedef typename ItemSetTraits ::ItemNotifier::ObserverBase Parent; @@ -2523,9 +2542,9 @@ /// \brief Constructor. /// - /// Constructor for creating in-degree map. - explicit InDegMap(const Digraph& digraph) - : _digraph(digraph), _deg(digraph) { + /// Constructor for creating an in-degree map. + explicit InDegMap(const Digraph& graph) + : _digraph(graph), _deg(graph) { Parent::attach(_digraph.notifier(typename Digraph::Arc())); for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) { @@ -2533,6 +2552,8 @@ } } + /// \brief Gives back the in-degree of a Node. + /// /// Gives back the in-degree of a Node. int operator[](const Key& key) const { return _deg[key]; @@ -2579,33 +2600,36 @@ AutoNodeMap _deg; }; - /// \brief Map of the node out-degrees. + /// \brief Map of the out-degrees of nodes in a digraph. /// /// This map returns the out-degree of a node. Once it is constructed, - /// the degrees are stored in a standard NodeMap, so each query is done + /// the degrees are stored in a standard \c NodeMap, so each query is done /// in constant time. On the other hand, the values are updated automatically /// whenever the digraph changes. /// - /// \warning Besides addNode() and addArc(), a digraph structure may provide - /// alternative ways to modify the digraph. The correct behavior of OutDegMap - /// is not guarantied if these additional features are used. For example - /// the functions \ref ListDigraph::changeSource() "changeSource()", + /// \warning Besides \c addNode() and \c addArc(), a digraph structure + /// may provide alternative ways to modify the digraph. + /// The correct behavior of OutDegMap is not guarantied if these additional + /// features are used. For example the functions + /// \ref ListDigraph::changeSource() "changeSource()", /// \ref ListDigraph::changeTarget() "changeTarget()" and /// \ref ListDigraph::reverseArc() "reverseArc()" /// of \ref ListDigraph will \e not update the degree values correctly. /// /// \sa InDegMap - - template + template class OutDegMap - : protected ItemSetTraits<_Digraph, typename _Digraph::Arc> + : protected ItemSetTraits ::ItemNotifier::ObserverBase { public: - typedef _Digraph Digraph; + /// The digraph type + typedef GR Digraph; + /// The key type + typedef typename Digraph::Node Key; + /// The value type typedef int Value; - typedef typename Digraph::Node Key; typedef typename ItemSetTraits ::ItemNotifier::ObserverBase Parent; @@ -2645,9 +2669,9 @@ /// \brief Constructor. /// - /// Constructor for creating out-degree map. - explicit OutDegMap(const Digraph& digraph) - : _digraph(digraph), _deg(digraph) { + /// Constructor for creating an out-degree map. + explicit OutDegMap(const Digraph& graph) + : _digraph(graph), _deg(graph) { Parent::attach(_digraph.notifier(typename Digraph::Arc())); for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) { @@ -2655,6 +2679,8 @@ } } + /// \brief Gives back the out-degree of a Node. + /// /// Gives back the out-degree of a Node. int operator[](const Key& key) const { return _deg[key]; @@ -2701,6 +2727,56 @@ AutoNodeMap _deg; }; + /// \brief Potential difference map + /// + /// PotentialMap returns the difference between the potentials of the + /// source and target nodes of each arc in a digraph, i.e. it returns + /// \code + /// potential[gr.target(arc)] - potential[gr.source(arc)]. + /// \endcode + /// \tparam GR The digraph type. + /// \tparam POT A node map storing the potentials. + template + class PotentialDifferenceMap { + public: + /// Key type + typedef typename GR::Arc Key; + /// Value type + typedef typename POT::Value Value; + + /// \brief Constructor + /// + /// Contructor of the map. + explicit PotentialDifferenceMap(const GR& gr, + const POT& potential) + : _digraph(gr), _potential(potential) {} + + /// \brief Returns the potential difference for the given arc. + /// + /// Returns the potential difference for the given arc, i.e. + /// \code + /// potential[gr.target(arc)] - potential[gr.source(arc)]. + /// \endcode + Value operator[](const Key& arc) const { + return _potential[_digraph.target(arc)] - + _potential[_digraph.source(arc)]; + } + + private: + const GR& _digraph; + const POT& _potential; + }; + + /// \brief Returns a PotentialDifferenceMap. + /// + /// This function just returns a PotentialDifferenceMap. + /// \relates PotentialDifferenceMap + template + PotentialDifferenceMap + potentialDifferenceMap(const GR& gr, const POT& potential) { + return PotentialDifferenceMap(gr, potential); + } + /// @} } diff --git a/lemon/max_matching.h b/lemon/max_matching.h --- a/lemon/max_matching.h +++ b/lemon/max_matching.h @@ -55,12 +55,12 @@ /// tight. This decomposition can be attained by calling \c /// decomposition() after running the algorithm. /// - /// \param _Graph The graph type the algorithm runs on. - template + /// \param GR The graph type the algorithm runs on. + template class MaxMatching { public: - typedef _Graph Graph; + typedef GR Graph; typedef typename Graph::template NodeMap MatchingMap; @@ -463,7 +463,7 @@ /// Initialize the matching from a \c bool valued \c Edge map. This /// map must have the property that there are no two incident edges /// with true value, ie. it contains a matching. - /// \return %True if the map contains a matching. + /// \return \c true if the map contains a matching. template bool matchingInit(const MatchingMap& matching) { createStructures(); @@ -613,7 +613,7 @@ /// This class provides an efficient implementation of Edmond's /// maximum weighted matching algorithm. The implementation is based /// on extensive use of priority queues and provides - /// \f$O(nm\log(n))\f$ time complexity. + /// \f$O(nm\log n)\f$ time complexity. /// /// The maximum weighted matching problem is to find undirected /// edges in the graph with maximum overall weight and no two of @@ -647,13 +647,16 @@ /// "BlossomIt" nested class, which is able to iterate on the nodes /// of a blossom. If the value type is integral then the dual /// solution is multiplied by \ref MaxWeightedMatching::dualScale "4". - template > + template > class MaxWeightedMatching { public: - typedef _Graph Graph; - typedef _WeightMap WeightMap; + ///\e + typedef GR Graph; + ///\e + typedef WM WeightMap; + ///\e typedef typename WeightMap::Value Value; /// \brief Scaling factor for dual solution @@ -1957,7 +1960,7 @@ /// This class provides an efficient implementation of Edmond's /// maximum weighted perfect matching algorithm. The implementation /// is based on extensive use of priority queues and provides - /// \f$O(nm\log(n))\f$ time complexity. + /// \f$O(nm\log n)\f$ time complexity. /// /// The maximum weighted matching problem is to find undirected /// edges in the graph with maximum overall weight and no two of @@ -1990,13 +1993,13 @@ /// "BlossomIt" nested class which is able to iterate on the nodes /// of a blossom. If the value type is integral then the dual /// solution is multiplied by \ref MaxWeightedMatching::dualScale "4". - template > + template > class MaxWeightedPerfectMatching { public: - typedef _Graph Graph; - typedef _WeightMap WeightMap; + typedef GR Graph; + typedef WM WeightMap; typedef typename WeightMap::Value Value; /// \brief Scaling factor for dual solution diff --git a/lemon/min_cost_arborescence.h b/lemon/min_cost_arborescence.h --- a/lemon/min_cost_arborescence.h +++ b/lemon/min_cost_arborescence.h @@ -35,19 +35,19 @@ /// \brief Default traits class for MinCostArborescence class. /// /// Default traits class for MinCostArborescence class. - /// \param _Digraph Digraph type. - /// \param _CostMap Type of cost map. - template + /// \param GR Digraph type. + /// \param CM Type of cost map. + template struct MinCostArborescenceDefaultTraits{ /// \brief The digraph type the algorithm runs on. - typedef _Digraph Digraph; + typedef GR Digraph; /// \brief The type of the map that stores the arc costs. /// /// The type of the map that stores the arc costs. /// It must meet the \ref concepts::ReadMap "ReadMap" concept. - typedef _CostMap CostMap; + typedef CM CostMap; /// \brief The value type of the costs. /// @@ -63,25 +63,25 @@ /// arc. After it will set all arborescence arcs once. typedef typename Digraph::template ArcMap ArborescenceMap; - /// \brief Instantiates a ArborescenceMap. + /// \brief Instantiates a \c ArborescenceMap. /// - /// This function instantiates a \ref ArborescenceMap. + /// This function instantiates a \c ArborescenceMap. /// \param digraph is the graph, to which we would like to - /// calculate the ArborescenceMap. + /// calculate the \c ArborescenceMap. static ArborescenceMap *createArborescenceMap(const Digraph &digraph){ return new ArborescenceMap(digraph); } - /// \brief The type of the PredMap + /// \brief The type of the \c PredMap /// - /// The type of the PredMap. It is a node map with an arc value type. + /// The type of the \c PredMap. It is a node map with an arc value type. typedef typename Digraph::template NodeMap PredMap; - /// \brief Instantiates a PredMap. + /// \brief Instantiates a \c PredMap. /// - /// This function instantiates a \ref PredMap. - /// \param _digraph is the digraph, to which we would like to define the - /// PredMap. + /// This function instantiates a \c PredMap. + /// \param digraph The digraph to which we would like to define the + /// \c PredMap. static PredMap *createPredMap(const Digraph &digraph){ return new PredMap(digraph); } @@ -98,39 +98,37 @@ /// more sources should be given for the algorithm and it will calculate /// the minimum cost subgraph which are union of arborescences with the /// given sources and spans all the nodes which are reachable from the - /// sources. The time complexity of the algorithm is \f$ O(n^2+e) \f$. + /// sources. The time complexity of the algorithm is O(n2+e). /// /// The algorithm provides also an optimal dual solution, therefore /// the optimality of the solution can be checked. /// - /// \param _Digraph The digraph type the algorithm runs on. The default value + /// \param GR The digraph type the algorithm runs on. The default value /// is \ref ListDigraph. - /// \param _CostMap This read-only ArcMap determines the costs of the + /// \param CM This read-only ArcMap determines the costs of the /// arcs. It is read once for each arc, so the map may involve in /// relatively time consuming process to compute the arc cost if /// it is necessary. The default map type is \ref /// concepts::Digraph::ArcMap "Digraph::ArcMap". - /// \param _Traits Traits class to set various data types used + /// \param TR Traits class to set various data types used /// by the algorithm. The default traits class is /// \ref MinCostArborescenceDefaultTraits - /// "MinCostArborescenceDefaultTraits<_Digraph, _CostMap>". See \ref + /// "MinCostArborescenceDefaultTraits". See \ref /// MinCostArborescenceDefaultTraits for the documentation of a /// MinCostArborescence traits class. - /// - /// \author Balazs Dezso #ifndef DOXYGEN - template , - typename _Traits = - MinCostArborescenceDefaultTraits<_Digraph, _CostMap> > + template , + typename TR = + MinCostArborescenceDefaultTraits > #else - template + template #endif class MinCostArborescence { public: /// The traits. - typedef _Traits Traits; + typedef TR Traits; /// The type of the underlying digraph. typedef typename Traits::Digraph Digraph; /// The type of the map that stores the arc costs. @@ -440,8 +438,8 @@ /// \brief Constructor. /// - /// \param _digraph The digraph the algorithm will run on. - /// \param _cost The cost map used by the algorithm. + /// \param digraph The digraph the algorithm will run on. + /// \param cost The cost map used by the algorithm. MinCostArborescence(const Digraph& digraph, const CostMap& cost) : _digraph(&digraph), _cost(&cost), _pred(0), local_pred(false), _arborescence(0), local_arborescence(false), @@ -456,7 +454,7 @@ /// \brief Sets the arborescence map. /// /// Sets the arborescence map. - /// \return \c (*this) + /// \return (*this) MinCostArborescence& arborescenceMap(ArborescenceMap& m) { if (local_arborescence) { delete _arborescence; @@ -469,7 +467,7 @@ /// \brief Sets the arborescence map. /// /// Sets the arborescence map. - /// \return \c (*this) + /// \return (*this) MinCostArborescence& predMap(PredMap& m) { if (local_pred) { delete _pred; diff --git a/lemon/path.h b/lemon/path.h --- a/lemon/path.h +++ b/lemon/path.h @@ -40,7 +40,7 @@ /// \brief A structure for representing directed paths in a digraph. /// /// A structure for representing directed path in a digraph. - /// \tparam _Digraph The digraph type in which the path is. + /// \tparam GR The digraph type in which the path is. /// /// In a sense, the path can be treated as a list of arcs. The /// lemon path type stores just this list. As a consequence, it @@ -52,11 +52,11 @@ /// insertion and erase is done in O(1) (amortized) time. The /// implementation uses two vectors for storing the front and back /// insertions. - template + template class Path { public: - typedef _Digraph Digraph; + typedef GR Digraph; typedef typename Digraph::Arc Arc; /// \brief Default constructor @@ -137,7 +137,7 @@ /// \brief The nth arc. /// - /// \pre n is in the [0..length() - 1] range + /// \pre \c n is in the [0..length() - 1] range. const Arc& nth(int n) const { return n < int(head.size()) ? *(head.rbegin() + n) : *(tail.begin() + (n - head.size())); @@ -145,7 +145,7 @@ /// \brief Initialize arc iterator to point to the nth arc /// - /// \pre n is in the [0..length() - 1] range + /// \pre \c n is in the [0..length() - 1] range. ArcIt nthIt(int n) const { return ArcIt(*this, n); } @@ -228,7 +228,7 @@ /// \brief A structure for representing directed paths in a digraph. /// /// A structure for representing directed path in a digraph. - /// \tparam _Digraph The digraph type in which the path is. + /// \tparam GR The digraph type in which the path is. /// /// In a sense, the path can be treated as a list of arcs. The /// lemon path type stores just this list. As a consequence it @@ -240,11 +240,11 @@ /// erasure is amortized O(1) time. This implementation is faster /// then the \c Path type because it use just one vector for the /// arcs. - template + template class SimplePath { public: - typedef _Digraph Digraph; + typedef GR Digraph; typedef typename Digraph::Arc Arc; /// \brief Default constructor @@ -329,7 +329,7 @@ /// \brief The nth arc. /// - /// \pre n is in the [0..length() - 1] range + /// \pre \c n is in the [0..length() - 1] range. const Arc& nth(int n) const { return data[n]; } @@ -392,7 +392,7 @@ /// \brief A structure for representing directed paths in a digraph. /// /// A structure for representing directed path in a digraph. - /// \tparam _Digraph The digraph type in which the path is. + /// \tparam GR The digraph type in which the path is. /// /// In a sense, the path can be treated as a list of arcs. The /// lemon path type stores just this list. As a consequence it @@ -404,11 +404,11 @@ /// of the arc in the path. The length can be computed in O(n) /// time. The front and back insertion and erasure is O(1) time /// and it can be splited and spliced in O(1) time. - template + template class ListPath { public: - typedef _Digraph Digraph; + typedef GR Digraph; typedef typename Digraph::Arc Arc; protected: @@ -507,7 +507,7 @@ /// \brief The nth arc. /// /// This function looks for the nth arc in O(n) time. - /// \pre n is in the [0..length() - 1] range + /// \pre \c n is in the [0..length() - 1] range. const Arc& nth(int n) const { Node *node = first; for (int i = 0; i < n; ++i) { @@ -732,7 +732,7 @@ /// \brief A structure for representing directed paths in a digraph. /// /// A structure for representing directed path in a digraph. - /// \tparam _Digraph The digraph type in which the path is. + /// \tparam GR The digraph type in which the path is. /// /// In a sense, the path can be treated as a list of arcs. The /// lemon path type stores just this list. As a consequence it @@ -746,11 +746,11 @@ /// Being the the most memory efficient path type in LEMON, /// it is intented to be /// used when you want to store a large number of paths. - template + template class StaticPath { public: - typedef _Digraph Digraph; + typedef GR Digraph; typedef typename Digraph::Arc Arc; /// \brief Default constructor @@ -833,7 +833,7 @@ /// \brief The nth arc. /// - /// \pre n is in the [0..length() - 1] range + /// \pre \c n is in the [0..length() - 1] range. const Arc& nth(int n) const { return arcs[n]; } diff --git a/lemon/preflow.h b/lemon/preflow.h --- a/lemon/preflow.h +++ b/lemon/preflow.h @@ -32,8 +32,8 @@ /// /// Default traits class of Preflow class. /// \tparam GR Digraph type. - /// \tparam CM Capacity map type. - template + /// \tparam CAP Capacity map type. + template struct PreflowDefaultTraits { /// \brief The type of the digraph the algorithm runs on. @@ -43,7 +43,7 @@ /// /// The type of the map that stores the arc capacities. /// It must meet the \ref concepts::ReadMap "ReadMap" concept. - typedef CM CapacityMap; + typedef CAP CapacityMap; /// \brief The type of the flow values. typedef typename CapacityMap::Value Value; @@ -94,8 +94,9 @@ /// \brief %Preflow algorithm class. /// /// This class provides an implementation of Goldberg-Tarjan's \e preflow - /// \e push-relabel algorithm producing a flow of maximum value in a - /// digraph. The preflow algorithms are the fastest known maximum + /// \e push-relabel algorithm producing a \ref max_flow + /// "flow of maximum value" in a digraph. + /// The preflow algorithms are the fastest known maximum /// flow algorithms. The current implementation use a mixture of the /// \e "highest label" and the \e "bound decrease" heuristics. /// The worst case time complexity of the algorithm is \f$O(n^2\sqrt{e})\f$. @@ -105,14 +106,14 @@ /// second phase constructs a feasible maximum flow on each arc. /// /// \tparam GR The type of the digraph the algorithm runs on. - /// \tparam CM The type of the capacity map. The default map + /// \tparam CAP The type of the capacity map. The default map /// type is \ref concepts::Digraph::ArcMap "GR::ArcMap". #ifdef DOXYGEN - template + template #else template , - typename TR = PreflowDefaultTraits > + typename CAP = typename GR::template ArcMap, + typename TR = PreflowDefaultTraits > #endif class Preflow { public: @@ -194,9 +195,9 @@ ///@{ - template + template struct SetFlowMapTraits : public Traits { - typedef _FlowMap FlowMap; + typedef T FlowMap; static FlowMap *createFlowMap(const Digraph&) { LEMON_ASSERT(false, "FlowMap is not initialized"); return 0; // ignore warnings @@ -208,16 +209,16 @@ /// /// \ref named-templ-param "Named parameter" for setting FlowMap /// type. - template + template struct SetFlowMap - : public Preflow > { + : public Preflow > { typedef Preflow > Create; + SetFlowMapTraits > Create; }; - template + template struct SetElevatorTraits : public Traits { - typedef _Elevator Elevator; + typedef T Elevator; static Elevator *createElevator(const Digraph&, int) { LEMON_ASSERT(false, "Elevator is not initialized"); return 0; // ignore warnings @@ -233,16 +234,16 @@ /// \ref elevator(Elevator&) "elevator()" function before calling /// \ref run() or \ref init(). /// \sa SetStandardElevator - template + template struct SetElevator - : public Preflow > { + : public Preflow > { typedef Preflow > Create; + SetElevatorTraits > Create; }; - template + template struct SetStandardElevatorTraits : public Traits { - typedef _Elevator Elevator; + typedef T Elevator; static Elevator *createElevator(const Digraph& digraph, int max_level) { return new Elevator(digraph, max_level); } @@ -260,12 +261,12 @@ /// algorithm with the \ref elevator(Elevator&) "elevator()" function /// before calling \ref run() or \ref init(). /// \sa SetElevator - template + template struct SetStandardElevator : public Preflow > { + SetStandardElevatorTraits > { typedef Preflow > Create; + SetStandardElevatorTraits > Create; }; /// @} @@ -946,7 +947,7 @@ /// could be slightly different if inexact computation is used. /// /// \note This function calls \ref minCut() for each node, so it runs in - /// \f$O(n)\f$ time. + /// O(n) time. /// /// \pre Either \ref run() or \ref init() must be called before /// using this function. diff --git a/lemon/radix_sort.h b/lemon/radix_sort.h --- a/lemon/radix_sort.h +++ b/lemon/radix_sort.h @@ -205,11 +205,11 @@ /// the identity function instead. /// /// This is a special quick sort algorithm where the pivot - /// values to split the items are choosen to be \f$ 2^k \f$ for each \c k. - /// Therefore, the time complexity of the - /// algorithm is \f$ O(\log(c)n) \f$ and it uses \f$ O(\log(c)) \f$, - /// additional space, where \c c is the maximal value and \c n is the - /// number of the items in the container. + /// values to split the items are choosen to be 2k + /// for each \c k. + /// Therefore, the time complexity of the algorithm is O(log(c)*n) and + /// it uses O(log(c)) additional space, where \c c is the maximal value + /// and \c n is the number of the items in the container. /// /// \param first The begin of the given range. /// \param last The end of the given range. @@ -430,10 +430,10 @@ /// bytes of the integer number. The algorithm sorts the items /// byte-by-byte. First, it counts how many times a byte value occurs /// in the container, then it copies the corresponding items to - /// another container in asceding order in \c O(n) time. + /// another container in asceding order in O(n) time. /// - /// The time complexity of the algorithm is \f$ O(\log(c)n) \f$ and - /// it uses \f$ O(n) \f$, additional space, where \c c is the + /// The time complexity of the algorithm is O(log(c)*n) and + /// it uses O(n) additional space, where \c c is the /// maximal value and \c n is the number of the items in the /// container. /// diff --git a/lemon/random.h b/lemon/random.h --- a/lemon/random.h +++ b/lemon/random.h @@ -603,7 +603,7 @@ /// By default, this function calls the \c seedFromFile() member /// function with the /dev/urandom file. If it does not success, /// it uses the \c seedFromTime(). - /// \return Currently always true. + /// \return Currently always \c true. bool seed() { #ifndef WIN32 if (seedFromFile("/dev/urandom", 0)) return true; @@ -624,7 +624,7 @@ /// entropy). /// \param file The source file /// \param offset The offset, from the file read. - /// \return True when the seeding successes. + /// \return \c true when the seeding successes. #ifndef WIN32 bool seedFromFile(const std::string& file = "/dev/urandom", int offset = 0) #else @@ -645,7 +645,7 @@ /// Seding from process id and time. This function uses the /// current process id and the current time for initialize the /// random sequence. - /// \return Currently always true. + /// \return Currently always \c true. bool seedFromTime() { #ifndef WIN32 timeval tv; diff --git a/lemon/smart_graph.h b/lemon/smart_graph.h --- a/lemon/smart_graph.h +++ b/lemon/smart_graph.h @@ -225,15 +225,15 @@ ///Add a new node to the digraph. - /// \return the new node. - /// + /// Add a new node to the digraph. + /// \return The new node. Node addNode() { return Parent::addNode(); } ///Add a new arc to the digraph. ///Add a new arc to the digraph with source node \c s ///and target node \c t. - ///\return the new arc. + ///\return The new arc. Arc addArc(const Node& s, const Node& t) { return Parent::addArc(s, t); } @@ -666,15 +666,15 @@ ///Add a new node to the graph. - /// \return the new node. - /// + /// Add a new node to the graph. + /// \return The new node. Node addNode() { return Parent::addNode(); } ///Add a new edge to the graph. ///Add a new edge to the graph with node \c s ///and \c t. - ///\return the new edge. + ///\return The new edge. Edge addEdge(const Node& s, const Node& t) { return Parent::addEdge(s, t); } diff --git a/lemon/suurballe.h b/lemon/suurballe.h --- a/lemon/suurballe.h +++ b/lemon/suurballe.h @@ -45,9 +45,9 @@ /// In fact, this implementation is the specialization of the /// \ref CapacityScaling "successive shortest path" algorithm. /// - /// \tparam Digraph The digraph type the algorithm runs on. + /// \tparam GR The digraph type the algorithm runs on. /// The default value is \c ListDigraph. - /// \tparam LengthMap The type of the length (cost) map. + /// \tparam LEN The type of the length (cost) map. /// The default value is Digraph::ArcMap. /// /// \warning Length values should be \e non-negative \e integers. @@ -55,21 +55,26 @@ /// \note For finding node-disjoint paths this algorithm can be used /// with \ref SplitNodes. #ifdef DOXYGEN - template + template #else - template < typename Digraph = ListDigraph, - typename LengthMap = typename Digraph::template ArcMap > + template < typename GR = ListDigraph, + typename LEN = typename GR::template ArcMap > #endif class Suurballe { - TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); + TEMPLATE_DIGRAPH_TYPEDEFS(GR); - typedef typename LengthMap::Value Length; typedef ConstMap ConstArcMap; - typedef typename Digraph::template NodeMap PredMap; + typedef typename GR::template NodeMap PredMap; public: + /// The type of the digraph the algorithm runs on. + typedef GR Digraph; + /// The type of the length map. + typedef LEN LengthMap; + /// The type of the lengths. + typedef typename LengthMap::Value Length; /// The type of the flow map. typedef typename Digraph::template ArcMap FlowMap; /// The type of the potential map. @@ -256,7 +261,7 @@ /// The found flow contains only 0 and 1 values. It is the union of /// the found arc-disjoint paths. /// - /// \return \c (*this) + /// \return (*this) Suurballe& flowMap(FlowMap &map) { if (_local_flow) { delete _flow; @@ -273,7 +278,7 @@ /// The potentials provide the dual solution of the underlying /// minimum cost flow problem. /// - /// \return \c (*this) + /// \return (*this) Suurballe& potentialMap(PotentialMap &map) { if (_local_potential) { delete _potential; @@ -458,7 +463,7 @@ /// \brief Return the total length (cost) of the found paths (flow). /// /// This function returns the total length (cost) of the found paths - /// (flow). The complexity of the function is \f$ O(e) \f$. + /// (flow). The complexity of the function is O(e). /// /// \pre \ref run() or \ref findFlow() must be called before using /// this function. diff --git a/lemon/unionfind.h b/lemon/unionfind.h --- a/lemon/unionfind.h +++ b/lemon/unionfind.h @@ -51,11 +51,13 @@ /// /// \pre You need to add all the elements by the \ref insert() /// method. - template + template class UnionFind { public: - typedef _ItemIntMap ItemIntMap; + ///\e + typedef IM ItemIntMap; + ///\e typedef typename ItemIntMap::Key Item; private: @@ -170,11 +172,13 @@ /// \pre You need to add all the elements by the \ref insert() /// method. /// - template + template class UnionFindEnum { public: - typedef _ItemIntMap ItemIntMap; + ///\e + typedef IM ItemIntMap; + ///\e typedef typename ItemIntMap::Key Item; private: @@ -627,11 +631,13 @@ /// /// \pre You need to add all the elements by the \ref insert() /// method. - template + template class ExtendFindEnum { public: - typedef _ItemIntMap ItemIntMap; + ///\e + typedef IM ItemIntMap; + ///\e typedef typename ItemIntMap::Key Item; private: @@ -948,18 +954,18 @@ /// /// \pre You need to add all the elements by the \ref insert() /// method. - /// - template > + template > class HeapUnionFind { public: - typedef _Value Value; - typedef typename _ItemIntMap::Key Item; - - typedef _ItemIntMap ItemIntMap; - - typedef _Comp Comp; + ///\e + typedef V Value; + ///\e + typedef typename IM::Key Item; + ///\e + typedef IM ItemIntMap; + ///\e + typedef Comp Compare; private: @@ -1601,7 +1607,7 @@ /// \brief Gives back the priority of the current item. /// - /// \return Gives back the priority of the current item. + /// Gives back the priority of the current item. const Value& operator[](const Item& item) const { return nodes[index[item]].prio; } @@ -1646,7 +1652,7 @@ /// \brief Gives back the minimum priority of the class. /// - /// \return Gives back the minimum priority of the class. + /// Gives back the minimum priority of the class. const Value& classPrio(int cls) const { return nodes[~(classes[cls].parent)].prio; } @@ -1660,9 +1666,9 @@ /// \brief Gives back a representant item of the class. /// + /// Gives back a representant item of the class. /// The representant is indpendent from the priorities of the /// items. - /// \return Gives back a representant item of the class. const Item& classRep(int id) const { int parent = classes[id].parent; return nodes[parent >= 0 ? classes[id].depth : leftNode(id)].item;