dagrejs / dagre-d3

A D3-based renderer for Dagre
MIT License
2.84k stars 587 forks source link

Cluster node separation is different from node separation outside a cluster #334

Open aswinjohn opened 6 years ago

aswinjohn commented 6 years ago

Hello, I am having an issue with horizontal separation of nodes (between B and C) within and outside clusters.

CASE1: The node separation when nodes having the same rank are not within a cluster obeys the nodesep rules, and is nicely tight. See : https://jsfiddle.net/aswinjohn/2hmLuk6e/ nodes_outside_cluster

CASE2: However, if I embed the nodes within a cluster, the nodes are stretched to the extent of the cluster. This creates unattractive graphs if the cluster has many elements that stretch it out. See: https://jsfiddle.net/aswinjohn/rwzj4qea/4/ nodes_inside_cluster

Is there any solution for this, where I can get CASE1 behavior in CASE2, without creating additional clusters or changing the graph?

I also noticed that just adding nodes to a cluster changes the 'align' from 'UL' to 'DL' (rankdir=TB, default)? Unconnected nodes in CASE1 that seem to float to the top of graph (left to right on top row) now seems pushed to bottom of graph (left to right on bottom row), when within a cluster (CASE2).

Thank you for your time.

aswinjohn commented 6 years ago

Just a quick update: I was able to read up the papers on graph drawing and identified the cause to be changes in the BK algorithm, introduced in dagre. Specifically, the issue is caused by pass2 of horizontal compaction . This might not be an 'issue', but a 'feature' of dagre.

In any case, I prefer my graph to match 'graphviz dot', and removed pass2 function call in my version of dagre-d3 compiled code. Thanks.