Browse Source

Update dagre.js

Lutz Roeder 1 month ago
parent
commit
71db23ca58
1 changed files with 7 additions and 1 deletions
  1. 7 1
      source/dagre.js

+ 7 - 1
source/dagre.js

@@ -634,7 +634,13 @@ dagre.layout = (nodes, edges, layout, state) => {
             }
             }
         };
         };
         const depths = treeDepths(g);
         const depths = treeDepths(g);
-        const height = Math.max(...Object.values(depths)) - 1; // Note: depths is an Object not an array
+        let height = 0;
+        for (const value of Object.values(depths)) {
+            if (value > height) {
+                height = value;
+            }
+        }
+        height -= 1;
         const nodeSep = 2 * height + 1;
         const nodeSep = 2 * height + 1;
         state.nestingRoot = root;
         state.nestingRoot = root;
         // Multiply minlen by nodeSep to align nodes on non-border ranks.
         // Multiply minlen by nodeSep to align nodes on non-border ranks.