[pygraphviz] Attribute name bug

8 views
Skip to first unread message

Damien Gombault

unread,
Jul 22, 2009, 6:12:53 AM7/22/09
to networkx-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

Damien Gombault

unread,
Jul 22, 2009, 9:58:43 AM7/22/09
to networkx-discuss
Oops. There is a `pygraphviz-discuss` group.

Sorry for posting here.
Reply all
Reply to author
Forward
0 new messages