I have two questions: 1) I am trying to iterate through the edges of a graph and output their edge weights. I am confused though. I know how to output the "edges", but they are actually just a (vertex, vertex) pair which defines the edge. So do I index *edgePair.first into the EdgeWeightMap to get the weight of the edge starting from vertex *edgePair.first? Or how else would I get the weight associated with a particular edge? Code snippet: http://stackoverflow.com/questions/4810589/output-bgl-edge-weights 2) I have created a struct, and used it as a template parameter to adjacency_list. However, when I try to add_edge(vertex1, vertex2, property, graph) , the compiler complains "no matching function call". Can anyone see where I've gone wrong? Code snippet: http://stackoverflow.com/questions/4810235/bgl-bundled-properties-add-edge-n... Any suggestions on either of these? Thanks, David
On Thursday, 27. January 2011 14:23:45 David Doria wrote:
I have two questions:
1) I am trying to iterate through the edges of a graph and output their edge weights. I am confused though. I know how to output the "edges", but they are actually just a (vertex, vertex) pair which defines the edge. So do I index *edgePair.first into the EdgeWeightMap to get the weight of the edge starting from vertex *edgePair.first? Or how else would I get the weight associated with a particular edge?
Code snippet: http://stackoverflow.com/questions/4810589/output-bgl-edge-weights
2) I have created a struct, and used it as a template parameter to adjacency_list. However, when I try to add_edge(vertex1, vertex2, property, graph) , the compiler complains "no matching function call". Can anyone see where I've gone wrong?
Code snippet: http://stackoverflow.com/questions/4810235/bgl-bundled-properties-add-edge- no-matching-function
Any suggestions on either of these?
You need to specify the vertex properties as empty (something like "no_property" IIRC). You did specify the edge weight as the parameter of the VertexProperties, but it should look like this: adjacency_list<OutEdgeList, VertexList, Directed, VertexProperties, EdgeProperties, GraphProperties, EdgeList> The g++-4.3.4 output contains something like "Value = boost::detail::error_property_not_found" which tells you that some property was not available while you tried to access it.
Thanks,
David _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Best, Cedric
You need to specify the vertex properties as empty (something like "no_property" IIRC). You did specify the edge weight as the parameter of the VertexProperties, but it should look like this: adjacency_list<OutEdgeList, VertexList, Directed, VertexProperties, EdgeProperties, GraphProperties, EdgeList>
The g++-4.3.4 output contains something like "Value = boost::detail::error_property_not_found" which tells you that some property was not available while you tried to access it.
Cedric, Ah, thanks. One problem was I was indeed trying to specify the edge property type in the template parameter for the vertex property type. Now I am trying to simply assign a property to a vertex. I have: typedef boost::property<boost::vertex_property_tag, double> VertexProperty; // a double property typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, VertexProperty> Graph; int main(int,char*[]) { // Create a graph object Graph g(3); boost::add_vertex(g); boost::property_map<Graph, VertexProperty>::type value = get(VertexProperty(), g); boost::put(value, 0, 1.2); } On the property_map call, I get an "error: invalid use of void expression" What is wrong with this? Thanks for your help so far, David
On Thu, 27 Jan 2011, David Doria wrote:
You need to specify the vertex properties as empty (something like "no_property" IIRC). You did specify the edge weight as the parameter of the VertexProperties, but it should look like this: adjacency_list<OutEdgeList, VertexList, Directed, VertexProperties, EdgeProperties, GraphProperties, EdgeList>
The g++-4.3.4 output contains something like "Value = boost::detail::error_property_not_found" which tells you that some property was not available while you tried to access it.
Cedric,
Ah, thanks. One problem was I was indeed trying to specify the edge property type in the template parameter for the vertex property type.
Now I am trying to simply assign a property to a vertex. I have:
typedef boost::property<boost::vertex_property_tag, double> VertexProperty; // a double property typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, VertexProperty> Graph;
int main(int,char*[]) { // Create a graph object Graph g(3);
boost::add_vertex(g); boost::property_map<Graph, VertexProperty>::type value = get(VertexProperty(), g); boost::put(value, 0, 1.2); }
On the property_map call, I get an "error: invalid use of void expression"
In property_map<> and get(), you need to use the property name (here "boost::vertex_property" IIRC) rather than the full property specification (property<>, which might actually be a list of properties). -- Jeremiah Willcock
On Thu, Jan 27, 2011 at 1:25 PM, Jeremiah Willcock <jewillco@osl.iu.edu> wrote:
On Thu, 27 Jan 2011, David Doria wrote:
You need to specify the vertex properties as empty (something like "no_property" IIRC). You did specify the edge weight as the parameter of the VertexProperties, but it should look like this: adjacency_list<OutEdgeList, VertexList, Directed, VertexProperties, EdgeProperties, GraphProperties, EdgeList>
After nearly a fully day of searching/experimenting, I think I figured everything out. I have summarized what I have learned in a small set of examples in the BGL section here: http://programmingexamples.net/index.php?title=Boost I would highly suggest these be absorbed into the official BGL examples. David
On Thu, 27 Jan 2011, David Doria wrote:
I have two questions:
1) I am trying to iterate through the edges of a graph and output their edge weights. I am confused though. I know how to output the "edges", but they are actually just a (vertex, vertex) pair which defines the edge. So do I index *edgePair.first into the EdgeWeightMap to get the weight of the edge starting from vertex *edgePair.first? Or how else would I get the weight associated with a particular edge?
Code snippet: http://stackoverflow.com/questions/4810589/output-bgl-edge-weights
2) I have created a struct, and used it as a template parameter to adjacency_list. However, when I try to add_edge(vertex1, vertex2, property, graph) , the compiler complains "no matching function call". Can anyone see where I've gone wrong?
Code snippet: http://stackoverflow.com/questions/4810235/bgl-bundled-properties-add-edge-n...
Any suggestions on either of these?
I just answered both on StackOverflow; the issue is, as the later posts say, using an edge property in the VertexProperty slot of the adjacency_list template parameter list. -- Jeremiah Willcock
participants (3)
-
Cedric Laczny
-
David Doria
-
Jeremiah Willcock