Boost logo

Boost Users :

Subject: Re: [Boost-users] [BGL]
From: Ben Pope (benpope81_at_[hidden])
Date: 2014-06-11 11:15:54


On Wednesday, June 11, 2014 09:36 PM, Pablo Madoery wrote:
> Hello, I Have 2 graphs: graph1 and graph2, and two sets of edge descriptors.
> One set is associated to edges of graph1 and another set associated to
> edges of graph2.
> I don't understand why is it possible to access information about edges
> of graph2 by using graph1 and the edge descriptors of graph2.

If the type of the vertex_descriptor is void*, internally, it's probably
just cast to some node in the graph. Just because the interface takes a
graph and a vertex_descriptor pair, doesn't mean it uses the graph you
passed*.

I guess the same would happen with a std::list<iterator>, if you use an
iterator from the wrong list, the next one would still point into the
wrong list, right?

It's undefined behaviour, and not all operations are likely to work, but
some might, as you've seen.

Ben

* It looks like you're using a member of the graph in that interface,
but if the implementation of that member doesn't use the this pointer,
it can still work.


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