diff -r b61354458b59 -r 7ac52d6a268e lemon/max_matching.h --- a/lemon/max_matching.h Wed Apr 15 12:01:14 2009 +0200 +++ b/lemon/max_matching.h Fri Apr 17 09:54:14 2009 +0200 @@ -40,7 +40,7 @@ /// \brief Maximum cardinality matching in general graphs /// /// This class implements Edmonds' alternating forest matching algorithm - /// for finding a maximum cardinality matching in a general graph. + /// for finding a maximum cardinality matching in a general undirected graph. /// It can be started from an arbitrary initial matching /// (the default is the empty one). /// @@ -53,16 +53,17 @@ /// a perfect matching. The number of the factor-critical components /// minus the number of barrier nodes is a lower bound on the /// unmatched nodes, and the matching is optimal if and only if this bound is - /// tight. This decomposition can be obtained by calling \c - /// decomposition() after running the algorithm. + /// tight. This decomposition can be obtained using \ref status() or + /// \ref statusMap() after running the algorithm. /// - /// \tparam GR The graph type the algorithm runs on. + /// \tparam GR The undirected graph type the algorithm runs on. template class MaxMatching { public: /// The graph type of the algorithm typedef GR Graph; + /// The type of the matching map typedef typename Graph::template NodeMap MatchingMap; @@ -84,6 +85,7 @@ UNMATCHED = -2 ///< = -2. }; + /// The type of the status map typedef typename Graph::template NodeMap StatusMap; private: @@ -583,6 +585,14 @@ return (*_matching)[n]; } + /// \brief Return a const reference to the matching map. + /// + /// This function returns a const reference to a node map that stores + /// the matching arc (or edge) incident to each node. + const MatchingMap& matchingMap() const { + return *_matching; + } + /// \brief Return the mate of the given node. /// /// This function returns the mate of the given node in the current @@ -605,10 +615,19 @@ /// /// This function returns the \ref Status "status" of the given node /// in the Edmonds-Gallai decomposition. - Status decomposition(const Node& n) const { + Status status(const Node& n) const { return (*_status)[n]; } + /// \brief Return a const reference to the status map, which stores + /// the Edmonds-Gallai decomposition. + /// + /// This function returns a const reference to a node map that stores the + /// \ref Status "status" of each node in the Edmonds-Gallai decomposition. + const StatusMap& statusMap() const { + return *_status; + } + /// \brief Return \c true if the given node is in the barrier. /// /// This function returns \c true if the given node is in the barrier. @@ -662,7 +681,7 @@ /// If the value type is integer, then the dual solution is multiplied /// by \ref MaxWeightedMatching::dualScale "4". /// - /// \tparam GR The graph type the algorithm runs on. + /// \tparam GR The undirected graph type the algorithm runs on. /// \tparam WM The type edge weight map. The default type is /// \ref concepts::Graph::EdgeMap "GR::EdgeMap". #ifdef DOXYGEN @@ -681,6 +700,7 @@ /// The value type of the edge weights typedef typename WeightMap::Value Value; + /// The type of the matching map typedef typename Graph::template NodeMap MatchingMap; @@ -1829,7 +1849,7 @@ /// This function returns the weight of the found matching. /// /// \pre Either run() or start() must be called before using this function. - Value matchingValue() const { + Value matchingWeight() const { Value sum = 0; for (NodeIt n(_graph); n != INVALID; ++n) { if ((*_matching)[n] != INVALID) { @@ -1875,6 +1895,14 @@ return (*_matching)[node]; } + /// \brief Return a const reference to the matching map. + /// + /// This function returns a const reference to a node map that stores + /// the matching arc (or edge) incident to each node. + const MatchingMap& matchingMap() const { + return *_matching; + } + /// \brief Return the mate of the given node. /// /// This function returns the mate of the given node in the found @@ -2050,7 +2078,7 @@ /// If the value type is integer, then the dual solution is multiplied /// by \ref MaxWeightedMatching::dualScale "4". /// - /// \tparam GR The graph type the algorithm runs on. + /// \tparam GR The undirected graph type the algorithm runs on. /// \tparam WM The type edge weight map. The default type is /// \ref concepts::Graph::EdgeMap "GR::EdgeMap". #ifdef DOXYGEN @@ -2076,6 +2104,7 @@ static const int dualScale = std::numeric_limits::is_integer ? 4 : 1; + /// The type of the matching map typedef typename Graph::template NodeMap MatchingMap; @@ -3038,7 +3067,7 @@ /// This function returns the weight of the found matching. /// /// \pre Either run() or start() must be called before using this function. - Value matchingValue() const { + Value matchingWeight() const { Value sum = 0; for (NodeIt n(_graph); n != INVALID; ++n) { if ((*_matching)[n] != INVALID) { @@ -3069,6 +3098,14 @@ return (*_matching)[node]; } + /// \brief Return a const reference to the matching map. + /// + /// This function returns a const reference to a node map that stores + /// the matching arc (or edge) incident to each node. + const MatchingMap& matchingMap() const { + return *_matching; + } + /// \brief Return the mate of the given node. /// /// This function returns the mate of the given node in the found