Boost logo

Boost Users :

From: Krishna Roskin (krish_at_[hidden])
Date: 2007-09-17 03:38:02


On 9/14/07, Brian Stadler <bdotstadler_at_[hidden]> wrote:
> I'm reading in thousands of files in the graphviz language into a program
> using read_graphviz(), library version 1.33.1. I noticed a problem with
> some of my results and discovered that read_graphviz doesn't appear to be
> interpreting the files correctly. The structure of the graphs is preserved
> (no edges gone astray). However, the labeling of the nodes is changed. I
> confirmed this by reading in a file and immediately writing it back out
> using write_graphviz(). Below is the code used to read in the files. It's
> very simple as I have nothing special being reprsented. Could someone else
> check this and confirm this is a problem. I've checked the bugs list and
> 1.34.x release notes and found nothing addressing the particular issue.
>
> thanks all.
>
> My read_graphviz code:
>
> bool file;
> ifstream in(openfile.c_str(), ios::in);
> dynamic_properties dp;
> dp.property ("node_id", get(&ed_node::vertex_name, ug)); <--simple
> adjacency list with bundled properties being used
> file = read_graphviz(in, ug, dp, "node_id");
>
> Source graphviz file:
>
> strict graph {
> 0 -- 3;
> 0 -- 4;
> 1 -- 3;
> 1 -- 4;
> 2 -- 3;
> 2 -- 4;
> 3 -- 4;
> }
>
> Output graphviz file:
>
> graph G {
> 0;
> 1;
> 2;
> 3;
> 4;
> 0--1 ;
> 0--2 ;
> 3--1 ;
> 3--2 ;
> 4--1 ;
> 4--2 ;
> 1--2 ;
> }

It looks like read_graphviz just adds the vertices in the order they
appear in the graph. That's why they get the above vertex indices. My
code does this all the time so I just learned to live with it. If I
really care about the vertex names, I add them to the graphviz file
with [label="name"] and not count on the vertex index.

HTH,
-krish


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