
On Mon, 5 Oct 2009, Cosimo Calabrese wrote:
Jeremiah Willcock ha scritto:
I think that should work. You might really want a tagged union type, though (boost::variant with some guarantee that the edge descriptor types of the two graphs are different is an example). You would need to do wrapping of each graph's descriptors in the union iterator then, though. That would remove the restrictions on edges that you gave above. I don't know what you need as far as properties; those might need to be combined as well.
Hi Jeremiah,
I've readed some days ago your suggestions about using boost::variant, but I ignored what boost::variant is. So I've spent some time to study it, and now I think I understand what you have suggested to me. E.g. the edge_descriptor of union_graph adaptor is a boost::variant, that contains the edge_descriptor of both the graph. When I call the source() function I pass an edge_descriptor to it, but the source() doesn't know if the edge_descriptor belongs to one or another graph. So the source() function use a source_visitor, that distinguish between the edge_descriptors, and call the source() on the right graph.
Can you take a look to the attached code? Is this that you meant? I've writed only the case of the source() function, but at every concept function corresponds a visitor.
I think your code is going in the right direction and is basically what I had in mind. 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" (you can use the same wrapper for vertices and edges) to put into the variant. Also, if you don't want a variant visitor, you can use get() to dispatch on the variant type. -- Jeremiah Willcock