Boost logo

Boost Users :

Subject: [Boost-users] [graph] Looks like there is a bug in some graph-writing function
From: Juan Antonio Farré Basurte (jafb_at_[hidden])
Date: 2009-03-17 11:24:14


Hi,

I was correctly reading graphs in graphml and graphviz.
Now I've added support for graph writing.
And now I get tons of
errors at the last line of my code (I mean symbol '}').

After looking carefully at them looks like there are two families of errors,
all of them related to property maps:

- Looks like property maps are being accessed for reading using operator[].
But if the
property map is backed by std::map, it's documented that operator[]
in fact does an insert in the map. This is not a problem when reading a
graph,
as the graph is mutable. But of course it is a problem when writing a const graph.
I get tons of errors about modifying read-only
locations and discarding qualifiers (const, of course).

- The other errors are about not finding a matching operator>>, also
related with properties.
In this case, it looks to be related with reading (and I think concretely graphviz), but I don't understand
why,
as it used to work before. May be this is a cryptic bug of my code.

I don't find clear information in the errors about what graph writing
function is causing the first family
of errors. I can attach compiler output, but I'm afraid messages are in Spanish :S
Moreover, I'm not
sure if it's correct to send attached files to the list.
If anybody wants me to send it, just ask.

By the way, I've found a minor
problem with graphviz writing.
I can't invoke the following template

template<typename Graph>
void
write_graphviz(std::ostream& out, const Graph& g,
     
         const dynamic_properties& dp,
               const std::string& node_id = "node_id");

just this way:

write_graphviz(out,g,dp,"name");

Looks like it gets confused with the following template:

template < typename VertexListGraph, typename VertexPropertyWriter,
           typename EdgePropertyWriter
>
void
write_graphviz(std::ostream& out, const VertexListGraph& g,
               VertexPropertyWriter vpw,
EdgePropertyWriter epw);

The workaround is easy:

write_graphviz(out,g,dp,string("name"));

But I find it a bit ugly.

Thanks,

Juan


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