I'm working on a Python script which discovers all of the Cisco devices in a network, and am now looking to add an option that creates a diagram for the user.
I'm using the graphviz Python module and am still working on the code, but this is what it generates at this point in time:
graph {
graph [nodesep=1.5 ranksep=1]
edge [fontsize=10 weight=0.5]
"R3.lab"
"R3.lab" -- "R1.lab" [headlabel="Fa0/1" taillabel="Fa0/1"]
"R2.lab"
"R2.lab" -- "R1.lab" [headlabel="Fa3/0" taillabel="Fa3/0"]
"R2.lab"
"R2.lab" -- "R1.lab" [headlabel="Fa1/0" taillabel="Fa0/1"]
"R4.lab"
"R4.lab" -- "R1.lab" [headlabel="Fa4/0" taillabel="Fa4/0"]
"R2.lab"
"R2.lab" -- "R3.lab" [headlabel="Fa0/0" taillabel="Fa0/0"]
"R5.lab"
"R5.lab" -- "R3.lab" [headlabel="Fa4/0" taillabel="Fa3/0"]
"R4.lab"
"R4.lab" -- "R3.lab" [headlabel="Fa1/0" taillabel="Fa0/0"]
"R4.lab"
"R4.lab" -- "R2.lab" [headlabel="Fa1/0" taillabel="Fa1/0"]
"R4.lab"
"R4.lab" -- "R5.lab" [headlabel="Fa0/1" taillabel="Fa0/1"]
}
The problem is that some nodes' edge labels (e.g R4) overlap one another and it is difficult to see which label applies to which edge. This leads me to the question, how do I go about ensuring this overlap does not occur?
The solution would need to be dynamic (as opposed to only fixing it in this graph) so that it worked on other networks too.
Any suggestions would be greatly appreciated. Thank you.