Dear all, Is there any way to deduce the graph a graph-iterator is iterating over? So, for example for: typedef graph_type::vertex_iterator iterator; iterator begin, end; tie(begin, end) = vertices(g); is there anything like graph_type gg = graph_of(begin); so that gg == g? TIA, --Hossein
On Thu, 20 May 2010, Hossein Haeri wrote:
Dear all,
Is there any way to deduce the graph a graph-iterator is iterating over? So, for example for:
typedef graph_type::vertex_iterator iterator; iterator begin, end; tie(begin, end) = vertices(g);
is there anything like
graph_type gg = graph_of(begin);
so that gg == g?
That's not really possible, just like there is no mapping from STL iterators to their corresponding paper. In some cases (I think actually most of them), the vertex iterators of a graph don't have a reference to the graph at all. -- Jeremiah Willcock
Jeremiah,
graph_type gg = graph_of(begin);
so that gg == g?
That's not really possible, just like there is no mapping from STL iterators to their corresponding paper. In some cases
The situation is not exactly as with STL. In STL, for an iterator i, *i will give the element i refers to. (Forgive my technically imprecise terminology for a moment please.) Whereas, in BGL, for a vertex_iterator vi, *vi will not give the vertex vi refers to; it's g[*vi] that does that. So, in fact, my problem will be solved if I can find a way of getting holds of the vertex vi is referring to even without messing around with g. Any ideas? TIA, --Hossein
On Thu, 20 May 2010, Hossein Haeri wrote:
Jeremiah,
graph_type gg = graph_of(begin);
so that gg == g?
That's not really possible, just like there is no mapping from STL iterators to their corresponding paper. In some cases
The situation is not exactly as with STL. In STL, for an iterator i, *i will give the element i refers to. (Forgive my technically imprecise terminology for a moment please.) Whereas, in BGL, for a vertex_iterator vi, *vi will not give the vertex vi refers to; it's g[*vi] that does that. So, in fact, my problem will be solved if I can find a way of getting holds of the vertex vi is referring to even without messing around with g. Any ideas?
In several of the graph types, a vertex descriptor is just an integer, so there is no graph-specific information in it at all. The vertex that vi is referring to is *vi; you don't need to have the graph to get the vertex descriptor out of an iterator. You do need the graph to get properties, and the vertex descriptor does not have enough information to find them without the graph being specified separately. -- Jeremiah Willcock
participants (2)
-
Hossein Haeri
-
Jeremiah Willcock