Boost logo

Boost :

Subject: Re: [boost] [BGL] Multithread problem inserting edges and exploring the same graph
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2009-10-07 13:01:58


On Mon, 5 Oct 2009, Cosimo Calabrese wrote:

> Jeremiah Willcock ha scritto:
>> One issue with it is the case where the vertex or edge descriptor types of
>> the two graphs are the same. You need separate types for "thing from graph
>> 1" and "thing from graph 2"
>
> Yes, it's true.
>
> I thought to use a thing that I haven't never used, that is the 6th template
> parameter of adjacency_list: GraphProperties.
>
> adjacency_list<EdgeList, VertexList, Directed,
> VertexProperties, EdgeProperties, *GraphProperties*>
>
> I could define two tags:
>
> struct original_graph_tag { };
> struct little_graph_tag { };
>
> and pass these types in the 'original' and 'little' graph, respectively. This
> could be enough to differentiate the two type of graph, and therefore the
> descriptors.

That only works if both graphs are adjacency_lists and you have control
over the graph types. I would personally just make:

template <typename T>
struct from_first_graph {T data;};
template <typename T>
struct from_second_graph {T data;};

and then have my variants be:

boost::variant<from_first_graph<graph_traits<First>::vertex_descriptor>,
                from_second_graph<graph_traits<Second>::vertex_descriptor>
>

and the same for edge descriptors. This will disambiguate the types for
arbitrary graphs.

-- Jeremiah Willcock


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk