Connected components or inverse search with the Boost Graph Library

243 views Asked by At

Is it possible to run connected_components() against a bidirectional graph (constructed with ::boost::bidirectionalS) in the BGL? I get a segmentation violation when running something like this with a graph constructed that way:

int num_comp = connected_components(g,
    make_iterator_property_map(component.begin(), get(vertex_index, g)));

This isn't surprising, since the documentation indicates that it's only usable against undirected graph.

Failing that, is it possible to use one of the search algorithms (BFS or DFS) in the inverse direction? For example, I'd like to start my search at a terminal vertex (one with no outbound edges) and work backward.

I might be asking the wrong question, too: what I'm trying to do is find the subgraph of all vertices with a path to a given terminal vertex. Is there a more direct way to do that with the BGL?

I can do all that myself, of course, but I'd prefer to use BGL facilities if I can.

0

There are 0 answers