COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
08/21/07 15:22:21 (17 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3301
Message:

Query functions: aMatching and bMatching
Modified algorithm function interfaces
ANodeMap<UEdge> matching map
BNodeMap<bool> barrier map

Consistency between augmenting path and push-relabel algorithm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/pr_bipartite_matching.h

    r2462 r2463  
    316316    ///@{
    317317
    318     /// \brief Set true all matching uedge in the map.
    319     ///
    320     /// Set true all matching uedge in the map. It does not change the
    321     /// value mapped to the other uedges.
    322     /// \return The number of the matching edges.
     318    ///Set true all matching uedge in the map.
     319
     320    ///Set true all matching uedge in the map. It does not change the
     321    ///value mapped to the other uedges.
     322    ///\return The number of the matching edges.
    323323    template <typename MatchingMap>
    324324    int quickMatching(MatchingMap& mm) const {
     
    329329    }
    330330
    331     ///\brief Set true all matching uedge in the map and the others to false.
     331    ///Set true all matching uedge in the map and the others to false.
    332332
    333333    ///Set true all matching uedge in the map and the others to false.
     
    337337      for (UEdgeIt e(_g);e!=INVALID;++e) {
    338338        mm.set(e,e==_matching[_g.aNode(e)]);
     339      }
     340      return _matching_size;
     341    }
     342
     343    ///Gives back the matching in an ANodeMap.
     344
     345    ///Gives back the matching in an ANodeMap. The parameter should
     346    ///be a write ANodeMap of UEdge values.
     347    ///\return The number of the matching edges.
     348    template<class MatchingMap>
     349    int aMatching(MatchingMap& mm) const {
     350      for (ANodeIt n(_g);n!=INVALID;++n) {
     351        mm.set(n,_matching[n]);
     352      }
     353      return _matching_size;
     354    }
     355
     356    ///Gives back the matching in a BNodeMap.
     357
     358    ///Gives back the matching in a BNodeMap. The parameter should
     359    ///be a write BNodeMap of UEdge values.
     360    ///\return The number of the matching edges.
     361    template<class MatchingMap>
     362    int bMatching(MatchingMap& mm) const {
     363      for (BNodeIt n(_g);n!=INVALID;++n) {
     364        mm.set(n,INVALID);
     365      }
     366      for (ANodeIt n(_g);n!=INVALID;++n) {
     367        if (_matching[n]!=INVALID)
     368          mm.set(_g.bNode(_matching[n]),_matching[n]);
    339369      }
    340370      return _matching_size;
     
    458488  ///in a bipartite graph \c g.
    459489  ///\param g An undirected bipartite graph.
    460   ///\retval matching A write UEdgeMap of value type \c bool.
    461   /// The found edges will be returned in this map.
     490  ///\retval matching A write ANodeMap of value type \c UEdge.
     491  /// The found edges will be returned in this map,
     492  /// i.e. for an \c ANode \c n the edge <tt>matching[n]</tt> is the one
     493  /// that covers the node \c n.
    462494  ///\return The cardinality of the maximum matching.
    463495  ///
     
    469501    PrBipartiteMatching<Graph> bpm(g);
    470502    bpm.run();
    471     bpm.matching(matching);
     503    bpm.aMatching(matching);
    472504    return bpm.matchingSize();
    473505  }
     
    479511  ///in a bipartite graph \c g.
    480512  ///\param g An undirected bipartite graph.
    481   ///\retval matching A write UEdgeMap of value type \c bool.
    482   /// The found edges will be returned in this map.
     513  ///\retval matching A write ANodeMap of value type \c UEdge.
     514  /// The found edges will be returned in this map,
     515  /// i.e. for an \c ANode \c n the edge <tt>matching[n]</tt> is the one
     516  /// that covers the node \c n.
    483517  ///\retval barrier A \c bool WriteMap on the BNodes. The map will be set
    484518  /// exactly once for each BNode. The nodes with \c true value represent
     
    495529    PrBipartiteMatching<Graph> bpm(g);
    496530    bpm.run();
    497     bpm.matching(matching);
     531    bpm.aMatching(matching);
    498532    bpm.bBarrier(barrier);
    499533    return bpm.matchingSize();
     
    522556  ///This function finds a perfect matching in a bipartite graph \c g.
    523557  ///\param g An undirected bipartite graph.
    524   ///\retval matching A write UEdgeMap of value type \c bool.
    525   /// The found edges will be returned in this map.
     558  ///\retval matching A write ANodeMap of value type \c UEdge.
     559  /// The found edges will be returned in this map,
     560  /// i.e. for an \c ANode \c n the edge <tt>matching[n]</tt> is the one
     561  /// that covers the node \c n.
    526562  /// The values are unchanged if the graph
    527563  /// has no perfect matching.
     
    534570  {
    535571    PrBipartiteMatching<Graph> bpm(g);
    536     bool ret = bpm.runPerfect();
    537     if (ret) bpm.matching(matching);
     572    bool ret = bpm.checkedRunPerfect();
     573    if (ret) bpm.aMatching(matching);
    538574    return ret;
    539575  }
     
    544580  ///This function finds a perfect matching in a bipartite graph \c g.
    545581  ///\param g An undirected bipartite graph.
    546   ///\retval matching A readwrite UEdgeMap of value type \c bool.
    547   /// The found edges will be returned in this map.
     582  ///\retval matching A write ANodeMap of value type \c UEdge.
     583  /// The found edges will be returned in this map,
     584  /// i.e. for an \c ANode \c n the edge <tt>matching[n]</tt> is the one
     585  /// that covers the node \c n.
    548586  /// The values are unchanged if the graph
    549587  /// has no perfect matching.
     
    558596  ///on the push-relabel principle.
    559597  template<class Graph,class MT, class GT>
    560   int prPerfectBipartiteMatching(const Graph &g,MT &matching,GT &barrier)
     598  bool prPerfectBipartiteMatching(const Graph &g,MT &matching,GT &barrier)
    561599  {
    562600    PrBipartiteMatching<Graph> bpm(g);
    563     bool ret=bpm.runPerfect();
     601    bool ret=bpm.checkedRunPerfect();
    564602    if(ret)
    565       bpm.matching(matching);
     603      bpm.aMatching(matching);
    566604    else
    567605      bpm.bBarrier(barrier);
Note: See TracChangeset for help on using the changeset viewer.