[Lemon-user] matching with double edge weights

Matthew Galati matthew.galati at gmail.com
Thu Sep 15 15:04:22 CEST 2016


Thanks! That worked.

On Thu, Sep 15, 2016 at 8:22 AM, Alpar Juttner <alpar at cs.elte.hu> wrote:

> Hi,
>
> You should also declare the type of the map containing the edge weights,
> i.e.:
>
> MaxWeightedPerfectMatching<ListGraph,ListGraph::EdgeMap<double> > mwpm(G,
> weight);
>
> For the second template parameter,  GR::EdgeMap<int> is default setting.
> That's why it worked without explicitly specifying it.
>
> Regards,
> Alpár
>
>
>
> On Wed, 2016-09-14 at 16:05 -0400, Matthew Galati wrote:
>
> I am trying to do a simple test of the matching algorithm.
>
> It works fine with ListGraph::EdgeMap<int> weight(G);
>
> But, if I change this to ListGraph::EdgeMap<double> weight(G), I get the
> following compiler error:
>
> /u/magala/cpp/lemon/tkegraph/src/lemoncpp.cpp(53): error: no instance of
> constructor "lemon::MaxWeightedPerfectMatching<GR, WM>::MaxWeightedPerfectMatching
> [with GR=lemon::ListGraph, WM=lemon::GraphExtender<lemon:
> :ListGraphBase>::EdgeMap<int>]" matches the argument list
>             argument types are: (lemon::ListGraph,
> lemon::GraphExtender<lemon::ListGraphBase>::EdgeMap<double>)
>      MaxWeightedPerfectMatching<ListGraph> mwpm(G, weight);
>
>
> Here is the full code:
>
> int LemonC::CreateGraph(const int      nNodes,
>                         const int64_t  nLinks,
>                         const int    * linkO,
>                         const int    * linkD,
>                         const double * linkWt){
>    TEMPLATE_GRAPH_TYPEDEFS(ListGraph);
>    cout << "hello test lemon create graph" << endl;
>    ListGraph G;
>    ListGraph::EdgeMap<double> weight(G);
>    //ListGraph::EdgeMap<int> weight(G);
>    ListGraph::Edge e;
>    ListGraph::Node n[10000];
>    G.reserveNode(nNodes);
>    G.reserveEdge(nLinks);
>    int64_t i;
>    for(i = 0; i < nNodes; i++){
>       n[i] = G.addNode();
>    }
>    for(i = 0; i < nLinks; i++){
>       e = G.addEdge(n[linkO[i]], n[linkD[i]]);
>       weight[e] = linkWt[i];
>    }
>
>    MaxWeightedPerfectMatching<ListGraph> mwpm(G, weight);
>    bool result = mwpm.run();
>    cout << "Matching weight = " << mwpm.matchingWeight() << endl;
>
>    return 1;
> }
>
> _______________________________________________
> Lemon-user mailing listLemon-user at lemon.cs.elte.huhttp://lemon.cs.elte.hu/mailman/listinfo/lemon-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lemon.cs.elte.hu/pipermail/lemon-user/attachments/20160915/a59120ee/attachment.html>


More information about the Lemon-user mailing list