[Lemon-user] matching with double edge weights

Alpar Juttner alpar at cs.elte.hu
Thu Sep 15 14:22:17 CEST 2016


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 weight(G), I get
> the following compiler error:
> 
> /u/magala/cpp/lemon/tkegraph/src/lemoncpp.cpp(53): error: no instance
> of constructor "lemon::MaxWeightedPerfectMatching
> WM>::MaxWeightedPerfectMatching [with GR=lemon::ListGraph,
> WM=lemon::GraphExtender::EdgeMap]" matches
> the argument list
>             argument types are: (lemon::ListGraph,
> lemon::GraphExtender::EdgeMap)
>      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 list
> Lemon-user at lemon.cs.elte.hu
> http://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/d50d1f3a/attachment.html>


More information about the Lemon-user mailing list