Ron,

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.

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.

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.

--Brian

On 9/18/07, Ronald Garcia <garcia@cs.indiana.edu> wrote:
Hi Brian,

I can see from your code snippet how your are reading the graph in.  Could you show the code for how  you are writing the graph out?
I'm not sure if the interface has changed since 1.33.1, but with the version in CVS, you can pass along the dynamic_properties object and the name of the property to use for vertex names in order to get the same graph out:

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



HTH,
ron

On Sep 17, 2007, at 1:45 PM, Brian Stadler wrote:

Good observation.  I see exactly what it's doing now.

However, this is still a bug.  If one is using dot language files across different programs then the parser needs to interpret it the same.  Though the graph may retain its overall structure, the structure for that individual vertex has now changed.  This will adversely affect the way algorithms make entree into the graph.  For example, if vertex 0 once had a degree of two and now has a degree of 3 than the choices to move from 0 have changed from two choices to three.

thanks again for the response!

On 9/17/07, Krishna Roskin < krish@soe.ucsc.edu> wrote:
On 9/14/07, Brian Stadler < bdotstadler@gmail.com> wrote:
> 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 ;
> }


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users