graph: PropertyMap needs lvalue for vertex_index

Hi, I've been playing arround with boost::graph (and the layout algorithms in special). Now I encountered a little problem, I'm trying to get Kamada Kawai Spring to work, but I do get an compile error when calling put for vertex_index. So, this problem has nothing to do with KKS. My Code: typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, // Vertex properties boost::property<boost::vertex_index_t, int, boost::property<vertex_position_t, point> > // Edge properties ,boost::property<boost::edge_weight_t, double>
Graph;
Graph g(scene->getNodeCount()); boost::graph_traits<Graph>::vertex_iterator vi,vi_end; int i = 0; for (boost::tie(vi, vi_end) = boost::vertices(g); vi != vi_end; ++vi) boost::put(boost::vertex_index, g, *vi, i++); put throws now a compile Error: ..\..\..\cpp\boost_1_43/boost/property_map/property_map.hpp:361: error: lvalue required as left operand of assignment The last argument of put does throw this error. I expected the code to work, as I have copied it out of the layout_tests file: http://www.boost.org/doc/libs/1_43_0/libs/graph/test/layout_test.cpp So, where is my error here? I tried some different versions and some casts, but none made this code work. And I don't think that something that trivial is broken in the testcases. regards, Jens Weller -- GRATIS: Spider-Man 1-3 sowie 300 weitere Videos! Jetzt freischalten! http://portal.gmx.net/de/go/maxdome

On Tue, 21 Sep 2010, Jens Weller wrote:
Hi,
I've been playing arround with boost::graph (and the layout algorithms in special). Now I encountered a little problem, I'm trying to get Kamada Kawai Spring to work, but I do get an compile error when calling put for vertex_index. So, this problem has nothing to do with KKS.
My Code: typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, // Vertex properties boost::property<boost::vertex_index_t, int, boost::property<vertex_position_t, point> > // Edge properties ,boost::property<boost::edge_weight_t, double>
Graph;
Graph g(scene->getNodeCount()); boost::graph_traits<Graph>::vertex_iterator vi,vi_end; int i = 0; for (boost::tie(vi, vi_end) = boost::vertices(g); vi != vi_end; ++vi) boost::put(boost::vertex_index, g, *vi, i++);
put throws now a compile Error: ..\..\..\cpp\boost_1_43/boost/property_map/property_map.hpp:361: error: lvalue required as left operand of assignment
The last argument of put does throw this error. I expected the code to work, as I have copied it out of the layout_tests file: http://www.boost.org/doc/libs/1_43_0/libs/graph/test/layout_test.cpp
So, where is my error here? I tried some different versions and some casts, but none made this code work. And I don't think that something that trivial is broken in the testcases.
An adjacency_list with vecS as the vertex container already contains a built-in, read-only vertex_index map. It is filled in correctly, so you should not need to modify it. -- Jeremiah Willcock

On Tue, 21 Sep 2010, Jens Weller wrote:
Hi,
I've been playing arround with boost::graph (and the layout algorithms in special). Now I encountered a little problem, I'm trying to get Kamada Kawai Spring to work, but I do get an compile error when calling put for vertex_index. So, this problem has nothing to do with KKS.
My Code: typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, // Vertex properties boost::property<boost::vertex_index_t, int, boost::property<vertex_position_t, point> > // Edge properties ,boost::property<boost::edge_weight_t, double>
Graph;
Graph g(scene->getNodeCount()); boost::graph_traits<Graph>::vertex_iterator vi,vi_end; int i = 0; for (boost::tie(vi, vi_end) = boost::vertices(g); vi != vi_end; ++vi) boost::put(boost::vertex_index, g, *vi, i++);
put throws now a compile Error: ..\..\..\cpp\boost_1_43/boost/property_map/property_map.hpp:361: error: lvalue required as left operand of assignment
The last argument of put does throw this error. I expected the code to work, as I have copied it out of the layout_tests file: http://www.boost.org/doc/libs/1_43_0/libs/graph/test/layout_test.cpp
So, where is my error here? I tried some different versions and some casts, but none made this code work. And I don't think that something that trivial is broken in the testcases.
An adjacency_list with vecS as the vertex container already contains a built-in, read-only vertex_index map. It is filled in correctly, so you should not need to modify it.
Ah, yes, thats infact one of the few differences, I decided to use vecS instead of listS. Would be listS better? Also I then have the question, why Kamada Kawai Spring fails in my case: template<class Graph> bool doKamadaKawaiSpring(Graph& g, double radius) { // this call works circle_graph_layout(g, boost::get(vertex_position, g), radius/2); //returns false; return kamada_kawai_spring_layout(g, boost::get(vertex_position, g), boost::get(boost::edge_weight, g), boost::square_topology<>(radius * 2.0), boost::side_length(radius * 2.0)); } called from: Graph g(scene->getNodeCount()); boost::graph_traits<Graph>::edge_descriptor ed; for(size_t i =0,s = edges.size(); i < s; ++i) { ed = boost::add_edge(edges[i].first,edges[i].second,g).first; boost::put(boost::edge_weight, g, ed, 1.0); } if(!doKamadaKawaiSpring(g,std::min(ui->graphicsView->height()/2-20.0,ui->graphicsView->width()/2-20.0))) QMessageBox::about(this,"Layout Failed","could not calculate Kamanda Kawai Spring Layout fully"); All I know is it returns false. Documentation says:
Returns: true if layout was successful or false if a negative weight cycle was detected or the graph is disconnected.
so, what can I do to get this working? My Current Graph: A -> B A -> C A -> D B -> C B -> D maybe the Graph is wrong ;) regards, Jens Weller D -> E -- GMX DSL SOMMER-SPECIAL: Surf & Phone Flat 16.000 für nur 19,99 Euro/mtl.!* http://portal.gmx.net/de/go/dsl
participants (2)
-
Jens Weller
-
Jeremiah Willcock