Issues with Multiple edges between the same node

10 views
Skip to first unread message

Animesh Kumar

unread,
Jul 9, 2015, 10:53:09 PM7/9/15
to pygraphvi...@googlegroups.com
Hi,

I am trying to create a graph where multiple edges between two nodes are possible.

I am gone through various post in the forum and on the internet but none of the solutions work.


Here is the snippet of my code :-
graph = AGraph(strict = False, directed = True)
# Set the style attributes of the graph
graph.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 in
graph.add_edge(source,destination,key=key_str,dir='both',taillabel=destination_port,headlabel=source_port,style='bold',color='blue')


I need multiple edges between two nodes which can have different source and destination port. The source_port, destination_port combination is always unique.

The issue i am getting is that, when my dot file is generated, the tail label and the head labels of edge with old key gets replaced by the tail and head label of the new key.

Output achieved :
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"];
}





Desired Result :

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"];
}


What am I doing wrong here? Or what else should i do to get the desired result?
Reply all
Reply to author
Forward
0 new messages