Boost logo

Boost Users :

From: Todd A. Gibson (tgibson_at_[hidden])
Date: 2005-06-03 15:10:41

Take this snippet:
        // g is an adjacency_list
        // u,v are vertices
        bool b;
        edge_desc e;
          std::cerr << "No such edge!";

boost::edge() is written to handle non-existent vertices:

  //abbreviated excerpt from detail/adjacency_list.hpp
  inline std::pair<edge_descriptor,bool>
  edge_dispatch(...) const
    bool found;
    typename Config::OutEdgeList::const_iterator
      i = g.out_edge_list(u).find(StoredEdge(v)),
      end = g.out_edge_list(u).end();
    found = (i != end);
    if (found)
      return std::make_pair(edge_descriptor(u, v, &(*i).get_property()),
      return std::make_pair(edge_descriptor(u, v, 0), false);

However, I don't believe out_edge_list handles invalid vertices.
If I provide an invalid source vertex, u, I get a segmentation fault on
the call to g.out_edge_list(u).find(v).

Todd A. Gibson

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at