Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which layout should I use to get non-overlapping edges in igraph in python?

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

like image 598
Daniela Fernandez Espinosa Avatar asked Aug 21 '15 17:08

Daniela Fernandez Espinosa


Video Answer


1 Answers

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().

like image 173
Tamás Avatar answered Nov 10 '22 18:11

Tamás