python-igraph icon indicating copy to clipboard operation
python-igraph copied to clipboard

sugiyama layout making up vertices

Open iosonofabio opened this issue 8 months ago • 1 comments

Describe the bug Sugiyama layout seems to have more coordinates than vertices, with the top ones being the actual good coords.

To reproduce

import random; import igraph as ig
random.seed(0)
g = ig.Graph.Erdos_Renyi(n=15, m=30, directed=False, loops=False)
g.to_directed(mode="acyclic")
g.vcount() -> 15
len(g.layout("sugiyama")) -> 35

This is from our own example ;-)

Not sure why this happens and how on Earth we did not notice before. I suspect our plotting infra has some filtering on singletons or some unwanted magic that hides this issue.

Unsure whether this would be C core or python interface.

Version information 0.11.8 from pip.

iosonofabio avatar May 31 '25 06:05 iosonofabio

This layout includes edge routing, which is encoded by adding extra dummy vertices. I pointed out many times that plotting infrastructure in high-level languages should be adapted to properly support edge routing, and this information should be returned in a more structured way than through dummy vertices.

https://igraph.org/c/html/latest/igraph-Layout.html#igraph_layout_sugiyama

The Sugiyama layout may introduce "bends" on the edges in order to obtain a visually more pleasing layout. This is achieved by adding dummy nodes to edges spanning more than one layer. The resulting layout assigns coordinates not only to the nodes of the original graph but also to the dummy nodes. The layout algorithm will also return the extended graph with the dummy nodes.

szhorvat avatar May 31 '25 09:05 szhorvat

This changed in 1.0.0 (see here) and the Python interface will follow suit in 1.0 so closing. (The change is already in the main branch).

ntamas avatar Oct 23 '25 10:10 ntamas