Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

Commit

Permalink
Remove compaction on root node. Fixes #279
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkpiano committed Jan 9, 2022
1 parent 9f93d67 commit 63273c6
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/graphUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ if (typeof ELK !== 'undefined') {
elk = new ELK();
}

const rootLayoutOptions: LayoutOptions = {
'elk.hierarchyHandling': 'INCLUDE_CHILDREN',
'elk.algorithm': 'layered',
'elk.layered.considerModelOrder': 'NODES_AND_EDGES',
'elk.layered.wrapping.strategy': 'MULTI_EDGE',
'elk.layered.compaction.postCompaction.strategy': 'LEFT',
'elk.aspectRatio': '2',
'elk.direction': 'RIGHT',
};

type RelativeNodeEdgeMap = [
Map<StateNode | undefined, DirectedGraphEdge[]>,
Map<string, StateNode | undefined>,
Expand Down Expand Up @@ -298,7 +288,7 @@ export function isStateElkNode(node: ElkNode): node is StateElkNode {
return 'absolutePosition' in node;
}

function elkJSON(elkNode: StateElkNode): any {
function elkJSON(elkNode: ElkNode): any {
const { id, layoutOptions, width, height, children, edges, ports } = elkNode;

return {
Expand All @@ -312,7 +302,9 @@ function elkJSON(elkNode: StateElkNode): any {
width: port.width,
height: port.height,
})),
edges: edges.map((edge) => {
edges: edges?.map((_edge) => {
const edge = _edge as ElkExtendedEdge;

return {
id: getElkId(edge.id),
labels: edge.labels?.map((label) => ({
Expand Down Expand Up @@ -349,7 +341,14 @@ export async function getElkGraph(
id: 'root',
edges: rootEdges.map((edge) => getElkEdge(edge, rectMap)),
children: [getElkChild(rootDigraphNode, runContext)],
layoutOptions: rootLayoutOptions,
layoutOptions: {
'elk.hierarchyHandling': 'INCLUDE_CHILDREN',
'elk.algorithm': 'layered',
'elk.layered.considerModelOrder': 'NODES_AND_EDGES',
'elk.layered.wrapping.strategy': 'MULTI_EDGE',
'elk.aspectRatio': '2',
'elk.direction': 'RIGHT',
},
});

let rootElkNode: ElkNode | undefined = undefined;
Expand Down

0 comments on commit 63273c6

Please sign in to comment.