Attribute name bug

66 views
Skip to first unread message

Damien Gombault

unread,
Jul 22, 2009, 9:57:06 AM7/22/09
to pygraphviz-discuss
Hello.

I think I have found a bug in pygraphviz.
If you define a node or edge attribute after a graph attribute with
the same attribute name, the node or edge attribute is not taken into
account.

Small script to exhibit the problem :
import pygraphviz
import sys

graph = pygraphviz.AGraph()

graph.graph_attr['fontname'] = 'graph font'
graph.node_attr['fontname'] = 'node font'
graph.edge_attr['fontname'] = 'edge font'

print graph.graph_attr
print graph.node_attr
print graph.edge_attr

print
graph.write(sys.stdout)

You get:
{'fontname': 'edge font'}
{}
{}

strict graph {
graph [fontname="edge font"];

}

If you define the graph attributes after node and edge attributes, it
works as expected :
import pygraphviz
import sys

graph = pygraphviz.AGraph()

graph.node_attr['fontname'] = 'node font'
graph.edge_attr['fontname'] = 'edge font'
graph.graph_attr['fontname'] = 'graph font'

print graph.graph_attr
print graph.node_attr
print graph.edge_attr

print
graph.write(sys.stdout)

You get:
{'fontname': 'graph font'}
{'fontname': 'node font'}
{'fontname': 'edge font'}

strict graph {
graph [fontname="graph font"];
node [fontname="node font"];
edge [fontname="edge font"];

}

I use pygraphviz version 0.99.1.

Regards.
Damien Gombault

Aric Hagberg

unread,
Jul 22, 2009, 10:15:31 AM7/22/09
to pygraphvi...@googlegroups.com

Thanks for the report. I may well be a bug. Can you tell me
what version of graphviz you are using too? Unfortunately some
of these type of problems are related to issues in different graphviz
versions and can be much harder to track down without that information.

Aric

Damien Gombault

unread,
Jul 22, 2009, 10:55:08 AM7/22/09
to pygraphviz-discuss
I use graphviz version 2.24.0 (20090616.2323).
Reply all
Reply to author
Forward
0 new messages