[Lemon-user] creating a graph out of a SubDigraph?
Alpár Jüttner
alpar at cs.elte.hu
Wed Aug 1 11:40:04 CEST 2012
Hi,
Of all the graph algorithms are implemented as templates therefore you
can use them with any graph type. The basic pattern is the following.
typedef SubDigraph<ListDigraph,ListDigraph::NodeMap<bool>,
ListDigraph::ArcMap<bool> > MySubDigraph;
ListDigraph g;
MySubDigraph sub(g,nm,am);
Dfs<MySubgraph> sub_dfs(g);
sub_dfs.run(s);
Using the functional API of DFS is even easier, as you don't need to
explicitly give the type of the underlying graph. You can simply write
dfs(sub).predMap(pm).run(s);
The tree found by dfs will be written into pm, which is a NodeMap of
arcs. More exactly it must be defined either as
ListDigraph::NodeMap<ListDigraph::Arc> pm(g);
or
MySubDigraph::NodeMap<MySubDigraph::Arc> pm(sub);
Here is the doc of the class based interface:
http://lemon.cs.elte.hu/pub/doc/1.2.3/a00096.html
And this is for the function-like one:
http://lemon.cs.elte.hu/pub/doc/1.2.3/a00530.html#ga1926710bf80700bdeab0fb2e16830999
Regards,
Alpar
On Mon, 2012-07-30 at 18:19 +0200, Dalia De Santis wrote:
> Hi users,
>
> I'm using the SubDigraph class to obtain a filtered view of a
> ListDigraph:
> SubDigraph<ListDigraph,ListDigraph::NodeMap<bool>,ListDigraph::ArcMap<bool>> netView;
>
> I am wondering if there is already a way in lemon to view this class
> as a graph so as to run the Dfs algorithm on this filtered version of
> the original graph, (let's say something like ListDigraph
> netView.asGraph()) or if it is necessary need to write an ad hoc
> method that takes the SubDigraph and creates a new graph out of it.
>
> Thank you!
>
> --
> Dalia
>
>
> _______________________________________________
> Lemon-user mailing list
> Lemon-user at lemon.cs.elte.hu
> http://lemon.cs.elte.hu/mailman/listinfo/lemon-user
More information about the Lemon-user
mailing list