elkjs
elkjs copied to clipboard
hierarchyHandling: 'INCLUDE_CHILDREN' not traversing children, reports that node does not exist
I've been receiving the following console error when trying to render a hierarchal graph:
polyfills.js:1 Error: org.eclipse.elk.core.UnsupportedGraphException: The source or the target of edge ElkEdge "e5" ElkNode "n4" (0,0 | 30,30) -> ElkNode "n6" (0,0 | 30,30) could not be found. This usually happens when an edge connects a node laid out by ELK Layered to a node in another level of hierarchy laid out by either another instance of ELK Layered or another layout algorithm alltogether. The former can be solved by setting the hierarchyHandling option to INCLUDE_CHILDREN.
My current JSON data looks like this (test data similar to actual):
{ id: "root", layoutOptions: { 'algorithm': 'layered', hierarchyHandling: 'INCLUDE_CHILDREN', }, children: [ { id: "n1", width: 80, height: 80, children:[{ id: "n4", width: 30, height: 30 }, { id: "n5", width: 30, height: 30 }] }, { id: "n2", width: 80, height: 80 }, { id: "n3", width: 80, height: 80, children:[{ id: "n6", width: 30, height: 30 }, { id: "n7", width: 30, height: 30 }] } ], edges: [ { id: "e1", sources: [ "n1" ], targets: [ "n2" ] }, { id: "e2", sources: [ "n1" ], targets: [ "n3" ] }, { id: "e3", sources: [ "n2" ], targets: [ "n1" ] }, { id: "e4", sources: [ "n7" ], targets: [ "n4" ] }, { id: "e5", sources: [ "n4" ], targets: [ "n6" ] } ] }
It renders correctly in the editor, https://rtsys.informatik.uni-kiel.de/elklive/json.html, but errors every time in my node environment.
If I remove the last two edges, 'e5' and 'e4', from the code, it renders. I'm on the latest version of elkjs and need INCLUDE_CHILDREN to be the heirarchyHandling in order to display the dataflow of my clients data. Primarily, the edges/relations between two child nodes with different parents.
Any help debugging this would be amazing.
If this happens while migrating from 0.7.X to 0.8.X it could happen because of https://github.com/eclipse/elk/issues/651. I found a way to reproduce the issue in elk-live. Your similar to actual test data does not reproduce the issue, but my example does. Does your real data look more like my example?
My data does not have any layout options set anywhere except at the root level. The example data I provided does not render locally for me either, it throws the same exception.
I also tried the data you provided in the elk-live demo. Even when I remove the second layoutOptions, it still throws the same error and does not render.
Can I somehow test this in your setup? I cannot seem to reproduce it otherwise. I do not have the issues in elk-live that you have in your setup.
I'm afraid my code is the private property of my employer so I cannot share my codebase with you. If it helps, we're running elkjs in an Angular environment.
What we ended up doing was rolling back to a much older version in order to get a render to work.
Thanks for the feedback. To make clear what solved the problem for you (if I have time to look into this in the future), what version are you using now?
I was getting the same exception. The issue was being caused by defining the algorithm in the defaultLayoutOptions
whilst initializing elk:
const elk = new Elk({
defaultLayoutOptions: {
"elk.algorithm": "layered"
}
})
Removing elk.algorithm
from the defaultLayoutOptions fixed the error. As the error message states, multiple layout algorithms at different levels will cause this error (even if they're the same algorithm!).
Thank you.
With this information I think I introduced this bug while "fixing" https://github.com/eclipse/elk/issues/651
I have the same problem, I would like to minimize a group making it fixed but keeping layered the edges that connect to outside, in the example the red edge is fixed, the problem is when use the default layered algorithm
