I have the following toy graph that represents, for instance, a forum thread:
import igraph as ig
g = ig.Graph(n = 12, directed=True)
g.add_edges([(1,0),(2,1), (3,2), (4,3),
(5,1),
(6,2), (7,6), (8,7),
(9,0),
(10,0), (11,10)])
g.vs["label"] = ["A", "B", "A", "B", "C", "F", "C", "B", "D", "C", "D", "F"]
ig.plot(g, layout="kk")
However, there seems to be no layout that places the root vertex (id 0, label A) into the top and grows downwards.
Am I missing something?
OK, I'll just add this as an answer, for the comments.
So the Reingold-Tilford layout works: http://igraph.sourceforge.net/doc/python/igraph.Graph-class.html#layout_reingold_tilford
layout = g.layout_reingold_tilford(mode="in", root=[0])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With