How to prevent the subgraph cluster alignment order from being reversed?

Hi,

let’s say we have this dot graph

digraph g {
rankdir=TB
subgraph {
style=invis
a b c d
}
}

I have the expected ( dot layout ) result: a b c d

If we have a subgraph cluster :

digraph g {
rankdir=TB
subgraph cluster_0 {
style=invis
a b c d
}
}

Then I have : d c b a

What caused this to happen?
Is it possible to prevent this?

Of course, one can rewrite the graph with inverse order but I would like to avoid this solution.

Thanks.

This is a good question. It’s been a long, long time since I’ve looked at this code. The intent should be to preserve the input order of nodes, per your question.

It’s not obvious where the bug is. Wonder if it relates to the implementation of union_find for collapsing clusters, and the implementation of build_ranks called from expand_cluster. I’ll look at this a little further. There are a lot of latent semantics in the way lists are built that could have been made more explicit.

1 Like

I just opened another topic on the forum about clustering.

Since you mentioned “the implementation of build_ranks called from expand_cluster”, maybe there is a link…