Boost logo

Boost Users :

From: Douglas Gregor (dgregor_at_[hidden])
Date: 2007-09-11 09:39:20


abhishek.v_at_[hidden] wrote:
> I have a function which take an input from the user whether the graph
> is directed or undirected.
> I'm declaring graph as follows :-
>
> typedef adjacency_list < vecS, vecS,* undirectedS*, property <
> vertex_name_t,std::string >, property < edge_name_t, std::string > >
> Graph;
> Graph g;
>
> Now here the parameter in Bold need to be varied as the user input
> changes. One method could be i could have two different function
> say,CreateDirected()
> and CreateUndirected(). But this is not working in my case as i want
> the declaration should be global so that i can use it throughout my
> application. Please help.
That's actually a bit tricky in the BGL, as you've noted. My suggestion
would be to use bidirectionalS as the directedness tag, which gives you
a directed graph with access to both the incoming and the outgoing
edges. Then, it is relatively easy to write a graph adaptor that views
an existing bidirectional graph as an undirected graph. I that someone
posted on to the Boost mailing list recently, but I can't find it now :(

    - Doug


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