[BGL] Out-of-range Edge Endpoints

Dear all, In the following documentation page for adjacency_list: http://www.boost.org/doc/libs/1_42_0/libs/graph/doc/adjacency_list.html according to what I read below the following ctor, endpoints of edges must all fall in [0, n): template <class EdgeIterator> adjacency_list(EdgeIterator first, EdgeIterator last, vertices_size_type n, edges_size_type m = 0, const GraphProperty& p = GraphProperty()) What I can't see is what will happen when the endpoints don't fall in [0, n). Is that documented somewhere? TIA, --Hossein

On Thu, 29 Apr 2010, Hossein Haeri wrote:
Dear all,
In the following documentation page for adjacency_list:
http://www.boost.org/doc/libs/1_42_0/libs/graph/doc/adjacency_list.html
according to what I read below the following ctor, endpoints of edges must all fall in [0, n):
template <class EdgeIterator> adjacency_list(EdgeIterator first, EdgeIterator last, vertices_size_type n, edges_size_type m = 0, const GraphProperty& p = GraphProperty())
What I can't see is what will happen when the endpoints don't fall in [0, n). Is that documented somewhere?
I don't think so. It's basically undefined behavior -- it usually ends up in an out-of-bounds array access and thus likely a crash. -- Jeremiah Willcock

What I can't see is what will happen when the endpoints don't fall in [0, n). Is that documented somewhere?
I don't think so. It's basically undefined behavior -- it usually ends up in an out-of-bounds array access and thus likely a crash.
In the case of the constructor, it may. In the case of add_edge (with the vertex list == vecS), adjacency_list will automatically resize -- I think I remember being surprised with this before :) It's probably worth looking at before taking my word for it. Andrew Sutton andrew.n.sutton@gmail.com
participants (3)
-
Andrew Sutton
-
Hossein Haeri
-
Jeremiah Willcock