graph = AGraph(strict = False, directed = True)# Set the style attributes of the graphgraph.node_attr['style']='rounded'graph.node_attr['shape']='box'graph.node_attr['fixedsize']='false'graph.node_attr['labelloc']='c'graph.node_attr['fontname']='times'graph.node_attr['fontcolor']='purple'
key_str = destination_port+"_"+source_port# Get the data from the dictionary and work on ingraph.add_edge(source,destination,key=key_str,dir='both',taillabel=destination_port,headlabel=source_port,style='bold',color='blue')
graph { node [fixedsize=false, fontcolor=red, fontname=times, label="\N", labelloc=c, shape=box, style=rounded ]; r1_re [fontcolor=purple, label=r1_re]; r2_re0 [label=r2_re0]; r1_re -- r2_re0 [key="abc_def", color=blue, dir=both, headlabel="abc", style=bold, taillabel="xyz"];}
graph { node [fixedsize=false, fontcolor=red, fontname=times, label="\N", labelloc=c, shape=box, style=rounded ]; r1_re [fontcolor=purple, label=r1_re]; r2_re0 [label=r2_re0]; r1_re -- r2_re0 [key="abc_def", color=blue, dir=both, headlabel="abc", style=bold, taillabel="def"]; r1_re -- r2_re0 [key="abc_xyz", color=blue, dir=both, headlabel="abc", style=bold, taillabel="xyz"];}
It could be a bug. But your example isn't complete which makes it harder to tell. Could you post a complete example? Aric
--
You received this message because you are subscribed to the Google Groups "pygraphviz-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pygraphviz-disc...@googlegroups.com.
To post to this group, send email to pygraphvi...@googlegroups.com.
Visit this group at http://groups.google.com/group/pygraphviz-discuss.
For more options, visit https://groups.google.com/d/optout.
from pygraphviz import *
G=AGraph(strict=False)G.add_edge('a','b','first')G.add_edge('a','b','second')sorted(G.edges(keys=True))print G.strictprint G.is_strict()G.write("graph.dot")
graph {
a -- b [key=first];}
Then maybe it is an installation issue. Do the tests run and pass? Aric
python -c "import pygraphviz; pygraphviz.test()"
Running PyGraphiz tests:FF....FF................F..............................F..............F.FF...F......
======================================================================
FAIL: pygraphviz.tests.test_attribute_defaults.test_default_attributes
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/Library/Python/2.7/site-packages/pygraphviz/tests/test_attribute_defaults.py", line 22, in test_default_attributes
""".replace('\n', linesep))
AssertionError: u'strict graph {\n graph [label=test, spam=eggs];\n}\n' != u'strict graph {\n graph [label=test,\n spam=eggs\n ];\n}\n'
strict graph {
- graph [label=test, spam=eggs];
? ------------
+ graph [label=test,
+ spam=eggs
+ ];
}
======================================================================
FAIL: pygraphviz.tests.test_attribute_defaults.test_graph_defaults
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/Library/Python/2.7/site-packages/pygraphviz/tests/test_attribute_defaults.py", line 47, in test_graph_defaults
""".replace('\n', linesep))
AssertionError: u'strict graph {\n graph [pack=true, rankdir=LR];\n}\n' != u'strict graph {\n graph [pack=true,\n rankdir=LR\n ];\n}\n'
strict graph {
- graph [pack=true, rankdir=LR];
? -------------
+ graph [pack=true,
+ rankdir=LR
+ ];
}
======================================================================
FAIL: pygraphviz.tests.test_edge_attributes.test_edge_attributes
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/Library/Python/2.7/site-packages/pygraphviz/tests/test_edge_attributes.py", line 15, in test_edge_attributes
""".replace('\n', linesep)
AssertionError: u'strict graph {\n 1 -- 2 [label=test, spam=eggs];\n}\n' != u'strict graph {\n 1 -- 2 [label=test,\n spam=eggs];\n}\n'
strict graph {
- 1 -- 2 [label=test, spam=eggs];
? ------------
+ 1 -- 2 [label=test,
? ++
+ spam=eggs];
}
======================================================================
FAIL: pygraphviz.tests.test_edge_attributes.test_edge_attributes2
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/Library/Python/2.7/site-packages/pygraphviz/tests/test_edge_attributes.py", line 32, in test_edge_attributes2
""".replace('\n', linesep)
AssertionError: u'strict graph {\n 1 -- 2 [label=test, spam=eggs];\n}\n' != u'strict graph {\n 1 -- 2 [label=test,\n spam=eggs];\n}\n'
strict graph {
- 1 -- 2 [label=test, spam=eggs];
? ------------
+ 1 -- 2 [label=test,
? ++
+ spam=eggs];
}
======================================================================
FAIL: pygraphviz.tests.test_graph.TestDiGraphOnly.test_graph_not_strict
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/Library/Python/2.7/site-packages/pygraphviz/tests/test_graph.py", line 262, in test_graph_not_strict
[('1', '2'), ('1', '2'), ('3', '3'), ('3', '3')])
AssertionError: Lists differ: [(u'1', u'2'), (u'1', u'2'), (... != [(u'1', u'2'), (u'1', u'2'), (...
Second list contains 1 additional elements.
First extra element 3:
(u'3', u'3')
- [(u'1', u'2'), (u'1', u'2'), (u'3', u'3')]
+ [(u'1', u'2'), (u'1', u'2'), (u'3', u'3'), (u'3', u'3')]
? ++++++++++++++
======================================================================
FAIL: pygraphviz.tests.test_graph.TestGraph.test_graph_not_strict
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/Library/Python/2.7/site-packages/pygraphviz/tests/test_graph.py", line 262, in test_graph_not_strict
[('1', '2'), ('1', '2'), ('3', '3'), ('3', '3')])
AssertionError: Lists differ: [(u'1', u'2'), (u'1', u'2'), (... != [(u'1', u'2'), (u'1', u'2'), (...
Second list contains 1 additional elements.
First extra element 3:
(u'3', u'3')
- [(u'1', u'2'), (u'1', u'2'), (u'3', u'3')]
+ [(u'1', u'2'), (u'1', u'2'), (u'3', u'3'), (u'3', u'3')]
? ++++++++++++++
======================================================================
FAIL: pygraphviz.tests.test_html.test_html
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/Library/Python/2.7/site-packages/pygraphviz/tests/test_html.py", line 23, in test_html
""".replace('\n', linesep))
AssertionError: u'strict graph {\n graph [label=<Hello<BR/>Graph>];\n node [label="\\N"];\n {\n graph [label=<Hello<BR/>Subgraph>];\n sa [label=<Hello<BR/>Subgraph Node b>];\n }\n a [label=<Hello<BR/>Node>];\n a -- b [label=<Hello<BR/>Edge>];\n}\n' != 'strict graph {\n graph [label=<Hello<BR/>Graph>];\n node [label="\\N"];\n {\n graph [label=<Hello<BR/>Subgraph>];\n sa [label=<Hello<BR/>Subgraph Node b>];\n }\n a [label=<Hello<BR/>Node>];\n a -- b [label=<Hello<BR/>Edge>];\n}\n'
======================================================================
FAIL: pygraphviz.tests.test_node_attributes.test_node_attribute
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/Library/Python/2.7/site-packages/pygraphviz/tests/test_node_attributes.py", line 16, in test_node_attribute
""".replace('\n', linesep))
AssertionError: u'strict graph {\n node [label="\\N"];\n 1 [label=test, spam=eggs];\n}\n' != u'strict graph {\n node [label="\\N"];\n 1 [label=test,\n spam=eggs];\n}\n [truncated]...
strict graph {
node [label="\N"];
- 1 [label=test, spam=eggs];
+ 1 [label=test,
+ spam=eggs];
}
======================================================================
FAIL: pygraphviz.tests.test_node_attributes.test_node_attributes2
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/Library/Python/2.7/site-packages/pygraphviz/tests/test_node_attributes.py", line 33, in test_node_attributes2
""".replace('\n', linesep)
AssertionError: u'strict graph {\n node [label="\\N"];\n 1 [label=test, spam=eggs];\n}\n' != u'strict graph {\n node [label="\\N"];\n 1 [label=test,\n spam=eggs];\n}\n [truncated]...
strict graph {
node [label="\N"];
- 1 [label=test, spam=eggs];
+ 1 [label=test,
+ spam=eggs];
}
======================================================================
FAIL: pygraphviz.tests.test_string.test_string_representation_large
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/Library/Python/2.7/site-packages/pygraphviz/tests/test_string.py", line 49, in test_string_representation_large
""".replace('\n', linesep))
AssertionError: u'strict graph "test graph" {\n 11;\n 1 -- 2;\n 2 -- 3;\n 3 -- 4;\n 4 -- 5;\n 5 -- 6;\n 6 -- 7;\n 7 -- 8;\n 8 -- 9;\n 9 -- 10;\n}\n' != 'strict graph "test graph" {\n 1 -- 2;\n 2 -- 3;\n 3 -- 4;\n 4 -- 5;\n 5 -- 6;\n 6 -- 7;\n 7 -- 8;\n 8 -- 9;\n 9 -- 10;\n 11;\n}\n'
----------------------------------------------------------------------
Ran 84 tests in 0.459s
FAILED (failures=10)
library_dirs='/usr/local/lib/graphviz'
include_dirs='/usr/local/include/graphviz'