BGL Adding an Edge with Multiple Properties

I want all the ribs to have properties, weight and capacity. I found that BGL is already defined. Therefore, I define Edge and Vertex properties for Graph

 typedef property<vertex_name_t, string> VertexProperty;
 typedef property<edge_weight_t, int, property<edge_capacity_t, int> > EdgeProperty;
 typedef adjacency_list<listS,vecS, undirectedS, VertexProperty, EdgeProperty > Graph;

This is where I try to add edges to the graph:

172: EdgeProperty prop = (weight, capacity);
173: add_edge(vertex1,vertex2, prop, g);

If I had only 1 property, I know that it will be prop = 5; However, with the two, I am confused about formatting.

Here is the error I get:

graph.cc: In functionvoid con_graph()’:
graph.cc:172: warning: left-hand operand of comma has no effect
+5
source share
2 answers

boost:: property, , . , (weight, capacity), , , , EdgeProperty prop = EdgeProperty(weight, capacity); EdgeProperty prop(weight, capacity);. , , . , :

EdgeProperty prop = EdgeProperty(weight, property<edge_capacity_t, int>(capacity));

, . , - edge, :

EdgeProperty prop;
get_property_value(prop, edge_weight_t) = weight;
get_property_value(prop, edge_capacity_t) = capacity;

, boost:: property.

+6

:

EdgeProperty prop;
get_property_value(prop, edge_weight) = weight;
get_property_value(prop, edge_capacity) = capacity;
0

All Articles