COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
08/23/04 13:06:00 (20 years ago)
Author:
marci
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1031
Message:

stGraphWrapper modifications

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/marci/max_bipartite_matching.h

    r762 r768  
    6060    //   EdgeFlow* edge_flow;
    6161    //   NodeFlow* node_flow;
    62     typedef  stGraphWrapper<Graph> stGW;
     62    typedef  stBipartiteGraphWrapper<Graph> stGW;
    6363    stGW stgw;
    6464    typedef typename stGW::template EdgeMapWrapper<EdgeCap, NodeCap> CapMap;
     
    6767    typedef typename stGW::template EdgeMapWrapper<EdgeFlow, NodeFlow> FlowMap;
    6868    FlowMap flow;
    69     MaxFlow<stGW, int, CapMap, FlowMap> mf;
     69    typedef MaxFlow<stGW, int, CapMap, FlowMap> MaxFlow;
     70    MaxFlow mf;
    7071    //graph* g;
    7172    //EdgeCap* edge_cap;
    7273    //EdgeFlow* edge_flow;
    7374  public:
     75    enum MatchingEnum{
     76      ZERO_MATCHING,
     77      GEN_MATCHING,
     78      GEN_MATCHING_WITH_GOOD_NODE_FLOW,
     79      NO_MATCHING
     80    };
    7481    /// For capacitated b-matchings, edge-caoacities and node-capacities
    7582    /// have to be given. After running \c run the matching is is given
     
    99106    ~MaxBipartiteMatching() { if (node_flow) delete node_flow; }
    100107    /// run computes the max matching.
    101     void run() { mf.run(); }
     108    void run(MatchingEnum me=ZERO_MATCHING) {
     109      switch (me) {
     110        case ZERO_MATCHING:
     111          mf.run(MaxFlow::ZERO_FLOW);
     112          break;
     113        case GEN_MATCHING:
     114        {
     115          typename stGW::OutEdgeIt e;
     116          for (stgw.first(e, stgw.S_NODE); stgw.valid(e); stgw.next(e))
     117            flow.set(e, cap[e]);
     118        }
     119        {
     120          typename stGW::InEdgeIt e;
     121          for (stgw.first(e, stgw.T_NODE); stgw.valid(e); stgw.next(e))
     122            flow.set(e, 0);
     123        }
     124        mf.run(MaxFlow::PRE_FLOW);
     125        break;
     126        case GEN_MATCHING_WITH_GOOD_NODE_FLOW:
     127          mf.run(MaxFlow::GEN_FLOW);
     128          break;
     129        case NO_MATCHING:
     130          mf.run(MaxFlow::NO_FLOW);
     131          break;
     132      }
     133    }
    102134    /// The matching value after running \c run.
    103     int matchingValue() { return mf.flowValue(); }
     135    int matchingValue() const { return mf.flowValue(); }
    104136  };
    105137
Note: See TracChangeset for help on using the changeset viewer.