Boost logo

Boost Users :

Subject: Re: [Boost-users] grid_graph vertex properties
From: David Doria (daviddoria_at_[hidden])
Date: 2012-01-23 12:22:28


> Yes, that is correct.  Both vertex and edge index maps exist, though, so it
> is easy to use external properties for both of those (unlike edge properties
> for adjacency_list).

Hm, I've been playing with this for a while now and I don't seem to
understand how to add something to the vertex index map.

This compiles, but I think it is creating a new map:

#include <iostream>
#include <boost/array.hpp>
#include <boost/graph/grid_graph.hpp>

int main(int argc, char* argv[])
{
  typedef boost::grid_graph<2> GraphType;

  const unsigned int dimension = 5;
  boost::array<std::size_t, 2> lengths = { { dimension, dimension } };
  GraphType graph(lengths);

  boost::graph_traits<GraphType>::vertex_descriptor v = { { 0, 1 } };

  std::vector<float> vertexData(dimension * dimension, 0);

  boost::grid_graph_index_map<GraphType,
boost::graph_traits<GraphType>::vertex_descriptor, float>
myMap(graph);

  float retrieved = get(myMap, v);
  std::cout << "Retrieved: " << retrieved << std::endl;

}

Could you demonstrate how to do this? We should really add this to the
grid_graph documentation :)

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