Custom Edge Properties (boost-graph) - struct

Hi All , I've been trying to use a custom structure for describing the various edge properties of a graph. I'm defining a graph as the following struct edge_properties { int capacity ; double weight ; typedef struct edge_properties_tag kind ; // NOT SURE what this does ? }; typedef boost::adjacency_list<listS, vecS, bidirectionalS, property<vertex_name_t, std::string>, edge_properties > Graph; This allows me to create a Graph instance g. I've been trying to retrieve the edge properties via a get call, but have not been able to do so. To retrieve the vertex properties doing the following works property_map<Graph, vertex_name_t>::type v_names ; v_names = get(vertex_name,g) ; But on attempting to do something similar for retrieving the edge properties always fails with the following error message "test.cpp: 75: error: expected primary-expression before ',' token" test.cpp 71: property_map<Graph, edge_properties>::type epr; 72: property_map<Graph, vertex_name_t>::type v_names ; 74: v_names = get(vertex_name,g) ; 75: epr = get(edge_properties,g) ; I've tried various variants but seems to me i'm missing something fundamental in the way boost-graph keeps the edge_properties hidden. Any pointers will be useful. Thanks in advance

Hi All , I've been trying to use a custom structure for describing the various edge properties of a graph. I'm defining a graph as the following struct edge_properties { int capacity ; double weight ; typedef struct edge_properties_tag kind ; // NOT SURE what this does ? }; typedef boost::adjacency_list<listS, vecS, bidirectionalS, property<vertex_name_t, std::string>, edge_properties > Graph; This allows me to create a Graph instance g. I've been trying to retrieve the edge properties via a get call, but have not been able to do so. To retrieve the vertex properties doing the following works property_map<Graph, vertex_name_t>::type v_names ; v_names = get(vertex_name,g) ; But on attempting to do something similar for retrieving the edge properties always fails with the following error message "test.cpp: 75: error: expected primary-expression before ',' token" test.cpp 71: property_map<Graph, edge_properties>::type epr; 72: property_map<Graph, vertex_name_t>::type v_names ; 74: v_names = get(vertex_name,g) ; 75: epr = get(edge_properties,g) ; I've tried various variants but seems to me i'm missing something fundamental in the way boost-graph keeps the edge_properties hidden. Any pointers will be useful. Thanks in advance

AMDG Kya Bey wrote:
property_map<Graph, vertex_name_t>::type v_names ; v_names = get(vertex_name,g) ;
But on attempting to do something similar for retrieving the edge properties always fails with the following error message
"test.cpp: 75: error: expected primary-expression before ',' token"
test.cpp
71: property_map<Graph, edge_properties>::type epr; 72: property_map<Graph, vertex_name_t>::type v_names ;
74: v_names = get(vertex_name,g) ; 75: epr = get(edge_properties,g) ;
edge_properties appears to be a type, not an object here.
I've tried various variants but seems to me i'm missing something fundamental in the way boost-graph keeps the edge_properties hidden. Any pointers will be useful.
In Christ, Steven Watanabe

On Sun, 14 Mar 2010, Kya Bey wrote:
Hi All , I've been trying to use a custom structure for describing the various edge properties of a graph. I'm defining a graph as the following
struct edge_properties { int capacity ; double weight ; typedef struct edge_properties_tag kind ; // NOT SURE what this does ? };
typedef boost::adjacency_list<listS, vecS, bidirectionalS, property<vertex_name_t, std::string>, edge_properties > Graph;
This allows me to create a Graph instance g. I've been trying to retrieve the edge properties via a get call, but have not been able to do so.
It appears that you are trying to use bundled properties. There is information on using them at <URL:http://www.boost.org/doc/libs/1_42_0/libs/graph/doc/bundles.html>. You do not need the kind in your structure in that case.
I've tried various variants but seems to me i'm missing something fundamental in the way boost-graph keeps the edge_properties hidden. Any pointers will be useful.
The syntax you want is get(&edge_properties::capacity, g) to get the capacity, and something similar for the weight. -- Jeremiah Willcock

Thanks a lot for your pointers. It helped me a lot. I'm stuck at getting dijkstra's to work (posting in another thread) On Mon, Mar 15, 2010 at 9:21 AM, Jeremiah Willcock <jewillco@osl.iu.edu>wrote:
On Sun, 14 Mar 2010, Kya Bey wrote:
Hi All ,
I've been trying to use a custom structure for describing the various edge properties of a graph. I'm defining a graph as the following
struct edge_properties { int capacity ; double weight ; typedef struct edge_properties_tag kind ; // NOT SURE what this does ? };
typedef boost::adjacency_list<listS, vecS, bidirectionalS, property<vertex_name_t, std::string>, edge_properties > Graph;
This allows me to create a Graph instance g. I've been trying to retrieve the edge properties via a get call, but have not been able to do so.
It appears that you are trying to use bundled properties. There is information on using them at <URL: http://www.boost.org/doc/libs/1_42_0/libs/graph/doc/bundles.html>. You do not need the kind in your structure in that case.
I've tried various variants but seems to me i'm missing something
fundamental in the way boost-graph keeps the edge_properties hidden. Any pointers will be useful.
The syntax you want is get(&edge_properties::capacity, g) to get the capacity, and something similar for the weight.
-- Jeremiah Willcock _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Jeremiah Willcock
-
Kya Bey
-
Steven Watanabe