Switch to ELK layout engine for proper compound node support

This commit is contained in:
Ian Gulliver
2026-01-24 15:37:04 -08:00
parent 8b50762c92
commit 997868949a
5 changed files with 6807 additions and 12 deletions

View File

@@ -47,10 +47,10 @@
<div id="cy"></div>
<script src="cytoscape.min.js"></script>
<script src="cola.min.js"></script>
<script src="cytoscape-cola.min.js"></script>
<script src="elk.bundled.js"></script>
<script src="cytoscape-elk.min.js"></script>
<script>
cytoscape.use(cytoscapeCola);
cytoscape.use(cytoscapeElk);
let cy;
function getLabel(node) {
@@ -106,15 +106,20 @@
function doLayout() {
cy.layout({
name: 'cola',
animate: false,
name: 'elk',
fit: true,
padding: 50,
nodeDimensionsIncludeLabels: true,
avoidOverlap: true,
nodeSpacing: 40,
edgeLength: 200,
fit: true,
randomize: true
elk: {
algorithm: 'layered',
'elk.direction': 'DOWN',
'elk.spacing.nodeNode': 80,
'elk.spacing.edgeNode': 40,
'elk.spacing.edgeEdge': 30,
'elk.layered.spacing.nodeNodeBetweenLayers': 100,
'elk.layered.crossingMinimization.strategy': 'LAYER_SWEEP',
'elk.hierarchyHandling': 'INCLUDE_CHILDREN'
}
}).run();
}