Boost logo

Boost Users :

From: Jeffrey Holle (jeff.holle_at_[hidden])
Date: 2004-11-16 11:49:21


First, you have not succeeded in giving your graph any properties,
either vertex or edge.

Something like this would do the trick for edge properties:
   enum edge_Datum_t { edge_Datum };
   namespace boost {
     BOOST_INSTALL_PROPERTY(edge,Datum);
   }
   typedef std::pair<int,int> IntPair;
   typedef property<edge_Datum_t,IntPair> EdgeProperty;
   typedef adjacency_list<vectS,
                          vecS,
                          undirectedS,
                          property<boost::vertex_index_t, int>,
                          EdgeProperty> Graph;

Second, I'm not sure about your algorithm's needs, wheither you need
edge or vertex properties.

Third, you need to add referenced vertices before edges.
Not doing so would result in an exception.

Andrew Chapman wrote:
> Hi everyone, I've got a fairly simple use for boost::graph, and I've
> been trying to get it working, but the documentation, whilst thorough,
> isn't being too helpful in getting me started.
>
> What I'm trying to do, is build a graph of polygon mesh edges, which are
> simply pairs of unsigned ints. I need to find contiguous edge lists.
> Here's the setup code:
>
> // setup graph
> typedef std::pair<int, int> Edge;
> typedef adjacency_list<vecS, vecS, undirectedS> Graph;
> Graph g;
>
> // add an edge
> add_edge(6,7, g);
>
> cout << "Total number of vertices: " << num_vertices(g) << endl;
>
> Which then outputs that I have 8 vertices in my graph (0 through 7),
> instead of just the one I've added. So, it appears that the vertex list
> is automatically managed to be contiguous.
>
> Should I instead be adding all my edges, not caring about their vertex
> index, and adding a per-vertex property to keep track of their
> associated polygon mesh vertex numbers?
>
> If so, then I presume my code for adding the edges becomes something
> like (only psuedo-code here):
>
> vertex_descriptor v1 = add_vertex(g);
> vertex_descriptor v2 = add_vertex(g);
> set_property(v1, MyIndexProperty, 6);
> set_property(v2, MyIndexProperty, 7);
> add_edge(v1,v2,g);
>
> ..instead of what I had:
>
> add_edge(6,7, g);
>
> Does that sound right?
>
> In that case, is there a quick way of locating vertex_descriptor in a
> graph based on a vertex property? Something like:
>
> find_vertex(g, MyIndexProperty, 6);
>
> Sorry for all the lack of understanding, but it is quite a simple thing
> I'm wanting to use the library for, and I'm finding the documentation
> quite overwhelming. I suppose it is intended for when you're using the
> graphs in a much more complex scenario.
>
> Thanks in advance for any tips.
>
> AC.


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