[Lemon-user] Run algorithm on SubDigraph but use (original) Digraph maps
David Franz Koza
dakoz at dtu.dk
Thu Jan 26 18:59:28 CET 2017
Dear all,
I'm trying to get a better understanding of lemon graph adaptors in combination with algorithms (function vs class interface). I have a Digraph and a corresponding SubDigraph. I would like to run an algorithm (e.g. Dijkstra) on the SubDigraph, but use the original Digraph maps as input. This is what I tried:
using namespace lemon;
typedef SmartDigraph Digraph;
typedef lemon::SubDigraph<Digraph, Digraph::NodeMap<bool>, Digraph::ArcMap<bool>> SubDigraph;
Digraph g;
Digraph::Node s = g.addNode();
// add further nodes here...
Digraph::NodeMap<bool> node_filter(g);
Digraph::ArcMap<bool> arc_filter(g);
Digraph::ArcMap<int> length(g);
// fill above maps with values...
Digraph::NodeMap<int> dist(g);
// this works:
Dijkstra<Digraph> dijkstra_alg(g, length);
// create a SubDigraph of g based on node_filter and arc_filter maps:
SubDigraph sub_dg(g, node_filter, arc_filter);
// this would work, but requires a new map defined over the SubDigraph:
SubDigraph::ArcMap<int> length_sub(sub_dg);
Dijkstra<SubDigraph> dijkstra_alg2(sub_dg, length_sub);
// this gives an error:
Dijkstra<SubDigraph> dijkstra_alg3(sub_dg, length);
// when using the function interface, this works:
dijkstra(subDigraph(g, node_filter, arc_filter), length).distMap(dist).run(s);
Why can I use subDigraph() (which returns a SubDigraph adaptor) in the dijkstra function interface together with maps of the original graph, and why does the line above using the class interface not work? Am I not using the class interface correctly or, in other words, how can I use the Dijkstra class interface for a SubDigraph while using the original Digraph maps?
Thanks,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lemon.cs.elte.hu/pipermail/lemon-user/attachments/20170126/71b990af/attachment.html>
More information about the Lemon-user
mailing list