|
Boost Users : |
Subject: Re: [Boost-users] Iterating over vertices in a specific region in a graph
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2012-01-22 16:15:08
On Sun, 22 Jan 2012, David Doria wrote:
>> You would need to do that by hand; note that there is a function to convert
>> from coordinates to graph vertices.
>>
>> -- Jeremiah Willcock
>
> Hi Jeremiah,
>
> You mean there is something more "built in" than this: ?
>
> #include "boost/graph/adjacency_list.hpp"
> #include "boost/graph/simple_point.hpp"
>
> namespace boost {
> enum vertex_coordinate_t { vertex_coordinate };
> BOOST_INSTALL_PROPERTY(vertex, coordinate);
> };
>
> int main(int argc, char *argv[])
> {
> typedef boost::simple_point<float> PointType;
>
> typedef boost::adjacency_list<boost::vecS,
> boost::vecS,
> boost::undirectedS,
> boost::property<
> boost::vertex_coordinate_t, PointType >
> > Graph;
> Graph g;
>
> typedef typename boost::property_map<Graph,
> boost::vertex_coordinate_t>::type CoordinatePropertyMap;
> CoordinatePropertyMap coordinatePropertyMap =
> get(boost::vertex_coordinate, g);
>
> return 0;
> }
>
> (i.e. can you point me to the function you are talking about : ) ?)
You can just make a boost::array with the coordinates and call that a
vertex descriptor; that equivalence is used often enough that it probably
needs to stay stable.
> Also, the reason I am not using boost::grid_graph is that there are
> "holes" in my graph - i.e. not every integer coordinate has a vertex.
> Does the coordinate-to-vertex_descriptor function you are talking
> about handle the case when a vertex doesn't exist at the specified
> coordinate?
If you use a filtered_graph on top of the grid_graph, the trick I
mentioned above will work, but you'd want to check the filter condition on
the coordinates before using them in the filtered_graph.
-- Jeremiah Willcock
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