5

I want to make a graph without overlapping edges. I am using python with the igraph libray. This is my code

import sys
import igraph
from igraph import *
import re

g = Graph([(1,2),(1,4),(1,7),(1,10),(1,12),(2,3),(2,4),(2,9),(3,4),(3,5),
(5,6)

layout = g.layout_reingold_tilford_circular()

plot(g, layout=layout)

And this is the result

enter image description here

but I want something like this

https://pbs.twimg.com/media/CM8r7sYUwAAEDy6.png

Any help about how I can do it in igraph? My graph is not a tree.

Thanks

3 Answers3

4

layout_reingold_tilford and layout_reingold_tilford_circular are tree layouts; they are meant for tree graphs. You are probably better off with layout_kamada_kawai() or layout_fruchterman_reingold().

Tamás
  • 47,239
  • 12
  • 105
  • 124
  • Hi !!! I tried with layout_kamada_kawai() and layout_fruchterman_reingold() but this was the result https://pbs.twimg.com/media/CNCgGiYUAAAhU-c.png and https://pbs.twimg.com/media/CNCgGa_UEAAVCvg.png Do you know what I can make to draw the graph without overlapping edges??? Thanks a lot – Daniela Fernandez Espinosa Aug 22 '15 at 20:24
  • If these algorithms did not work, you have to implement a planar graph layout algorithm on your own as igraph provides no algorithms that guarantee a planar layout for a planar graph. – Tamás Aug 24 '15 at 09:38
1

Using the option hovermost when plotting may help you

layout = h.layout("fruchterman_reingold")
igraph.plot(h, '2.png', layout=layout, bbox=(1000, 1000), margin=120, hovermode='closest')
B Furtado
  • 1,488
  • 3
  • 20
  • 34
0

I tried the hovermode but it's not within the igraph package. The only think helped a little bit is play with the size of the figure, or use tkplot for manual handling of the figure.