diff -r 80bb73097736 -r c5e56125959a src/lemon/max_matching.h --- a/src/lemon/max_matching.h Mon Feb 21 14:59:12 2005 +0000 +++ b/src/lemon/max_matching.h Mon Feb 21 18:51:11 2005 +0000 @@ -54,6 +54,9 @@ ///\author Jacint Szabo template class MaxMatching { + + protected: + typedef typename Graph::Node Node; typedef typename Graph::Edge Edge; typedef typename Graph::UndirEdgeIt UndirEdgeIt; @@ -77,7 +80,7 @@ C=2 }; - private: + protected: static const int HEUR_density=2; const Graph& g; @@ -128,11 +131,11 @@ return _mate[node]; } - ///Reads a matching from a \c Node map of \c Nodes. + ///Reads a matching from a \c Node valued \c Node map. - ///Reads a matching from a \c Node map of \c Nodes. This map must be \e - ///symmetric, i.e. if \c map[u]==v then \c map[v]==u must hold, and - ///\c uv will be an edge of the matching. + ///Reads a matching from a \c Node valued \c Node map. This map + ///must be \e symmetric, i.e. if \c map[u]==v then \c map[v]==u + ///must hold, and \c uv will be an edge of the matching. template void readNMapNode(NMapN& map) { for(NodeIt v(g); v!=INVALID; ++v) { @@ -140,9 +143,9 @@ } } - ///Writes the stored matching to a \c Node map of \c Nodes. + ///Writes the stored matching to a \c Node valued \c Node map. - ///Writes the stored matching to a \c Node map of \c Nodes. The + ///Writes the stored matching to a \c Node valued \c Node map. The ///resulting map will be \e symmetric, i.e. if \c map[u]==v then \c ///map[v]==u will hold, and now \c uv is an edge of the matching. template @@ -152,27 +155,29 @@ } } - ///Reads a matching from a \c Node map of \c Edges. + ///Reads a matching from an \c UndirEdge valued \c Node map. - ///Reads a matching from a \c Node map of incident \c Edges. This - ///map must have the property that if \c G.target(map[u])==v then \c - ///G.target(map[v])==u must hold, and now this edge is an edge of - ///the matching. + ///Reads a matching from an \c UndirEdge valued \c Node map. \c + ///map[v] must be an \c UndirEdge incident to \c v. This map must + ///have the property that if \c g.oppositeNode(u,map[u])==v then + ///\c \c g.oppositeNode(v,map[v])==u holds, and now some edge + ///joining \c u to \v will be an edge of the matching. template void readNMapEdge(NMapE& map) { for(NodeIt v(g); v!=INVALID; ++v) { - Edge e=map[v]; - if ( g.valid(e) ) + UndirEdge e=map[v]; + if ( e!=INVALID ) g.source(e) == v ? _mate.set(v,g.target(e)) : _mate.set(v,g.source(e)); } } - ///Writes the matching stored to a \c Node map of \c Edges. + ///Writes the matching stored to an \c UndirEdge valued \c Node map. - ///Writes the stored matching to a \c Node map of incident \c - ///Edges. This map will have the property that if \c - ///g.target(map[u])==v then \c g.target(map[v])==u holds, and now this - ///edge is an edge of the matching. + ///Writes the stored matching to an \c UndirEdge valued \c Node + ///map. \c map[v] will be an \c UndirEdge incident to \c v. This + ///map will have the property that if \c g.oppositeNode(u,map[u]) + ///== v then \c map[u]==map[v] holds, and now this edge is an edge + ///of the matching. template void writeNMapEdge (NMapE& map) const { typename Graph::template NodeMap todo(g,true); @@ -193,11 +198,11 @@ } - ///Reads a matching from an \c Edge map of \c bools. + ///Reads a matching from a \c bool valued \c Edge map. - ///Reads a matching from an \c Edge map of \c bools. This map must - ///have the property that there are no two adjacent edges \c e, \c - ///f with \c map[e]==map[f]==true. The edges \c e with \c + ///Reads a matching from a \c bool valued \c Edge map. This map + ///must have the property that there are no two incident edges \c + ///e, \c f with \c map[e]==map[f]==true. The edges \c e with \c ///map[e]==true form the matching. template void readEMapBool(EMapB& map) { @@ -212,12 +217,12 @@ } - ///Writes the matching stored to an \c Edge map of \c bools. + ///Writes the matching stored to a \c bool valued \c Edge map. - ///Writes the matching stored to an \c Edge map of \c bools. This - ///map will have the property that there are no two adjacent edges - ///\c e, \c f with \c map[e]==map[f]==true. The edges \c e with \c - ///map[e]==true form the matching. + ///Writes the matching stored to a \c bool valued \c Edge + ///map. This map will have the property that there are no two + ///incident edges \c e, \c f with \c map[e]==map[f]==true. The + ///edges \c e with \c map[e]==true form the matching. template void writeEMapBool (EMapB& map) const { for(UndirEdgeIt e(g); e!=INVALID; ++e) map.set(e,false); @@ -252,6 +257,7 @@ private: + void lateShrink(Node v, typename Graph::template NodeMap& ear, UFE& blossom, UFE& tree); @@ -292,12 +298,14 @@ typename Graph::template NodeMap ear(g,INVALID); //undefined for the base nodes of the blossoms (i.e. for the - //representative elements of UFE blossom) and for the nodes in C - + //representative elements of UFE blossom) and for the nodes in C + typename UFE::MapType blossom_base(g); UFE blossom(blossom_base); typename UFE::MapType tree_base(g); UFE tree(tree_base); + //If these UFE's would be members of the class then also + //blossom_base and tree_base should be a member. for(NodeIt v(g); v!=INVALID; ++v) { if ( position[v]==C && _mate[v]==INVALID ) { @@ -471,7 +479,7 @@ ++s; } } - return (int)s/2; + return s/2; } template @@ -562,4 +570,4 @@ } //END OF NAMESPACE LEMON -#endif //EDMONDS_H +#endif //LEMON_MAX_MATCHING_H