tgdwyer / WebCola

Javascript constraint-based graph layout
http://marvl.infotech.monash.edu/webcola/
MIT License
2.03k stars 258 forks source link

Uncaught TypeError: Cannot read property 'next' of null #320

Open lisp opened 3 years ago

lisp commented 3 years ago

an attempt to layout an apparently innocuous graph leads to that error. it appears to be a group with a zero length leaves array. that is, if the first group memer is removed, the layout complete. otherwise it loops, reiterating the error indefinitely.

the stack trace is

rectangle.js:261 Uncaught TypeError: Cannot read property 'next' of null at f (rectangle.js:261) at Object.findXNeighbours [as findNeighbours] (rectangle.js:272) at generateConstraints (rectangle.js:235) at generateGroupConstraints (rectangle.js:204) at rectangle.js:189 at Array.reduce () at generateGroupConstraints (rectangle.js:189) at generateXGroupConstraints (rectangle.js:295) at Projection.project (rectangle.js:450) at Projection.xProject (rectangle.js:419)

the graph is

{ "nodes": [ { "index": 0, "name": "withSubquery", "width": 32, "height": 10 }, { "index": 1, "name": "internal", "width": 32, "height": 10 }, { "index": 2, "name": "withServiceClause", "width": 32, "height": 10 }, { "index": 3, "name": "asImport", "width": 32, "height": 10 }, { "index": 4, "name": "1111", "width": 32, "height": 10 }, { "index": 5, "name": "11", "width": 32, "height": 10 }, { "index": 6, "name": "1", "width": 32, "height": 10 }, { "index": 7, "name": "0", "width": 32, "height": 10 }, { "index": 8, "name": "1111", "width": 32, "height": 10 }, { "index": 9, "name": "1111", "width": 32, "height": 10 }, { "index": 10, "name": "1111", "width": 32, "height": 10 } ], "links": [ { "source": 0, "target": 1 } ], "groups": [ { "leaves": [] }, { "leaves": [ 8 ] }, { "leaves": [ 9 ] }, { "leaves": [ 10 ] }, { "leaves": [ 0, 1, 2, 3 ] } ] }