Boost logo

Boost Users :

Subject: Re: [Boost-users] graph: PropertyMap needs lvalue for vertex_index
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2010-09-21 09:32:57


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net