[BGL] Basic graph construction

I was wondering if someone could give me a tip on how to construct the following graph. The problem is that the queue type definition does not know what "edge" is until the type definition for the graph is created. Is there a way to get around this? Thank you #include <boost/graph/adjacency_list.hpp> #include <queue> // Type definition for a priority queue of (double,edge) pairs typedef std::priority_queue<std::pair<double,int> > edge_queue; struct vertex_edge_priority_t { typedef vertex_property_tag kind; }; // Vertex properties: typedef property < vertex_edge_priority_t, edge_queue > domainVertexProperty; // Edge propeties: typedef property < edge_index_t, int, property < edge_weight_t, double > > domainEdgeProperty; // Graph used to represent possible vertices and edges within the domain. typedef adjacency_list< setS, vecS, undirectedS, domainVertexProperty, domainEdgeProperty > domainGraph; typedef graph_traits<domainGraph>::edge_descriptor edge;

Hi Alejandro, On 4/25/07, Alejandro Marcos Aragón <aaragon2@uiuc.edu> wrote:
I was wondering if someone could give me a tip on how to construct the following graph. The problem is that the queue type definition does not know what "edge" is until the type definition for the graph is created. Is there a way to get around this?
Yep, for this case there is the adjacency_list_traits class, which is only templated on EdgeList, VertexList and Directed. You may want to check http://www.boost.org/libs/graph/doc/adjacency_list_traits.html for more information.
// Type definition for a priority queue of (double,edge) pairs typedef std::priority_queue<std::pair<double,int> > edge_queue;
With the above this would read: typedef adjacency_list_traits< setS, vecS, undirectedS
::edge_descriptor edge_descriptor; typedef std::priority_queue< std::pair< double, edge_descriptor > > edge_queue;
HTH, Stephan

Stephan Diederich wrote:
Hi Alejandro,
On 4/25/07, Alejandro Marcos Aragón <aaragon2@uiuc.edu> wrote:
I was wondering if someone could give me a tip on how to construct the following graph. The problem is that the queue type definition does not know what "edge" is until the type definition for the graph is created. Is there a way to get around this?
Yep, for this case there is the adjacency_list_traits class, which is only templated on EdgeList, VertexList and Directed. You may want to check http://www.boost.org/libs/graph/doc/adjacency_list_traits.html for more information.
// Type definition for a priority queue of (double,edge) pairs typedef std::priority_queue<std::pair<double,int> > edge_queue;
With the above this would read: typedef adjacency_list_traits< setS, vecS, undirectedS
::edge_descriptor edge_descriptor; typedef std::priority_queue< std::pair< double, edge_descriptor > > edge_queue;
HTH, Stephan
Thanks for the help Stephan, I'll try that.
participants (2)
-
Alejandro Marcos Aragón
-
Stephan Diederich