kieler / elkjs

ELK's layout algorithms for JavaScript
Other
1.82k stars 97 forks source link

Error: org.eclipse.elk.graph.json.JsonImportException: An edge must have a source node" #168

Open Jasminou opened 2 years ago

Jasminou commented 2 years ago

looks like the lib doesnt like to have edge without future comin nodes "Error: org.eclipse.elk.graph.json.JsonImportException: An edge must have a source node"

is there any way to have a solution for this without creating the missing nodes ( the node will appear when user click to expand a node)

soerendomroes commented 2 years ago

Have you tried introducing the edge in the same hierarchy level as the nodes that you sometimes don't show, such that they will not be part of the graph before you expand the node? E.g.:

node n1 {
  // Not shown
  node n11
  edge n11 -> n2 // Warning but seems to work
}

node n2

Can you provide an example graph that reproduces your issue?

This seems to be an issue that the framework that you use to expand nodes should deal with.

Jasminou commented 2 years ago

@soerendomroes ,

I'm the one expanding my graph. not using any thired lib here.

my graph is a list of nodes and edges some of the nodes can have nodes children

so as u can see below some of the nodes can have children nodes. but the list of edges contain all the edges needed.

I've been using dagre and trying to to switch to elkjs but its seems that elkjs doesn't like to have random edges waiting for some coming nodes.

   nodes: [
      {
        id: '.....',
        data: {
        }
      },
      .....
   // some of the node can have children nodes as well
      {
        id: ...,
        data: {
          children: [
            {
              id:  'child1'
               ...
            },
            {
              id: 'child2',
             ...
            },
          ]
        }
      }
    ],
    edges: [
      {
        sourceNodeId: '',
        targetNodeId: ''
        data: {
          .....
        }
      },
    ....
    ],
}
soerendomroes commented 2 years ago

If you think that ignoring edges without source and target is a feature that you would like to have in elkjs, I suggest to create a ticket in ELK.