Boost logo

Boost Users :

From: Brian Stadler (bdotstadler_at_[hidden])
Date: 2007-09-19 22:29:50


Hello again,

I'm still not convinced boost is interpreting these file correctly. I
understand and agree that node id's are strings. I do not understand why
you think these graph files are a special case.

Answer me the following. Why is that when I process the following using the
dot binary that i get back a picture with the correct interpretation, but
when I read the same file using the boost library its interpretation is
skewed?

strict graph {
    0 -- 3;
    0 -- 4;
    1 -- 3;
    1 -- 4;
    2 -- 3;
    2 -- 4;
    3 -- 4;
}

On 9/19/07, Ronald Garcia <garcia_at_[hidden]> wrote:
>
> Hi Brian,
> On Sep 19, 2007, at 10:41 AM, Brian Stadler wrote:
>
>
> Code for writing is very simple. I dont use this code unless I am doing
> testing.
>
> ofstream fo(filename.c_str());
> write_graphviz(fo, [graph here]);
> fo.close();
>
>
>
> The function you speak of is listed on
> http://boost.org/libs/graph/doc/write-graphviz.html. It is included with
> 1.33.1.
>
>
> Based on my reading of the write_graphviz docs, it seems that the function
> that I suggested will get you the results that you want. Also, I should
> mention that you don't need to keep the dynamic_properties object around to
> get the vertex names. They are also available directly from the internal
> vertex_name property map of your graph. You could use one of the versions
> of write_graphviz that takes a VertexID argument instead.
>
> To be honest, I wish read_graphviz() did not require a dynamic properties
> object. If one wants to read a very simple dot file without any extra stuff
> then they basically have to create a fake dp object just to do this.
>
>
> Bear in mind that the graphs you are parsing with read_graphviz are a
> special case: The names of the vertices happen to be integral numbers. In
> general, graphviz graphs can have almost arbitrary string identifiers as
> node id's. Even though node id's do not have to be in quotes, they're still
> just character strings as far as the DOT language is concerned. I think
> that in the most common-cases:
> 1) the names of graph nodes are arbitrary strings (not integers)
> 2) the consumer of the DOT-specified graph cares about those names
>
> The dynamic_properties object at the least guarantees that you can
> associate the names of the vertices with the vertices that are created in
> your graph object. The problem that you have been having that you
> originally reported is that you were indeed losing the node name information
> (the string representations of integers) when you were writing out your
> graphs using write_graphviz. That information is preserved in the
> vertex_name property map that you passed along to dynamic_properties, and
> also in the dynamic_properties
>
>
>
> Quick note, I changed the dot files I was reading in from the original
> post to the following, which is the way the boost library outputs them.
>
> graph G {
> "0";
> "1";
> "2";
> "0" -- "1";
> "0" -- "2";
> "1" -- "2";
> }
>
> Vertices are quoted but boost is able to handle it correctly.
>
>
> This is actually a good demonstration of how graphviz node id's are really
> strings, not numbers. The version of the graph output by write_graphviz may
> be textually different (because of the addition of quotation marks), but as
> far as any DOT tool is concerned, it's the same graph.
>
> HTH,
> ron
>
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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