Boost logo

Boost Users :

Subject: [Boost-users] Retrieving edge weights
From: David Doria (daviddoria_at_[hidden])
Date: 2011-06-11 17:10:38


I found one way to get edge weights:

  typedef boost::property_map<Graph, boost::edge_weight_t>::type EdgeWeightMap;
  EdgeWeightMap edgeWeightMap = get(boost::edge_weight, g);

  std::pair<Graph::edge_descriptor, bool> edgePair = boost::edge(v0, v1, g);
  Graph::edge_descriptor edge = edgePair.first;

That seems like a lot of work though. It looks like there is a
operator[](edge_descriptor), but I don't understand how to use it:

I tried:

g[edge]->edge_weight

but there are compiler errors.

The whole demonstration is here:

http://programmingexamples.net/index.php?title=CPP/Boost/BGL/Directed/Weighted

Any suggestions? Or is the first way the only/best way?

Thanks,

David


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