[BGL] Using copy_graph(g_in, g_out) with filtered_graph (and a special predicate) as input yields an unexpectedly empty graph
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? Best, Cedric
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
On Wednesday, 11. May 2011 06:00:54 Jeremiah Willcock wrote:
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.
Ok, thank you for the confirmation. I just had a deeper look at the code again and it turned out that it was not caused by copy_graph(). Thanks again.
-- Jeremiah Willcock _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Best, Cedric
participants (2)
-
Cedric Laczny
-
Jeremiah Willcock