@antv/layout 0.3.12 → 1.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -32
- package/dist/3a54d760230d1933f953.worker.js +2 -0
- package/dist/3a54d760230d1933f953.worker.js.map +1 -0
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/lib/Circular.d.ts +40 -0
- package/lib/Supervisor.d.ts +65 -0
- package/lib/index.d.ts +3 -3
- package/lib/registry.d.ts +3 -0
- package/lib/types.d.ts +128 -0
- package/lib/util/gpu.d.ts +22 -22
- package/lib/util/index.d.ts +6 -6
- package/lib/util/math.d.ts +3 -3
- package/lib/worker.d.ts +3 -0
- package/package.json +21 -95
- package/dist/layout.min.js +0 -3
- package/dist/layout.min.js.LICENSE.txt +0 -1
- package/dist/layout.min.js.map +0 -1
- package/es/index.d.ts +0 -3
- package/es/index.js +0 -6
- package/es/index.js.map +0 -1
- package/es/layout/base.d.ts +0 -22
- package/es/layout/base.js +0 -51
- package/es/layout/base.js.map +0 -1
- package/es/layout/circular.d.ts +0 -80
- package/es/layout/circular.js +0 -314
- package/es/layout/circular.js.map +0 -1
- package/es/layout/comboCombined.d.ts +0 -54
- package/es/layout/comboCombined.js +0 -354
- package/es/layout/comboCombined.js.map +0 -1
- package/es/layout/comboForce.d.ts +0 -134
- package/es/layout/comboForce.js +0 -801
- package/es/layout/comboForce.js.map +0 -1
- package/es/layout/concentric.d.ts +0 -67
- package/es/layout/concentric.js +0 -219
- package/es/layout/concentric.js.map +0 -1
- package/es/layout/constants.d.ts +0 -12
- package/es/layout/constants.js +0 -22
- package/es/layout/constants.js.map +0 -1
- package/es/layout/dagre/graph.d.ts +0 -91
- package/es/layout/dagre/graph.js +0 -4
- package/es/layout/dagre/graph.js.map +0 -1
- package/es/layout/dagre/index.d.ts +0 -8
- package/es/layout/dagre/index.js +0 -31
- package/es/layout/dagre/index.js.map +0 -1
- package/es/layout/dagre/src/acyclic.d.ts +0 -6
- package/es/layout/dagre/src/acyclic.js +0 -52
- package/es/layout/dagre/src/acyclic.js.map +0 -1
- package/es/layout/dagre/src/add-border-segments.d.ts +0 -3
- package/es/layout/dagre/src/add-border-segments.js +0 -32
- package/es/layout/dagre/src/add-border-segments.js.map +0 -1
- package/es/layout/dagre/src/coordinate-system.d.ts +0 -6
- package/es/layout/dagre/src/coordinate-system.js +0 -69
- package/es/layout/dagre/src/coordinate-system.js.map +0 -1
- package/es/layout/dagre/src/data/list.d.ts +0 -12
- package/es/layout/dagre/src/data/list.js +0 -48
- package/es/layout/dagre/src/data/list.js.map +0 -1
- package/es/layout/dagre/src/debug.d.ts +0 -3
- package/es/layout/dagre/src/debug.js +0 -24
- package/es/layout/dagre/src/debug.js.map +0 -1
- package/es/layout/dagre/src/greedy-fas.d.ts +0 -3
- package/es/layout/dagre/src/greedy-fas.js +0 -114
- package/es/layout/dagre/src/greedy-fas.js.map +0 -1
- package/es/layout/dagre/src/layout.d.ts +0 -3
- package/es/layout/dagre/src/layout.js +0 -518
- package/es/layout/dagre/src/layout.js.map +0 -1
- package/es/layout/dagre/src/nesting-graph.d.ts +0 -6
- package/es/layout/dagre/src/nesting-graph.js +0 -117
- package/es/layout/dagre/src/nesting-graph.js.map +0 -1
- package/es/layout/dagre/src/normalize.d.ts +0 -6
- package/es/layout/dagre/src/normalize.js +0 -89
- package/es/layout/dagre/src/normalize.js.map +0 -1
- package/es/layout/dagre/src/order/add-subgraph-constraints.d.ts +0 -3
- package/es/layout/dagre/src/order/add-subgraph-constraints.js +0 -27
- package/es/layout/dagre/src/order/add-subgraph-constraints.js.map +0 -1
- package/es/layout/dagre/src/order/barycenter.d.ts +0 -11
- package/es/layout/dagre/src/order/barycenter.js +0 -24
- package/es/layout/dagre/src/order/barycenter.js.map +0 -1
- package/es/layout/dagre/src/order/build-layer-graph.d.ts +0 -3
- package/es/layout/dagre/src/order/build-layer-graph.js +0 -71
- package/es/layout/dagre/src/order/build-layer-graph.js.map +0 -1
- package/es/layout/dagre/src/order/cross-count.d.ts +0 -3
- package/es/layout/dagre/src/order/cross-count.js +0 -65
- package/es/layout/dagre/src/order/cross-count.js.map +0 -1
- package/es/layout/dagre/src/order/index.d.ts +0 -3
- package/es/layout/dagre/src/order/index.js +0 -91
- package/es/layout/dagre/src/order/index.js.map +0 -1
- package/es/layout/dagre/src/order/init-data-order.d.ts +0 -6
- package/es/layout/dagre/src/order/init-data-order.js +0 -25
- package/es/layout/dagre/src/order/init-data-order.js.map +0 -1
- package/es/layout/dagre/src/order/init-order.d.ts +0 -3
- package/es/layout/dagre/src/order/init-order.js +0 -52
- package/es/layout/dagre/src/order/init-order.js.map +0 -1
- package/es/layout/dagre/src/order/resolve-conflicts.d.ts +0 -19
- package/es/layout/dagre/src/order/resolve-conflicts.js +0 -93
- package/es/layout/dagre/src/order/resolve-conflicts.js.map +0 -1
- package/es/layout/dagre/src/order/sort-subgraph.d.ts +0 -7
- package/es/layout/dagre/src/order/sort-subgraph.js +0 -85
- package/es/layout/dagre/src/order/sort-subgraph.js.map +0 -1
- package/es/layout/dagre/src/order/sort.d.ts +0 -7
- package/es/layout/dagre/src/order/sort.js +0 -68
- package/es/layout/dagre/src/order/sort.js.map +0 -1
- package/es/layout/dagre/src/parent-dummy-chains.d.ts +0 -3
- package/es/layout/dagre/src/parent-dummy-chains.js +0 -81
- package/es/layout/dagre/src/parent-dummy-chains.js.map +0 -1
- package/es/layout/dagre/src/position/bk.d.ts +0 -23
- package/es/layout/dagre/src/position/bk.js +0 -370
- package/es/layout/dagre/src/position/bk.js.map +0 -1
- package/es/layout/dagre/src/position/index.d.ts +0 -3
- package/es/layout/dagre/src/position/index.js +0 -51
- package/es/layout/dagre/src/position/index.js.map +0 -1
- package/es/layout/dagre/src/rank/feasible-tree.d.ts +0 -9
- package/es/layout/dagre/src/rank/feasible-tree.js +0 -148
- package/es/layout/dagre/src/rank/feasible-tree.js.map +0 -1
- package/es/layout/dagre/src/rank/index.d.ts +0 -3
- package/es/layout/dagre/src/rank/index.js +0 -53
- package/es/layout/dagre/src/rank/index.js.map +0 -1
- package/es/layout/dagre/src/rank/network-simplex.d.ts +0 -9
- package/es/layout/dagre/src/rank/network-simplex.js +0 -195
- package/es/layout/dagre/src/rank/network-simplex.js.map +0 -1
- package/es/layout/dagre/src/rank/util.d.ts +0 -11
- package/es/layout/dagre/src/rank/util.js +0 -141
- package/es/layout/dagre/src/rank/util.js.map +0 -1
- package/es/layout/dagre/src/util.d.ts +0 -31
- package/es/layout/dagre/src/util.js +0 -261
- package/es/layout/dagre/src/util.js.map +0 -1
- package/es/layout/dagre.d.ts +0 -71
- package/es/layout/dagre.js +0 -433
- package/es/layout/dagre.js.map +0 -1
- package/es/layout/dagreCompound.d.ts +0 -121
- package/es/layout/dagreCompound.js +0 -391
- package/es/layout/dagreCompound.js.map +0 -1
- package/es/layout/er/core.d.ts +0 -1
- package/es/layout/er/core.js +0 -107
- package/es/layout/er/core.js.map +0 -1
- package/es/layout/er/forceGrid.d.ts +0 -8
- package/es/layout/er/forceGrid.js +0 -88
- package/es/layout/er/forceGrid.js.map +0 -1
- package/es/layout/er/grid.d.ts +0 -26
- package/es/layout/er/grid.js +0 -162
- package/es/layout/er/grid.js.map +0 -1
- package/es/layout/er/index.d.ts +0 -29
- package/es/layout/er/index.js +0 -54
- package/es/layout/er/index.js.map +0 -1
- package/es/layout/er/mysqlWorkbench.d.ts +0 -6
- package/es/layout/er/mysqlWorkbench.js +0 -324
- package/es/layout/er/mysqlWorkbench.js.map +0 -1
- package/es/layout/er/type.d.ts +0 -35
- package/es/layout/er/type.js +0 -2
- package/es/layout/er/type.js.map +0 -1
- package/es/layout/force/force-in-a-box.d.ts +0 -28
- package/es/layout/force/force-in-a-box.js +0 -330
- package/es/layout/force/force-in-a-box.js.map +0 -1
- package/es/layout/force/force.d.ts +0 -100
- package/es/layout/force/force.js +0 -340
- package/es/layout/force/force.js.map +0 -1
- package/es/layout/force/index.d.ts +0 -1
- package/es/layout/force/index.js +0 -2
- package/es/layout/force/index.js.map +0 -1
- package/es/layout/force2/ForceNBody.d.ts +0 -7
- package/es/layout/force2/ForceNBody.js +0 -94
- package/es/layout/force2/ForceNBody.js.map +0 -1
- package/es/layout/force2/index.d.ts +0 -119
- package/es/layout/force2/index.js +0 -608
- package/es/layout/force2/index.js.map +0 -1
- package/es/layout/forceAtlas2/body.d.ts +0 -33
- package/es/layout/forceAtlas2/body.js +0 -89
- package/es/layout/forceAtlas2/body.js.map +0 -1
- package/es/layout/forceAtlas2/index.d.ts +0 -115
- package/es/layout/forceAtlas2/index.js +0 -484
- package/es/layout/forceAtlas2/index.js.map +0 -1
- package/es/layout/forceAtlas2/quad.d.ts +0 -27
- package/es/layout/forceAtlas2/quad.js +0 -96
- package/es/layout/forceAtlas2/quad.js.map +0 -1
- package/es/layout/forceAtlas2/quadTree.d.ts +0 -20
- package/es/layout/forceAtlas2/quadTree.js +0 -103
- package/es/layout/forceAtlas2/quadTree.js.map +0 -1
- package/es/layout/fruchterman.d.ts +0 -73
- package/es/layout/fruchterman.js +0 -296
- package/es/layout/fruchterman.js.map +0 -1
- package/es/layout/gForce.d.ts +0 -96
- package/es/layout/gForce.js +0 -399
- package/es/layout/gForce.js.map +0 -1
- package/es/layout/gpu/fruchterman.d.ts +0 -57
- package/es/layout/gpu/fruchterman.js +0 -267
- package/es/layout/gpu/fruchterman.js.map +0 -1
- package/es/layout/gpu/fruchtermanShader.d.ts +0 -4
- package/es/layout/gpu/fruchtermanShader.js +0 -201
- package/es/layout/gpu/fruchtermanShader.js.map +0 -1
- package/es/layout/gpu/gForce.d.ts +0 -68
- package/es/layout/gpu/gForce.js +0 -330
- package/es/layout/gpu/gForce.js.map +0 -1
- package/es/layout/gpu/gForceShader.d.ts +0 -4
- package/es/layout/gpu/gForceShader.js +0 -218
- package/es/layout/gpu/gForceShader.js.map +0 -1
- package/es/layout/grid.d.ts +0 -83
- package/es/layout/grid.js +0 -317
- package/es/layout/grid.js.map +0 -1
- package/es/layout/index.d.ts +0 -22
- package/es/layout/index.js +0 -25
- package/es/layout/index.js.map +0 -1
- package/es/layout/layout.d.ts +0 -26
- package/es/layout/layout.js +0 -97
- package/es/layout/layout.js.map +0 -1
- package/es/layout/mds.d.ts +0 -39
- package/es/layout/mds.js +0 -122
- package/es/layout/mds.js.map +0 -1
- package/es/layout/radial/index.d.ts +0 -1
- package/es/layout/radial/index.js +0 -2
- package/es/layout/radial/index.js.map +0 -1
- package/es/layout/radial/mds.d.ts +0 -15
- package/es/layout/radial/mds.js +0 -38
- package/es/layout/radial/mds.js.map +0 -1
- package/es/layout/radial/radial.d.ts +0 -74
- package/es/layout/radial/radial.js +0 -420
- package/es/layout/radial/radial.js.map +0 -1
- package/es/layout/radial/radialNonoverlapForce.d.ts +0 -50
- package/es/layout/radial/radialNonoverlapForce.js +0 -123
- package/es/layout/radial/radialNonoverlapForce.js.map +0 -1
- package/es/layout/random.d.ts +0 -35
- package/es/layout/random.js +0 -62
- package/es/layout/random.js.map +0 -1
- package/es/layout/types.d.ts +0 -432
- package/es/layout/types.js +0 -2
- package/es/layout/types.js.map +0 -1
- package/es/registy/index.d.ts +0 -3
- package/es/registy/index.js +0 -41
- package/es/registy/index.js.map +0 -1
- package/es/util/array.d.ts +0 -1
- package/es/util/array.js +0 -2
- package/es/util/array.js.map +0 -1
- package/es/util/function.d.ts +0 -6
- package/es/util/function.js +0 -56
- package/es/util/function.js.map +0 -1
- package/es/util/gpu.d.ts +0 -52
- package/es/util/gpu.js +0 -239
- package/es/util/gpu.js.map +0 -1
- package/es/util/index.d.ts +0 -6
- package/es/util/index.js +0 -7
- package/es/util/index.js.map +0 -1
- package/es/util/math.d.ts +0 -48
- package/es/util/math.js +0 -276
- package/es/util/math.js.map +0 -1
- package/es/util/number.d.ts +0 -3
- package/es/util/number.js +0 -7
- package/es/util/number.js.map +0 -1
- package/es/util/object.d.ts +0 -2
- package/es/util/object.js +0 -25
- package/es/util/object.js.map +0 -1
- package/es/util/string.d.ts +0 -2
- package/es/util/string.js +0 -16
- package/es/util/string.js.map +0 -1
- package/lib/index.js +0 -24
- package/lib/index.js.map +0 -1
- package/lib/layout/base.d.ts +0 -22
- package/lib/layout/base.js +0 -56
- package/lib/layout/base.js.map +0 -1
- package/lib/layout/circular.d.ts +0 -80
- package/lib/layout/circular.js +0 -337
- package/lib/layout/circular.js.map +0 -1
- package/lib/layout/comboCombined.d.ts +0 -54
- package/lib/layout/comboCombined.js +0 -390
- package/lib/layout/comboCombined.js.map +0 -1
- package/lib/layout/comboForce.d.ts +0 -134
- package/lib/layout/comboForce.js +0 -826
- package/lib/layout/comboForce.js.map +0 -1
- package/lib/layout/concentric.d.ts +0 -67
- package/lib/layout/concentric.js +0 -243
- package/lib/layout/concentric.js.map +0 -1
- package/lib/layout/constants.d.ts +0 -12
- package/lib/layout/constants.js +0 -25
- package/lib/layout/constants.js.map +0 -1
- package/lib/layout/dagre/graph.d.ts +0 -91
- package/lib/layout/dagre/graph.js +0 -28
- package/lib/layout/dagre/graph.js.map +0 -1
- package/lib/layout/dagre/index.d.ts +0 -8
- package/lib/layout/dagre/index.js +0 -36
- package/lib/layout/dagre/index.js.map +0 -1
- package/lib/layout/dagre/src/acyclic.d.ts +0 -6
- package/lib/layout/dagre/src/acyclic.js +0 -57
- package/lib/layout/dagre/src/acyclic.js.map +0 -1
- package/lib/layout/dagre/src/add-border-segments.d.ts +0 -3
- package/lib/layout/dagre/src/add-border-segments.js +0 -34
- package/lib/layout/dagre/src/add-border-segments.js.map +0 -1
- package/lib/layout/dagre/src/coordinate-system.d.ts +0 -6
- package/lib/layout/dagre/src/coordinate-system.js +0 -71
- package/lib/layout/dagre/src/coordinate-system.js.map +0 -1
- package/lib/layout/dagre/src/data/list.d.ts +0 -12
- package/lib/layout/dagre/src/data/list.js +0 -52
- package/lib/layout/dagre/src/data/list.js.map +0 -1
- package/lib/layout/dagre/src/debug.d.ts +0 -3
- package/lib/layout/dagre/src/debug.js +0 -26
- package/lib/layout/dagre/src/debug.js.map +0 -1
- package/lib/layout/dagre/src/greedy-fas.d.ts +0 -3
- package/lib/layout/dagre/src/greedy-fas.js +0 -144
- package/lib/layout/dagre/src/greedy-fas.js.map +0 -1
- package/lib/layout/dagre/src/layout.d.ts +0 -3
- package/lib/layout/dagre/src/layout.js +0 -535
- package/lib/layout/dagre/src/layout.js.map +0 -1
- package/lib/layout/dagre/src/nesting-graph.d.ts +0 -6
- package/lib/layout/dagre/src/nesting-graph.js +0 -119
- package/lib/layout/dagre/src/nesting-graph.js.map +0 -1
- package/lib/layout/dagre/src/normalize.d.ts +0 -6
- package/lib/layout/dagre/src/normalize.js +0 -91
- package/lib/layout/dagre/src/normalize.js.map +0 -1
- package/lib/layout/dagre/src/order/add-subgraph-constraints.d.ts +0 -3
- package/lib/layout/dagre/src/order/add-subgraph-constraints.js +0 -29
- package/lib/layout/dagre/src/order/add-subgraph-constraints.js.map +0 -1
- package/lib/layout/dagre/src/order/barycenter.d.ts +0 -11
- package/lib/layout/dagre/src/order/barycenter.js +0 -26
- package/lib/layout/dagre/src/order/barycenter.js.map +0 -1
- package/lib/layout/dagre/src/order/build-layer-graph.d.ts +0 -3
- package/lib/layout/dagre/src/order/build-layer-graph.js +0 -73
- package/lib/layout/dagre/src/order/build-layer-graph.js.map +0 -1
- package/lib/layout/dagre/src/order/cross-count.d.ts +0 -3
- package/lib/layout/dagre/src/order/cross-count.js +0 -67
- package/lib/layout/dagre/src/order/cross-count.js.map +0 -1
- package/lib/layout/dagre/src/order/index.d.ts +0 -3
- package/lib/layout/dagre/src/order/index.js +0 -96
- package/lib/layout/dagre/src/order/index.js.map +0 -1
- package/lib/layout/dagre/src/order/init-data-order.d.ts +0 -6
- package/lib/layout/dagre/src/order/init-data-order.js +0 -27
- package/lib/layout/dagre/src/order/init-data-order.js.map +0 -1
- package/lib/layout/dagre/src/order/init-order.d.ts +0 -3
- package/lib/layout/dagre/src/order/init-order.js +0 -54
- package/lib/layout/dagre/src/order/init-order.js.map +0 -1
- package/lib/layout/dagre/src/order/resolve-conflicts.d.ts +0 -19
- package/lib/layout/dagre/src/order/resolve-conflicts.js +0 -98
- package/lib/layout/dagre/src/order/resolve-conflicts.js.map +0 -1
- package/lib/layout/dagre/src/order/sort-subgraph.d.ts +0 -7
- package/lib/layout/dagre/src/order/sort-subgraph.js +0 -90
- package/lib/layout/dagre/src/order/sort-subgraph.js.map +0 -1
- package/lib/layout/dagre/src/order/sort.d.ts +0 -7
- package/lib/layout/dagre/src/order/sort.js +0 -70
- package/lib/layout/dagre/src/order/sort.js.map +0 -1
- package/lib/layout/dagre/src/parent-dummy-chains.d.ts +0 -3
- package/lib/layout/dagre/src/parent-dummy-chains.js +0 -83
- package/lib/layout/dagre/src/parent-dummy-chains.js.map +0 -1
- package/lib/layout/dagre/src/position/bk.d.ts +0 -23
- package/lib/layout/dagre/src/position/bk.js +0 -409
- package/lib/layout/dagre/src/position/bk.js.map +0 -1
- package/lib/layout/dagre/src/position/index.d.ts +0 -3
- package/lib/layout/dagre/src/position/index.js +0 -64
- package/lib/layout/dagre/src/position/index.js.map +0 -1
- package/lib/layout/dagre/src/rank/feasible-tree.d.ts +0 -9
- package/lib/layout/dagre/src/rank/feasible-tree.js +0 -152
- package/lib/layout/dagre/src/rank/feasible-tree.js.map +0 -1
- package/lib/layout/dagre/src/rank/index.d.ts +0 -3
- package/lib/layout/dagre/src/rank/index.js +0 -58
- package/lib/layout/dagre/src/rank/index.js.map +0 -1
- package/lib/layout/dagre/src/rank/network-simplex.d.ts +0 -9
- package/lib/layout/dagre/src/rank/network-simplex.js +0 -205
- package/lib/layout/dagre/src/rank/network-simplex.js.map +0 -1
- package/lib/layout/dagre/src/rank/util.d.ts +0 -11
- package/lib/layout/dagre/src/rank/util.js +0 -146
- package/lib/layout/dagre/src/rank/util.js.map +0 -1
- package/lib/layout/dagre/src/util.d.ts +0 -31
- package/lib/layout/dagre/src/util.js +0 -280
- package/lib/layout/dagre/src/util.js.map +0 -1
- package/lib/layout/dagre.d.ts +0 -71
- package/lib/layout/dagre.js +0 -462
- package/lib/layout/dagre.js.map +0 -1
- package/lib/layout/dagreCompound.d.ts +0 -121
- package/lib/layout/dagreCompound.js +0 -429
- package/lib/layout/dagreCompound.js.map +0 -1
- package/lib/layout/er/core.d.ts +0 -1
- package/lib/layout/er/core.js +0 -147
- package/lib/layout/er/core.js.map +0 -1
- package/lib/layout/er/forceGrid.d.ts +0 -8
- package/lib/layout/er/forceGrid.js +0 -97
- package/lib/layout/er/forceGrid.js.map +0 -1
- package/lib/layout/er/grid.d.ts +0 -26
- package/lib/layout/er/grid.js +0 -177
- package/lib/layout/er/grid.js.map +0 -1
- package/lib/layout/er/index.d.ts +0 -29
- package/lib/layout/er/index.js +0 -80
- package/lib/layout/er/index.js.map +0 -1
- package/lib/layout/er/mysqlWorkbench.d.ts +0 -6
- package/lib/layout/er/mysqlWorkbench.js +0 -326
- package/lib/layout/er/mysqlWorkbench.js.map +0 -1
- package/lib/layout/er/type.d.ts +0 -35
- package/lib/layout/er/type.js +0 -3
- package/lib/layout/er/type.js.map +0 -1
- package/lib/layout/force/force-in-a-box.d.ts +0 -28
- package/lib/layout/force/force-in-a-box.js +0 -357
- package/lib/layout/force/force-in-a-box.js.map +0 -1
- package/lib/layout/force/force.d.ts +0 -100
- package/lib/layout/force/force.js +0 -388
- package/lib/layout/force/force.js.map +0 -1
- package/lib/layout/force/index.d.ts +0 -1
- package/lib/layout/force/index.js +0 -18
- package/lib/layout/force/index.js.map +0 -1
- package/lib/layout/force2/ForceNBody.d.ts +0 -7
- package/lib/layout/force2/ForceNBody.js +0 -98
- package/lib/layout/force2/ForceNBody.js.map +0 -1
- package/lib/layout/force2/index.d.ts +0 -119
- package/lib/layout/force2/index.js +0 -643
- package/lib/layout/force2/index.js.map +0 -1
- package/lib/layout/forceAtlas2/body.d.ts +0 -33
- package/lib/layout/forceAtlas2/body.js +0 -93
- package/lib/layout/forceAtlas2/body.js.map +0 -1
- package/lib/layout/forceAtlas2/index.d.ts +0 -115
- package/lib/layout/forceAtlas2/index.js +0 -509
- package/lib/layout/forceAtlas2/index.js.map +0 -1
- package/lib/layout/forceAtlas2/quad.d.ts +0 -27
- package/lib/layout/forceAtlas2/quad.js +0 -100
- package/lib/layout/forceAtlas2/quad.js.map +0 -1
- package/lib/layout/forceAtlas2/quadTree.d.ts +0 -20
- package/lib/layout/forceAtlas2/quadTree.js +0 -107
- package/lib/layout/forceAtlas2/quadTree.js.map +0 -1
- package/lib/layout/fruchterman.d.ts +0 -73
- package/lib/layout/fruchterman.js +0 -320
- package/lib/layout/fruchterman.js.map +0 -1
- package/lib/layout/gForce.d.ts +0 -96
- package/lib/layout/gForce.js +0 -421
- package/lib/layout/gForce.js.map +0 -1
- package/lib/layout/gpu/fruchterman.d.ts +0 -57
- package/lib/layout/gpu/fruchterman.js +0 -361
- package/lib/layout/gpu/fruchterman.js.map +0 -1
- package/lib/layout/gpu/fruchtermanShader.d.ts +0 -4
- package/lib/layout/gpu/fruchtermanShader.js +0 -8
- package/lib/layout/gpu/fruchtermanShader.js.map +0 -1
- package/lib/layout/gpu/gForce.d.ts +0 -68
- package/lib/layout/gpu/gForce.js +0 -415
- package/lib/layout/gpu/gForce.js.map +0 -1
- package/lib/layout/gpu/gForceShader.d.ts +0 -4
- package/lib/layout/gpu/gForceShader.js +0 -8
- package/lib/layout/gpu/gForceShader.js.map +0 -1
- package/lib/layout/grid.d.ts +0 -83
- package/lib/layout/grid.js +0 -339
- package/lib/layout/grid.js.map +0 -1
- package/lib/layout/index.d.ts +0 -22
- package/lib/layout/index.js +0 -59
- package/lib/layout/index.js.map +0 -1
- package/lib/layout/layout.d.ts +0 -26
- package/lib/layout/layout.js +0 -102
- package/lib/layout/layout.js.map +0 -1
- package/lib/layout/mds.d.ts +0 -39
- package/lib/layout/mds.js +0 -144
- package/lib/layout/mds.js.map +0 -1
- package/lib/layout/radial/index.d.ts +0 -1
- package/lib/layout/radial/index.js +0 -18
- package/lib/layout/radial/index.js.map +0 -1
- package/lib/layout/radial/mds.d.ts +0 -15
- package/lib/layout/radial/mds.js +0 -42
- package/lib/layout/radial/mds.js.map +0 -1
- package/lib/layout/radial/radial.d.ts +0 -74
- package/lib/layout/radial/radial.js +0 -445
- package/lib/layout/radial/radial.js.map +0 -1
- package/lib/layout/radial/radialNonoverlapForce.d.ts +0 -50
- package/lib/layout/radial/radialNonoverlapForce.js +0 -127
- package/lib/layout/radial/radialNonoverlapForce.js.map +0 -1
- package/lib/layout/random.d.ts +0 -35
- package/lib/layout/random.js +0 -84
- package/lib/layout/random.js.map +0 -1
- package/lib/layout/types.d.ts +0 -432
- package/lib/layout/types.js +0 -3
- package/lib/layout/types.js.map +0 -1
- package/lib/registy/index.d.ts +0 -3
- package/lib/registy/index.js +0 -65
- package/lib/registy/index.js.map +0 -1
- package/lib/util/array.js +0 -5
- package/lib/util/array.js.map +0 -1
- package/lib/util/function.js +0 -65
- package/lib/util/function.js.map +0 -1
- package/lib/util/gpu.js +0 -250
- package/lib/util/gpu.js.map +0 -1
- package/lib/util/index.js +0 -23
- package/lib/util/index.js.map +0 -1
- package/lib/util/math.js +0 -289
- package/lib/util/math.js.map +0 -1
- package/lib/util/number.js +0 -13
- package/lib/util/number.js.map +0 -1
- package/lib/util/object.js +0 -43
- package/lib/util/object.js.map +0 -1
- package/lib/util/string.js +0 -20
- package/lib/util/string.js.map +0 -1
- package/src/index.ts +0 -7
- package/src/layout/base.ts +0 -57
- package/src/layout/circular.ts +0 -370
- package/src/layout/comboCombined.ts +0 -397
- package/src/layout/comboForce.ts +0 -873
- package/src/layout/concentric.ts +0 -289
- package/src/layout/constants.ts +0 -22
- package/src/layout/dagre/graph.ts +0 -104
- package/src/layout/dagre/index.ts +0 -31
- package/src/layout/dagre/src/acyclic.ts +0 -58
- package/src/layout/dagre/src/add-border-segments.ts +0 -47
- package/src/layout/dagre/src/coordinate-system.ts +0 -77
- package/src/layout/dagre/src/data/list.ts +0 -60
- package/src/layout/dagre/src/debug.ts +0 -30
- package/src/layout/dagre/src/greedy-fas.ts +0 -144
- package/src/layout/dagre/src/layout.ts +0 -579
- package/src/layout/dagre/src/nesting-graph.ts +0 -143
- package/src/layout/dagre/src/normalize.ts +0 -96
- package/src/layout/dagre/src/order/add-subgraph-constraints.ts +0 -29
- package/src/layout/dagre/src/order/barycenter.ts +0 -26
- package/src/layout/dagre/src/order/build-layer-graph.ts +0 -82
- package/src/layout/dagre/src/order/cross-count.ts +0 -77
- package/src/layout/dagre/src/order/index.ts +0 -105
- package/src/layout/dagre/src/order/init-data-order.ts +0 -27
- package/src/layout/dagre/src/order/init-order.ts +0 -56
- package/src/layout/dagre/src/order/resolve-conflicts.ts +0 -152
- package/src/layout/dagre/src/order/sort-subgraph.ts +0 -105
- package/src/layout/dagre/src/order/sort.ts +0 -76
- package/src/layout/dagre/src/parent-dummy-chains.ts +0 -102
- package/src/layout/dagre/src/position/bk.ts +0 -493
- package/src/layout/dagre/src/position/index.ts +0 -82
- package/src/layout/dagre/src/rank/feasible-tree.ts +0 -165
- package/src/layout/dagre/src/rank/index.ts +0 -54
- package/src/layout/dagre/src/rank/network-simplex.ts +0 -225
- package/src/layout/dagre/src/rank/util.ts +0 -166
- package/src/layout/dagre/src/util.ts +0 -309
- package/src/layout/dagre.ts +0 -460
- package/src/layout/dagreCompound.ts +0 -518
- package/src/layout/er/core.ts +0 -117
- package/src/layout/er/forceGrid.ts +0 -95
- package/src/layout/er/grid.ts +0 -185
- package/src/layout/er/index.ts +0 -68
- package/src/layout/er/mysqlWorkbench.ts +0 -345
- package/src/layout/er/type.ts +0 -39
- package/src/layout/force/force-in-a-box.ts +0 -400
- package/src/layout/force/force.ts +0 -391
- package/src/layout/force/index.ts +0 -1
- package/src/layout/force2/ForceNBody.ts +0 -128
- package/src/layout/force2/index.ts +0 -741
- package/src/layout/forceAtlas2/body.ts +0 -115
- package/src/layout/forceAtlas2/index.ts +0 -556
- package/src/layout/forceAtlas2/quad.ts +0 -115
- package/src/layout/forceAtlas2/quadTree.ts +0 -107
- package/src/layout/fruchterman.ts +0 -361
- package/src/layout/gForce.ts +0 -488
- package/src/layout/gpu/fruchterman.ts +0 -314
- package/src/layout/gpu/fruchtermanShader.ts +0 -203
- package/src/layout/gpu/gForce.ts +0 -407
- package/src/layout/gpu/gForceShader.ts +0 -220
- package/src/layout/grid.ts +0 -404
- package/src/layout/index.ts +0 -47
- package/src/layout/layout.ts +0 -110
- package/src/layout/mds.ts +0 -140
- package/src/layout/radial/index.ts +0 -1
- package/src/layout/radial/mds.ts +0 -51
- package/src/layout/radial/radial.ts +0 -500
- package/src/layout/radial/radialNonoverlapForce.ts +0 -189
- package/src/layout/random.ts +0 -75
- package/src/layout/types.ts +0 -496
- package/src/registy/index.ts +0 -43
- package/src/util/array.ts +0 -1
- package/src/util/function.ts +0 -64
- package/src/util/gpu.ts +0 -256
- package/src/util/index.ts +0 -6
- package/src/util/math.ts +0 -294
- package/src/util/number.ts +0 -8
- package/src/util/object.ts +0 -28
- package/src/util/string.ts +0 -18
|
@@ -1,579 +0,0 @@
|
|
|
1
|
-
import acyclic from "./acyclic";
|
|
2
|
-
import normalize from "./normalize";
|
|
3
|
-
import rank from "./rank";
|
|
4
|
-
import {
|
|
5
|
-
normalizeRanks,
|
|
6
|
-
removeEmptyRanks,
|
|
7
|
-
time as usetime,
|
|
8
|
-
notime,
|
|
9
|
-
asNonCompoundGraph,
|
|
10
|
-
addDummyNode,
|
|
11
|
-
intersectRect,
|
|
12
|
-
buildLayerMatrix,
|
|
13
|
-
} from "./util";
|
|
14
|
-
import parentDummyChains from "./parent-dummy-chains";
|
|
15
|
-
import nestingGraph from "./nesting-graph";
|
|
16
|
-
import addBorderSegments from "./add-border-segments";
|
|
17
|
-
import coordinateSystem from "./coordinate-system";
|
|
18
|
-
import order from "./order";
|
|
19
|
-
import position from "./position";
|
|
20
|
-
import initDataOrder from "./order/init-data-order";
|
|
21
|
-
import { Graph, Node } from "../graph";
|
|
22
|
-
|
|
23
|
-
const layout = (g: Graph, opts?: any) => {
|
|
24
|
-
const time = opts && opts.debugTiming ? usetime : notime;
|
|
25
|
-
time("layout", () => {
|
|
26
|
-
// 如果在原图基础上修改,继承原图的order结果
|
|
27
|
-
if (opts && !opts.keepNodeOrder && opts.prevGraph) {
|
|
28
|
-
time(" inheritOrder", () => {
|
|
29
|
-
inheritOrder(g, opts.prevGraph);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
const layoutGraph: any = time(" buildLayoutGraph", () => {
|
|
33
|
-
return buildLayoutGraph(g);
|
|
34
|
-
});
|
|
35
|
-
// 控制是否为边的label留位置(这会影响是否在边中间添加dummy node)
|
|
36
|
-
if (!(opts && opts.edgeLabelSpace === false)) {
|
|
37
|
-
time(" makeSpaceForEdgeLabels", () => {
|
|
38
|
-
makeSpaceForEdgeLabels(layoutGraph);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
// TODO: 暂时处理层级设置不正确时的异常报错,提示设置正确的层级
|
|
42
|
-
try {
|
|
43
|
-
time(" runLayout", () => {
|
|
44
|
-
runLayout(layoutGraph, time, opts);
|
|
45
|
-
});
|
|
46
|
-
} catch (e) {
|
|
47
|
-
if (
|
|
48
|
-
e.message ===
|
|
49
|
-
"Not possible to find intersection inside of the rectangle"
|
|
50
|
-
) {
|
|
51
|
-
console.error(
|
|
52
|
-
"The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure:\n",
|
|
53
|
-
e
|
|
54
|
-
);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
throw e;
|
|
58
|
-
}
|
|
59
|
-
time(" updateInputGraph", () => {
|
|
60
|
-
updateInputGraph(g, layoutGraph);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const runLayout = (g: Graph, time: any, opts: any) => {
|
|
66
|
-
time(" removeSelfEdges", () => {
|
|
67
|
-
removeSelfEdges(g);
|
|
68
|
-
});
|
|
69
|
-
time(" acyclic", () => {
|
|
70
|
-
acyclic.run(g);
|
|
71
|
-
});
|
|
72
|
-
time(" nestingGraph.run", () => {
|
|
73
|
-
nestingGraph.run(g);
|
|
74
|
-
});
|
|
75
|
-
time(" rank", () => {
|
|
76
|
-
rank(asNonCompoundGraph(g));
|
|
77
|
-
});
|
|
78
|
-
time(" injectEdgeLabelProxies", () => {
|
|
79
|
-
injectEdgeLabelProxies(g);
|
|
80
|
-
});
|
|
81
|
-
time(" removeEmptyRanks", () => {
|
|
82
|
-
removeEmptyRanks(g);
|
|
83
|
-
});
|
|
84
|
-
time(" nestingGraph.cleanup", () => {
|
|
85
|
-
nestingGraph.cleanup(g);
|
|
86
|
-
});
|
|
87
|
-
time(" normalizeRanks", () => {
|
|
88
|
-
normalizeRanks(g);
|
|
89
|
-
});
|
|
90
|
-
time(" assignRankMinMax", () => {
|
|
91
|
-
assignRankMinMax(g);
|
|
92
|
-
});
|
|
93
|
-
time(" removeEdgeLabelProxies", () => {
|
|
94
|
-
removeEdgeLabelProxies(g);
|
|
95
|
-
});
|
|
96
|
-
time(" normalize.run", () => {
|
|
97
|
-
normalize.run(g);
|
|
98
|
-
});
|
|
99
|
-
time(" parentDummyChains", () => {
|
|
100
|
-
parentDummyChains(g);
|
|
101
|
-
});
|
|
102
|
-
time(" addBorderSegments", () => {
|
|
103
|
-
addBorderSegments(g);
|
|
104
|
-
});
|
|
105
|
-
if (opts && opts.keepNodeOrder) {
|
|
106
|
-
time(" initDataOrder", () => {
|
|
107
|
-
initDataOrder(g, opts.nodeOrder);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
time(" order", () => {
|
|
111
|
-
order(g);
|
|
112
|
-
});
|
|
113
|
-
time(" insertSelfEdges", () => {
|
|
114
|
-
insertSelfEdges(g);
|
|
115
|
-
});
|
|
116
|
-
time(" adjustCoordinateSystem", () => {
|
|
117
|
-
coordinateSystem.adjust(g);
|
|
118
|
-
});
|
|
119
|
-
time(" position", () => {
|
|
120
|
-
position(g);
|
|
121
|
-
});
|
|
122
|
-
time(" positionSelfEdges", () => {
|
|
123
|
-
positionSelfEdges(g);
|
|
124
|
-
});
|
|
125
|
-
time(" removeBorderNodes", () => {
|
|
126
|
-
removeBorderNodes(g);
|
|
127
|
-
});
|
|
128
|
-
time(" normalize.undo", () => {
|
|
129
|
-
normalize.undo(g);
|
|
130
|
-
});
|
|
131
|
-
time(" fixupEdgeLabelCoords", () => {
|
|
132
|
-
fixupEdgeLabelCoords(g);
|
|
133
|
-
});
|
|
134
|
-
time(" undoCoordinateSystem", () => {
|
|
135
|
-
coordinateSystem.undo(g);
|
|
136
|
-
});
|
|
137
|
-
time(" translateGraph", () => {
|
|
138
|
-
translateGraph(g);
|
|
139
|
-
});
|
|
140
|
-
time(" assignNodeIntersects", () => {
|
|
141
|
-
assignNodeIntersects(g);
|
|
142
|
-
});
|
|
143
|
-
time(" reversePoints", () => {
|
|
144
|
-
reversePointsForReversedEdges(g);
|
|
145
|
-
});
|
|
146
|
-
time(" acyclic.undo", () => {
|
|
147
|
-
acyclic.undo(g);
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* 继承上一个布局中的order,防止翻转
|
|
153
|
-
* TODO: 暂时没有考虑涉及层级变动的布局,只保证原来布局层级和相对顺序不变
|
|
154
|
-
*/
|
|
155
|
-
const inheritOrder = (currG: Graph, prevG: Graph) => {
|
|
156
|
-
currG.nodes().forEach((n: string) => {
|
|
157
|
-
const node = currG.node(n)!;
|
|
158
|
-
const prevNode = prevG.node(n)!;
|
|
159
|
-
if (prevNode !== undefined) {
|
|
160
|
-
node.fixorder = prevNode._order;
|
|
161
|
-
delete prevNode._order;
|
|
162
|
-
} else {
|
|
163
|
-
delete node.fixorder;
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
/*
|
|
169
|
-
* Copies final layout information from the layout graph back to the input
|
|
170
|
-
* graph. This process only copies whitelisted attributes from the layout graph
|
|
171
|
-
* to the input graph, so it serves as a good place to determine what
|
|
172
|
-
* attributes can influence layout.
|
|
173
|
-
*/
|
|
174
|
-
const updateInputGraph = (inputGraph: Graph, layoutGraph: Graph) => {
|
|
175
|
-
inputGraph.nodes().forEach((v) => {
|
|
176
|
-
const inputLabel = inputGraph.node(v);
|
|
177
|
-
|
|
178
|
-
if (inputLabel) {
|
|
179
|
-
const layoutLabel = layoutGraph.node(v)!;
|
|
180
|
-
inputLabel.x = layoutLabel.x;
|
|
181
|
-
inputLabel.y = layoutLabel.y;
|
|
182
|
-
inputLabel._order = layoutLabel.order;
|
|
183
|
-
inputLabel._rank = layoutLabel.rank;
|
|
184
|
-
|
|
185
|
-
if (layoutGraph.children(v)?.length) {
|
|
186
|
-
inputLabel.width = layoutLabel.width;
|
|
187
|
-
inputLabel.height = layoutLabel.height;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
inputGraph.edges().forEach((e) => {
|
|
193
|
-
const inputLabel = inputGraph.edge(e)!;
|
|
194
|
-
const layoutLabel = layoutGraph.edge(e)!;
|
|
195
|
-
|
|
196
|
-
inputLabel.points = layoutLabel ? layoutLabel.points : [];
|
|
197
|
-
if (layoutLabel && layoutLabel.hasOwnProperty("x")) {
|
|
198
|
-
inputLabel.x = layoutLabel.x;
|
|
199
|
-
inputLabel.y = layoutLabel.y;
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
inputGraph.graph().width = layoutGraph.graph().width;
|
|
204
|
-
inputGraph.graph().height = layoutGraph.graph().height;
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const graphNumAttrs = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"];
|
|
208
|
-
const graphDefaults = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb" };
|
|
209
|
-
const graphAttrs = ["acyclicer", "ranker", "rankdir", "align"];
|
|
210
|
-
const nodeNumAttrs = ["width", "height", "layer", "fixorder"]; // 需要传入layer, fixOrder作为参数参考
|
|
211
|
-
const nodeDefaults = { width: 0, height: 0 };
|
|
212
|
-
const edgeNumAttrs = ["minlen", "weight", "width", "height", "labeloffset"];
|
|
213
|
-
const edgeDefaults = {
|
|
214
|
-
minlen: 1,
|
|
215
|
-
weight: 1,
|
|
216
|
-
width: 0,
|
|
217
|
-
height: 0,
|
|
218
|
-
labeloffset: 10,
|
|
219
|
-
labelpos: "r",
|
|
220
|
-
};
|
|
221
|
-
const edgeAttrs = ["labelpos"];
|
|
222
|
-
|
|
223
|
-
/*
|
|
224
|
-
* Constructs a new graph from the input graph, which can be used for layout.
|
|
225
|
-
* This process copies only whitelisted attributes from the input graph to the
|
|
226
|
-
* layout graph. Thus this function serves as a good place to determine what
|
|
227
|
-
* attributes can influence layout.
|
|
228
|
-
*/
|
|
229
|
-
const buildLayoutGraph = (inputGraph: Graph) => {
|
|
230
|
-
const g = new Graph({ multigraph: true, compound: true });
|
|
231
|
-
const graph = canonicalize(inputGraph.graph());
|
|
232
|
-
|
|
233
|
-
const pickedProperties: any = {};
|
|
234
|
-
graphAttrs?.forEach((key) => {
|
|
235
|
-
if (graph[key] !== undefined) pickedProperties[key] = graph[key];
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
g.setGraph(
|
|
239
|
-
Object.assign(
|
|
240
|
-
{},
|
|
241
|
-
graphDefaults,
|
|
242
|
-
selectNumberAttrs(graph, graphNumAttrs),
|
|
243
|
-
pickedProperties
|
|
244
|
-
)
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
inputGraph.nodes().forEach((v) => {
|
|
248
|
-
const node = canonicalize(inputGraph.node(v));
|
|
249
|
-
const defaultNode = {
|
|
250
|
-
...nodeDefaults,
|
|
251
|
-
...node,
|
|
252
|
-
} as Node;
|
|
253
|
-
const defaultAttrs = selectNumberAttrs(defaultNode, nodeNumAttrs) as Node;
|
|
254
|
-
|
|
255
|
-
g.setNode(v, defaultAttrs);
|
|
256
|
-
g.setParent(v, inputGraph.parent(v));
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
inputGraph.edges().forEach((e) => {
|
|
260
|
-
const edge = canonicalize(inputGraph.edge(e));
|
|
261
|
-
|
|
262
|
-
const pickedProperties: any = {};
|
|
263
|
-
edgeAttrs?.forEach((key) => {
|
|
264
|
-
if (edge[key] !== undefined) pickedProperties[key] = edge[key];
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
g.setEdgeObj(
|
|
268
|
-
e,
|
|
269
|
-
Object.assign(
|
|
270
|
-
{},
|
|
271
|
-
edgeDefaults,
|
|
272
|
-
selectNumberAttrs(edge, edgeNumAttrs),
|
|
273
|
-
pickedProperties
|
|
274
|
-
)
|
|
275
|
-
);
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
return g;
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
/*
|
|
282
|
-
* This idea comes from the Gansner paper: to account for edge labels in our
|
|
283
|
-
* layout we split each rank in half by doubling minlen and halving ranksep.
|
|
284
|
-
* Then we can place labels at these mid-points between nodes.
|
|
285
|
-
*
|
|
286
|
-
* We also add some minimal padding to the width to push the label for the edge
|
|
287
|
-
* away from the edge itself a bit.
|
|
288
|
-
*/
|
|
289
|
-
const makeSpaceForEdgeLabels = (g: Graph) => {
|
|
290
|
-
const graph = g.graph();
|
|
291
|
-
if (!graph.ranksep) graph.ranksep = 0;
|
|
292
|
-
graph.ranksep /= 2;
|
|
293
|
-
g.nodes().forEach((n) => {
|
|
294
|
-
const node = g.node(n)!;
|
|
295
|
-
if (!isNaN(node.layer as any)) {
|
|
296
|
-
if (!node.layer) node.layer = 0;
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
g.edges().forEach((e) => {
|
|
300
|
-
const edge = g.edge(e)!;
|
|
301
|
-
edge.minlen! *= 2;
|
|
302
|
-
if (edge.labelpos?.toLowerCase() !== "c") {
|
|
303
|
-
if (graph.rankdir === "TB" || graph.rankdir === "BT") {
|
|
304
|
-
edge.width += edge.labeloffset;
|
|
305
|
-
} else {
|
|
306
|
-
edge.height += edge.labeloffset;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
/*
|
|
313
|
-
* Creates temporary dummy nodes that capture the rank in which each edge's
|
|
314
|
-
* label is going to, if it has one of non-zero width and height. We do this
|
|
315
|
-
* so that we can safely remove empty ranks while preserving balance for the
|
|
316
|
-
* label's position.
|
|
317
|
-
*/
|
|
318
|
-
const injectEdgeLabelProxies = (g: Graph) => {
|
|
319
|
-
g.edges().forEach((e) => {
|
|
320
|
-
const edge = g.edge(e)!;
|
|
321
|
-
if (edge.width && edge.height) {
|
|
322
|
-
const v = g.node(e.v)!;
|
|
323
|
-
const w = g.node(e.w)!;
|
|
324
|
-
const label = {
|
|
325
|
-
e,
|
|
326
|
-
rank:
|
|
327
|
-
((w.rank as number) - (v.rank as number)) / 2 + (v.rank as number),
|
|
328
|
-
};
|
|
329
|
-
addDummyNode(g, "edge-proxy", label, "_ep");
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
const assignRankMinMax = (g: Graph) => {
|
|
335
|
-
let maxRank = 0;
|
|
336
|
-
g.nodes().forEach((v) => {
|
|
337
|
-
const node = g.node(v)!;
|
|
338
|
-
if (node.borderTop) {
|
|
339
|
-
node.minRank = g.node(node.borderTop)?.rank;
|
|
340
|
-
node.maxRank = g.node(node.borderBottom)?.rank;
|
|
341
|
-
maxRank = Math.max(maxRank, node.maxRank || -Infinity);
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
g.graph().maxRank = maxRank;
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
const removeEdgeLabelProxies = (g: Graph) => {
|
|
348
|
-
g.nodes().forEach((v) => {
|
|
349
|
-
const node = g.node(v)!;
|
|
350
|
-
if (node.dummy === "edge-proxy") {
|
|
351
|
-
g.edge((node as any).e)!.labelRank = node.rank;
|
|
352
|
-
g.removeNode(v);
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
const translateGraph = (g: Graph) => {
|
|
358
|
-
let minX: number;
|
|
359
|
-
let maxX = 0;
|
|
360
|
-
let minY: number;
|
|
361
|
-
let maxY = 0;
|
|
362
|
-
const graphLabel = g.graph();
|
|
363
|
-
const marginX = graphLabel.marginx || 0;
|
|
364
|
-
const marginY = graphLabel.marginy || 0;
|
|
365
|
-
|
|
366
|
-
const getExtremes = (attrs: any) => {
|
|
367
|
-
if (!attrs) return;
|
|
368
|
-
const x = attrs.x;
|
|
369
|
-
const y = attrs.y;
|
|
370
|
-
const w = attrs.width;
|
|
371
|
-
const h = attrs.height;
|
|
372
|
-
if (!isNaN(x) && !isNaN(w)) {
|
|
373
|
-
if (minX === undefined) {
|
|
374
|
-
minX = x - w / 2;
|
|
375
|
-
}
|
|
376
|
-
minX = Math.min(minX, x - w / 2);
|
|
377
|
-
maxX = Math.max(maxX, x + w / 2);
|
|
378
|
-
}
|
|
379
|
-
if (!isNaN(y) && !isNaN(h)) {
|
|
380
|
-
if (minY === undefined) {
|
|
381
|
-
minY = y - h / 2;
|
|
382
|
-
}
|
|
383
|
-
minY = Math.min(minY, y - h / 2);
|
|
384
|
-
maxY = Math.max(maxY, y + h / 2);
|
|
385
|
-
}
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
g.nodes().forEach((v) => {
|
|
389
|
-
getExtremes(g.node(v));
|
|
390
|
-
});
|
|
391
|
-
g.edges().forEach((e) => {
|
|
392
|
-
const edge = g.edge(e)!;
|
|
393
|
-
if (edge?.hasOwnProperty("x")) {
|
|
394
|
-
getExtremes(edge);
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
minX! -= marginX;
|
|
399
|
-
minY! -= marginY;
|
|
400
|
-
|
|
401
|
-
g.nodes().forEach((v) => {
|
|
402
|
-
const node = g.node(v);
|
|
403
|
-
if (node) {
|
|
404
|
-
node.x! -= minX;
|
|
405
|
-
node.y! -= minY;
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
g.edges().forEach((e) => {
|
|
410
|
-
const edge = g.edge(e)!;
|
|
411
|
-
edge.points?.forEach((p) => {
|
|
412
|
-
p.x -= minX;
|
|
413
|
-
p.y -= minY;
|
|
414
|
-
});
|
|
415
|
-
if (edge.hasOwnProperty("x")) {
|
|
416
|
-
edge.x -= minX;
|
|
417
|
-
}
|
|
418
|
-
if (edge.hasOwnProperty("y")) {
|
|
419
|
-
edge.y -= minY;
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
graphLabel.width = maxX - minX! + marginX;
|
|
424
|
-
graphLabel.height = maxY - minY! + marginY;
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
const assignNodeIntersects = (g: Graph) => {
|
|
428
|
-
g.edges().forEach((e) => {
|
|
429
|
-
const edge = g.edge(e)!;
|
|
430
|
-
const nodeV = g.node(e.v)!;
|
|
431
|
-
const nodeW = g.node(e.w)!;
|
|
432
|
-
let p1;
|
|
433
|
-
let p2;
|
|
434
|
-
if (!edge.points) {
|
|
435
|
-
edge.points = [];
|
|
436
|
-
p1 = nodeW;
|
|
437
|
-
p2 = nodeV;
|
|
438
|
-
} else {
|
|
439
|
-
p1 = edge.points[0];
|
|
440
|
-
p2 = edge.points[edge.points.length - 1];
|
|
441
|
-
}
|
|
442
|
-
edge.points.unshift(intersectRect(nodeV, p1));
|
|
443
|
-
edge.points.push(intersectRect(nodeW, p2));
|
|
444
|
-
});
|
|
445
|
-
};
|
|
446
|
-
|
|
447
|
-
const fixupEdgeLabelCoords = (g: Graph) => {
|
|
448
|
-
g.edges().forEach((e) => {
|
|
449
|
-
const edge = g.edge(e)!;
|
|
450
|
-
if (edge?.hasOwnProperty("x")) {
|
|
451
|
-
if (edge.labelpos === "l" || edge.labelpos === "r") {
|
|
452
|
-
edge.width! -= edge.labeloffset;
|
|
453
|
-
}
|
|
454
|
-
switch (edge.labelpos) {
|
|
455
|
-
case "l":
|
|
456
|
-
edge.x -= edge.width! / 2 + edge.labeloffset;
|
|
457
|
-
break;
|
|
458
|
-
case "r":
|
|
459
|
-
edge.x += edge.width! / 2 + edge.labeloffset;
|
|
460
|
-
break;
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
};
|
|
465
|
-
|
|
466
|
-
const reversePointsForReversedEdges = (g: Graph) => {
|
|
467
|
-
g.edges().forEach((e) => {
|
|
468
|
-
const edge = g.edge(e)!;
|
|
469
|
-
if (edge.reversed) {
|
|
470
|
-
edge.points?.reverse();
|
|
471
|
-
}
|
|
472
|
-
});
|
|
473
|
-
};
|
|
474
|
-
|
|
475
|
-
const removeBorderNodes = (g: Graph) => {
|
|
476
|
-
g.nodes().forEach((v) => {
|
|
477
|
-
if (g.children(v)?.length) {
|
|
478
|
-
const node = g.node(v)!;
|
|
479
|
-
const t = g.node(node.borderTop);
|
|
480
|
-
const b = g.node(node.borderBottom);
|
|
481
|
-
const l = g.node(node.borderLeft[node.borderLeft?.length - 1]);
|
|
482
|
-
const r = g.node(node.borderRight[node.borderRight?.length - 1]);
|
|
483
|
-
|
|
484
|
-
node.width = Math.abs(r?.x! - l?.x!) || 10;
|
|
485
|
-
node.height = Math.abs(b?.y! - t?.y!) || 10;
|
|
486
|
-
node.x = (l?.x || 0) + node.width / 2;
|
|
487
|
-
node.y = (t?.y || 0) + node.height / 2;
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
|
|
491
|
-
g.nodes().forEach((v) => {
|
|
492
|
-
if (g.node(v)?.dummy === "border") {
|
|
493
|
-
g.removeNode(v);
|
|
494
|
-
}
|
|
495
|
-
});
|
|
496
|
-
};
|
|
497
|
-
|
|
498
|
-
const removeSelfEdges = (g: Graph) => {
|
|
499
|
-
g.edges().forEach((e) => {
|
|
500
|
-
if (e.v === e.w) {
|
|
501
|
-
const node = g.node(e.v)!;
|
|
502
|
-
if (!node.selfEdges) {
|
|
503
|
-
node.selfEdges = [];
|
|
504
|
-
}
|
|
505
|
-
node.selfEdges.push({ e, label: g.edge(e) });
|
|
506
|
-
g.removeEdgeObj(e);
|
|
507
|
-
}
|
|
508
|
-
});
|
|
509
|
-
};
|
|
510
|
-
|
|
511
|
-
const insertSelfEdges = (g: Graph) => {
|
|
512
|
-
const layers = buildLayerMatrix(g);
|
|
513
|
-
layers?.forEach((layer: string[]) => {
|
|
514
|
-
let orderShift = 0;
|
|
515
|
-
layer?.forEach((v: string, i: number) => {
|
|
516
|
-
const node = g.node(v)!;
|
|
517
|
-
node.order = i + orderShift;
|
|
518
|
-
node.selfEdges?.forEach((selfEdge: any) => {
|
|
519
|
-
addDummyNode(
|
|
520
|
-
g,
|
|
521
|
-
"selfedge",
|
|
522
|
-
{
|
|
523
|
-
width: selfEdge.label.width,
|
|
524
|
-
height: selfEdge.label.height,
|
|
525
|
-
rank: node.rank,
|
|
526
|
-
order: i + ++orderShift,
|
|
527
|
-
e: selfEdge.e,
|
|
528
|
-
label: selfEdge.label,
|
|
529
|
-
},
|
|
530
|
-
"_se"
|
|
531
|
-
);
|
|
532
|
-
});
|
|
533
|
-
delete node.selfEdges;
|
|
534
|
-
});
|
|
535
|
-
});
|
|
536
|
-
};
|
|
537
|
-
|
|
538
|
-
const positionSelfEdges = (g: Graph) => {
|
|
539
|
-
g.nodes().forEach((v) => {
|
|
540
|
-
const node = g.node(v)!;
|
|
541
|
-
if (node.dummy === "selfedge") {
|
|
542
|
-
const selfNode = g.node(node.e.v)!;
|
|
543
|
-
const x = selfNode.x! + selfNode.width! / 2;
|
|
544
|
-
const y = selfNode.y!;
|
|
545
|
-
const dx = node.x! - x;
|
|
546
|
-
const dy = selfNode.height! / 2;
|
|
547
|
-
g.setEdgeObj(node.e, node.label);
|
|
548
|
-
g.removeNode(v);
|
|
549
|
-
node.label.points = [
|
|
550
|
-
{ x: x + (2 * dx) / 3, y: y - dy },
|
|
551
|
-
{ x: x + (5 * dx) / 6, y: y - dy },
|
|
552
|
-
{ y, x: x + dx },
|
|
553
|
-
{ x: x + (5 * dx) / 6, y: y + dy },
|
|
554
|
-
{ x: x + (2 * dx) / 3, y: y + dy },
|
|
555
|
-
];
|
|
556
|
-
node.label.x = node.x;
|
|
557
|
-
node.label.y = node.y;
|
|
558
|
-
}
|
|
559
|
-
});
|
|
560
|
-
};
|
|
561
|
-
|
|
562
|
-
const selectNumberAttrs = (obj: Record<string, any>, attrs: string[]) => {
|
|
563
|
-
const pickedProperties: Record<string, any> = {};
|
|
564
|
-
attrs?.forEach((key: string) => {
|
|
565
|
-
if (obj[key] === undefined) return;
|
|
566
|
-
pickedProperties[key] = (+obj[key]);
|
|
567
|
-
});
|
|
568
|
-
return pickedProperties;
|
|
569
|
-
};
|
|
570
|
-
|
|
571
|
-
const canonicalize = (attrs: Record<string, any> = {}) => {
|
|
572
|
-
const newAttrs: Record<string, any> = {};
|
|
573
|
-
Object.keys(attrs).forEach((k: string) => {
|
|
574
|
-
newAttrs[k.toLowerCase()] = attrs[k];
|
|
575
|
-
});
|
|
576
|
-
return newAttrs;
|
|
577
|
-
};
|
|
578
|
-
|
|
579
|
-
export default layout;
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { Graph } from "../graph";
|
|
2
|
-
import { addBorderNode, addDummyNode } from "./util";
|
|
3
|
-
|
|
4
|
-
/*
|
|
5
|
-
* A nesting graph creates dummy nodes for the tops and bottoms of subgraphs,
|
|
6
|
-
* adds appropriate edges to ensure that all cluster nodes are placed between
|
|
7
|
-
* these boundries, and ensures that the graph is connected.
|
|
8
|
-
*
|
|
9
|
-
* In addition we ensure, through the use of the minlen property, that nodes
|
|
10
|
-
* and subgraph border nodes to not end up on the same rank.
|
|
11
|
-
*
|
|
12
|
-
* Preconditions:
|
|
13
|
-
*
|
|
14
|
-
* 1. Input graph is a DAG
|
|
15
|
-
* 2. Nodes in the input graph has a minlen attribute
|
|
16
|
-
*
|
|
17
|
-
* Postconditions:
|
|
18
|
-
*
|
|
19
|
-
* 1. Input graph is connected.
|
|
20
|
-
* 2. Dummy nodes are added for the tops and bottoms of subgraphs.
|
|
21
|
-
* 3. The minlen attribute for nodes is adjusted to ensure nodes do not
|
|
22
|
-
* get placed on the same rank as subgraph border nodes.
|
|
23
|
-
*
|
|
24
|
-
* The nesting graph idea comes from Sander, "Layout of Compound Directed
|
|
25
|
-
* Graphs."
|
|
26
|
-
*/
|
|
27
|
-
const run = (g: Graph) => {
|
|
28
|
-
const root = addDummyNode(g, "root", {}, "_root");
|
|
29
|
-
const depths = treeDepths(g);
|
|
30
|
-
let maxDepth = Math.max(...Object.values(depths));
|
|
31
|
-
|
|
32
|
-
if (Math.abs(maxDepth) === Infinity) {
|
|
33
|
-
maxDepth = 1;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const height = maxDepth - 1; // Note: depths is an Object not an array
|
|
37
|
-
const nodeSep = 2 * height + 1;
|
|
38
|
-
|
|
39
|
-
g.graph().nestingRoot = root;
|
|
40
|
-
|
|
41
|
-
// Multiply minlen by nodeSep to align nodes on non-border ranks.
|
|
42
|
-
g.edges().forEach((e) => {
|
|
43
|
-
g.edge(e)!.minlen! *= nodeSep;
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// Calculate a weight that is sufficient to keep subgraphs vertically compact
|
|
47
|
-
const weight = sumWeights(g) + 1;
|
|
48
|
-
|
|
49
|
-
// Create border nodes and link them up
|
|
50
|
-
g.children()?.forEach((child) => {
|
|
51
|
-
dfs(g, root, nodeSep, weight, height, depths, child);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// Save the multiplier for node layers for later removal of empty border
|
|
55
|
-
// layers.
|
|
56
|
-
g.graph().nodeRankFactor = nodeSep;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const dfs = (
|
|
60
|
-
g: Graph,
|
|
61
|
-
root: string,
|
|
62
|
-
nodeSep: number,
|
|
63
|
-
weight: number,
|
|
64
|
-
height: number,
|
|
65
|
-
depths:Record<string, number>,
|
|
66
|
-
v: string
|
|
67
|
-
) => {
|
|
68
|
-
const children = g.children(v);
|
|
69
|
-
if (!children?.length) {
|
|
70
|
-
if (v !== root) {
|
|
71
|
-
g.setEdge(root, v, { weight: 0, minlen: nodeSep });
|
|
72
|
-
}
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const top = addBorderNode(g, "_bt");
|
|
77
|
-
const bottom = addBorderNode(g, "_bb");
|
|
78
|
-
const label = g.node(v)!;
|
|
79
|
-
|
|
80
|
-
g.setParent(top, v);
|
|
81
|
-
label.borderTop = top;
|
|
82
|
-
g.setParent(bottom, v);
|
|
83
|
-
label.borderBottom = bottom;
|
|
84
|
-
|
|
85
|
-
children?.forEach((child) => {
|
|
86
|
-
dfs(g, root, nodeSep, weight, height, depths, child);
|
|
87
|
-
|
|
88
|
-
const childNode = g.node(child)!;
|
|
89
|
-
const childTop = childNode.borderTop ? childNode.borderTop : child;
|
|
90
|
-
const childBottom = childNode.borderBottom ? childNode.borderBottom : child;
|
|
91
|
-
const thisWeight = childNode.borderTop ? weight : 2 * weight;
|
|
92
|
-
const minlen = childTop !== childBottom ? 1 : height - depths[v] + 1;
|
|
93
|
-
|
|
94
|
-
g.setEdge(top, childTop, {
|
|
95
|
-
minlen,
|
|
96
|
-
weight: thisWeight,
|
|
97
|
-
nestingEdge: true,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
g.setEdge(childBottom, bottom, {
|
|
101
|
-
minlen,
|
|
102
|
-
weight: thisWeight,
|
|
103
|
-
nestingEdge: true,
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
if (!g.parent(v)) {
|
|
108
|
-
g.setEdge(root, top, { weight: 0, minlen: height + depths[v] });
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const treeDepths = (g: Graph) => {
|
|
113
|
-
const depths: Record<string, number> = {};
|
|
114
|
-
const dfs = (v: string, depth: number) => {
|
|
115
|
-
const children = g.children(v);
|
|
116
|
-
children?.forEach((child) => dfs(child, depth + 1));
|
|
117
|
-
depths[v] = depth;
|
|
118
|
-
};
|
|
119
|
-
g.children()?.forEach((v) => dfs(v, 1));
|
|
120
|
-
return depths;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const sumWeights = (g: Graph) => {
|
|
124
|
-
let result = 0;
|
|
125
|
-
g.edges().forEach((e) => {
|
|
126
|
-
result += g.edge(e)!.weight!;
|
|
127
|
-
});
|
|
128
|
-
return result;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const cleanup = (g: Graph) => {
|
|
132
|
-
const graphLabel = g.graph();
|
|
133
|
-
graphLabel.nestingRoot && g.removeNode(graphLabel.nestingRoot);
|
|
134
|
-
delete graphLabel.nestingRoot;
|
|
135
|
-
g.edges().forEach((e: any) => {
|
|
136
|
-
const edge = g.edge(e)!;
|
|
137
|
-
if (edge.nestingEdge) {
|
|
138
|
-
g.removeEdgeObj(e);
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export default { run, cleanup };
|