[Lemon-user] Generic algorithm that can take different SubDigraph types as input?
David Franz Koza
dakoz at dtu.dk
Mon Mar 6 18:27:14 CET 2017
Dear all,
I coded a graph algorithm, which I would like to call for differently specified SubDigraphs as input (or even other types of Digraphs). Without having to duplicate the code, how can I code my algorithm in a generic way?
In my particular case I have different SubDigraphs, e.g.:
lemon::SubDigraph< lemon::SmartDigraph, lemon::SmartDigraph::NodeMap<bool>, lemon::SmartDigraph::ArcMap<bool> > sub1;
or
lemon::SubDigraph< lemon::SmartDigraph, lemon::CombineMap< lemon::SmartDigraph::NodeMap<bool>, lemon::SmartDigraph::NodeMap<bool>, std::logical_and<bool> >, lemon::SmartDigraph::ArcMap<bool> > sub2;
i.e. the first one is defined over a standard NodeMap<bool>, while the second one is defined over a CombineMap of two NodeMap<bool>. When looping through vertices in the algorithm, however, the SubDigraph type needs to be specified explicitly. How can I make the following code work for both SubDigraph (or, more generally, other Digraph) specifications:
for (lemon::SubDigraph< lemon::SmartDigraph, lemon::SmartDigraph::NodeMap<bool>, lemon::SmartDigraph::ArcMap<bool> >
::NodeIt v(sub1); v != lemon::INVALID; ++v) {
...
}
Question http://lemon.cs.elte.hu/pipermail/lemon-user/2011-October/000483.html is similar and suggests to use template functions. Could you provide a tiny example of how a solution using template functions would look like in the above case?
Thanks,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lemon.cs.elte.hu/pipermail/lemon-user/attachments/20170306/507a9a40/attachment.html>
More information about the Lemon-user
mailing list