dagrejs / dagre-d3

A D3-based renderer for Dagre
MIT License
2.85k stars 590 forks source link

Weird-looking layout #108

Open martint opened 10 years ago

martint commented 10 years ago

For a graph with the following shape:

digraph G {
"0.0";
"0.1";
"0.2";
"0.3";
"1.0";
"1.1";
"1.2";
"1.3";
"2.0";
"2.1";
"2.2";
"2.3";
"3.0";
"3.1";
"3.2";
"3.3";
"1.0"->"0.0";
"1.1"->"0.0";
"1.2"->"0.0";
"1.3"->"0.0";
"1.0"->"0.1";
"1.1"->"0.1";
"1.2"->"0.1";
"1.3"->"0.1";
"1.0"->"0.2";
"1.1"->"0.2";
"1.2"->"0.2";
"1.3"->"0.2";
"1.0"->"0.3";
"1.1"->"0.3";
"1.2"->"0.3";
"1.3"->"0.3";
"2.0"->"1.0";
"2.1"->"1.0";
"2.2"->"1.0";
"2.3"->"1.0";
"2.0"->"1.1";
"2.1"->"1.1";
"2.2"->"1.1";
"2.3"->"1.1";
"2.0"->"1.2";
"2.1"->"1.2";
"2.2"->"1.2";
"2.3"->"1.2";
"2.0"->"1.3";
"2.1"->"1.3";
"2.2"->"1.3";
"2.3"->"1.3";
"3.0"->"2.0";
"3.1"->"2.0";
"3.2"->"2.0";
"3.3"->"2.0";
"3.0"->"2.1";
"3.1"->"2.1";
"3.2"->"2.1";
"3.3"->"2.1";
"3.0"->"2.2";
"3.1"->"2.2";
"3.2"->"2.2";
"3.3"->"2.2";
"3.0"->"2.3";
"3.1"->"2.3";
"3.2"->"2.3";
"3.3"->"2.3";
} 

graphviz produces this layout: graphviz

while dagre produces this one: dagre

Is this expected? Is there any way to force dagre to produce something closer to graphviz for this case?

hongtaobai commented 10 years ago

I had similar problems when using dagre. I’d love to have some option to make the layout looks nicer.

From: Martin Traverso [mailto:notifications@github.com] Sent: Wednesday, October 29, 2014 9:11 PM To: cpettitt/dagre-d3 Subject: [dagre-d3] Weird-looking layout (#108)

For a graph with the following shape:

digraph G { "0.0"; "0.1"; "0.2"; "0.3"; "1.0"; "1.1"; "1.2"; "1.3"; "2.0"; "2.1"; "2.2"; "2.3"; "3.0"; "3.1"; "3.2"; "3.3"; "1.0"->"0.0"; "1.1"->"0.0"; "1.2"->"0.0"; "1.3"->"0.0"; "1.0"->"0.1"; "1.1"->"0.1"; "1.2"->"0.1"; "1.3"->"0.1"; "1.0"->"0.2"; "1.1"->"0.2"; "1.2"->"0.2"; "1.3"->"0.2"; "1.0"->"0.3"; "1.1"->"0.3"; "1.2"->"0.3"; "1.3"->"0.3"; "2.0"->"1.0"; "2.1"->"1.0"; "2.2"->"1.0"; "2.3"->"1.0"; "2.0"->"1.1"; "2.1"->"1.1"; "2.2"->"1.1"; "2.3"->"1.1"; "2.0"->"1.2"; "2.1"->"1.2"; "2.2"->"1.2"; "2.3"->"1.2"; "2.0"->"1.3"; "2.1"->"1.3"; "2.2"->"1.3"; "2.3"->"1.3"; "3.0"->"2.0"; "3.1"->"2.0"; "3.2"->"2.0"; "3.3"->"2.0"; "3.0"->"2.1"; "3.1"->"2.1"; "3.2"->"2.1"; "3.3"->"2.1"; "3.0"->"2.2"; "3.1"->"2.2"; "3.2"->"2.2"; "3.3"->"2.2"; "3.0"->"2.3"; "3.1"->"2.3"; "3.2"->"2.3"; "3.3"->"2.3"; }

graphviz produces this layout: https://cloud.githubusercontent.com/assets/14387/4838489/41b0cda6-5fea-11e4-907b-d37337c626ec.png

while dagre produces this one: https://cloud.githubusercontent.com/assets/14387/4838492/571f86d2-5fea-11e4-9997-7b0c65ddbd70.png

Is this expected? Is there any way to force dagre to produce something closer to graphviz for this case?

— Reply to this email directly or view it on GitHub https://github.com/cpettitt/dagre-d3/issues/108 . https://github.com/notifications/beacon/AHCd_yzwMcQlsrxory4UWLKwadkXx4Yaks5nIbG3gaJpZM4C0vKE.gif

keeper3000 commented 9 years ago

I'm new to Dagre myself, but did you try these properties?

graph nodesep 50 Number of pixels that separate nodes horizontally in the layout. graph edgesep 10 Number of pixels that separate edges horizontally in the layout. graph ranksep 50 Number of pixels between each rank in the layout.

cpettitt commented 6 years ago

A somewhat simplified example of the ever expanding split, for debugging purposes:

https://dagrejs.github.io/project/dagre-d3/latest/demo/interactive-demo.html?graph=digraph%20G%20%7B%0Aa%20-%3E%20d%0Aa%20-%3E%20e%0Ab%20-%3E%20d%0Ab%20-%3E%20e%0Ac%20-%3E%20d%0Ac%20-%3E%20e%0Ad%20-%3E%20f%0Ae%20-%3E%20f%0Ad%20-%3E%20g%0Ae%20-%3E%20g%0Af%20-%3E%20h%0Ag%20-%3E%20h%0Af%20-%3E%20i%0Ag%20-%3E%20i%0A%7D%20