Boost logo

Boost Users :

From: Aaron Windsor (aaron.windsor_at_[hidden])
Date: 2007-11-03 08:54:26


On 11/2/07, Ferng, Andrew D <andrew.d.ferng_at_[hidden]> wrote:
> Hi,
>
> I'm trying to use the concepts in the Kevin Bacon example in my code and
> am having trouble with compiling.
> http://www.boost.org/libs/graph/doc/kevin_bacon.html
>
> When I compiled the example by itself, it ran fine. However when I
> changed it to my data, then it gave me a compile error of "error C2106:
> '=' : left operand must be l-value"
>
> I don't know why this is, other than variable name, I just changed the
> vertex type from string to index. Nothing that I can see would cause
> this.
>
> The line not compiling is "grid_id[u] = gid;" See below for code.

<snip>

>
> Any ideas why this is? I'm confused as to what's causing this.
> Any other way to populate the property map?
>
> I'm using VS2005 and boost 1.33.1.

Hi Andrew,

Your code didn't show the type of graph you're using for
interfaceGraph, but I'm going to assume that it's an adjacency_list
using a std::vector to store the vertices. In that case, the vertex
index is populated automatically with the indices of each vertex
descriptor in the underlying vector, making the vertex index map
read-only. In other configurations (for example, using a std::list to
store the vertices) you can set the vertex index - in fact, you have
to initialize it yourself if you're going to use it.

The vertex index and edge index are used by most BGL algorithms to
create property maps from vertices and edges to arbitrary types, so
I'd recommend against using them for anything else (in your code,
you're using them to store a grid id and connecting element id). Check
out the documentation on bundled properties, which allow you to
augment graphs with arbitrary properties easily
(http://www.boost.org/libs/graph/doc/bundles.html).

Regards,
Aaron


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