graph/subgraph: end iterator dereferenced

Hi, Line 189 of subgraph.hpp is: return std::make_pair((*i).second, i != m_local_vertex.end()); Consequently iterator i is dereferenced even when it is equal to m_local_vertex.end(). So here comes a patch. When *i is not valid, the patch simply returns u_global (the closest vertex_descriptor available to the code), another value may make better sense (but since the value is not supposed to be used). Regards, Guillaume

On Jul 17, 2004, at 4:15 AM, Guillaume Melquiond wrote:
Hi,
Line 189 of subgraph.hpp is:
return std::make_pair((*i).second, i != m_local_vertex.end());
Consequently iterator i is dereferenced even when it is equal to m_local_vertex.end(). So here comes a patch. When *i is not valid, the patch simply returns u_global (the closest vertex_descriptor available to the code), another value may make better sense (but since the value is not supposed to be used).
You could use graph_traits<Graph>::null_vertex() to get a real "null" vertex. Thanks for the patches! I'm hitting the road right now, but I'll get to them tomorrow night if nobody gets there first. Doug

Le sam 17/07/2004 à 17:19, Doug Gregor a écrit :
On Jul 17, 2004, at 4:15 AM, Guillaume Melquiond wrote:
Hi,
Line 189 of subgraph.hpp is:
return std::make_pair((*i).second, i != m_local_vertex.end());
Consequently iterator i is dereferenced even when it is equal to m_local_vertex.end(). So here comes a patch. When *i is not valid, the patch simply returns u_global (the closest vertex_descriptor available to the code), another value may make better sense (but since the value is not supposed to be used).
You could use graph_traits<Graph>::null_vertex() to get a real "null" vertex. Thanks for the patches! I'm hitting the road right now, but I'll get to them tomorrow night if nobody gets there first.
I replaced u_global by null_vertex() and committed the first patch. I also committed the second patch. However, the second one may require a bit of review: the problem was obvious, but I'm not sure my solution does what should be done (even if the subgraph.cpp test program is happy). Regards, Guillaume
participants (2)
-
Doug Gregor
-
Guillaume Melquiond