In nutshell: how can I check whether a property map has some given
The exact problem is as follows. I have graph edges with the property
"lambdas" of positive integers, but its the exact meaning is not
important here. With the read_graphviz function I am loading graph
files which look like this:
c -- a [distance="100"];
a -- b [lambdas="8"];
After I load the file I want to examine which edges have the "lambdas"
property, but I don't know how to do this. If I request the property
value with the "get" function, I get some random value. My program is
at the bottom of this email.
The program prints the edge and the value of the "lambdas" property.
I get this:
The first line is bad: the edge (2,0), i.e. c -- a in my graphviz
file, has the reported value of 33489268. The second line is OK.
>>In nutshell: how can I check whether a property map has some given
> Some property maps may provide bounds checking, but the property map
> concept doesn't require it, so in general you can't.
Good to know. I didn't find this in the property map documentation.
> I think you'll need to give every edge a lambda number, but you
> might reserve a special value to indicate that the lambda property
> isn't applicable to that edge.
I had the class def_int as the type of the lambda property:
In this way if a link doesn't have this property, then the property
map has -1 for that edge. The problem is that I needed to define
operators =, <, <<, >> to make it work. Then I wanted to use some
other stuff and got cryptic error messages at compilation.
Finally I dropped the def_int class in favor of the int type, and now
I make sure that every link in the .dot file has a lambdas property.
Irek Szczesniak wrote:
> In nutshell: how can I check whether a property map has some given
One way which may work for you is to use optional<value> as the actual
value_type of the map.
That way, your map can just return an absent optional if there is no value
associated with a key.