Boost logo

Boost Users :

Subject: Re: [Boost-users] [BGL] Using copy_graph(g_in, g_out) with filtered_graph (and a special predicate) as input yields an unexpectedly empty graph
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2011-05-11 00:00:54


On Thu, 5 May 2011, Cedric Laczny wrote:

> Hi,
>
> in order to select a subgraph based on some predicates, I use filtered_graph()
> with an appropriate predicate. To get the resulting subgraph (strictly
> speaking it is a new graph), I simply use copy_graph(fg, new_g). In a special
> situation, this predicate simply filters on the name and type of a vertex (set
> via vertex_properties). This is working as expected. The more, I am working
> with multipartite graphs, so there are no edges between 2 vertices of the same
> type.
> When I now define a predicate that will only let vertices of one special type
> to be visible and I use copy_graph() on this filtered_graph, the resulting
> graph has no edges (which is ok) but it also has no vertices. I would not
> expect the latter to happen. In turn, when I let another type of vertices to
> be visible, the resulting graph is again as expected.
> Is there perhaps some obvious speciality of copy_graph() I am missing?

If you manually iterate through vertices() of your filtered_graph, does
that return the vertices you expect? It looks like copy_graph (as opposed
to copy_component) just iterates through vertices and edges, and so
unreachable vertices should still be copied.

-- Jeremiah Willcock


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net