@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,96 +0,0 @@
|
|
|
1
|
-
import { Edge, Graph, Node } from "../graph";
|
|
2
|
-
import { addDummyNode } from "./util";
|
|
3
|
-
|
|
4
|
-
/*
|
|
5
|
-
* Breaks any long edges in the graph into short segments that span 1 layer
|
|
6
|
-
* each. This operation is undoable with the denormalize function.
|
|
7
|
-
*
|
|
8
|
-
* Pre-conditions:
|
|
9
|
-
*
|
|
10
|
-
* 1. The input graph is a DAG.
|
|
11
|
-
* 2. Each node in the graph has a "rank" property.
|
|
12
|
-
*
|
|
13
|
-
* Post-condition:
|
|
14
|
-
*
|
|
15
|
-
* 1. All edges in the graph have a length of 1.
|
|
16
|
-
* 2. Dummy nodes are added where edges have been split into segments.
|
|
17
|
-
* 3. The graph is augmented with a "dummyChains" attribute which contains
|
|
18
|
-
* the first dummy in each chain of dummy nodes produced.
|
|
19
|
-
*/
|
|
20
|
-
const run = (g: Graph) => {
|
|
21
|
-
g.graph().dummyChains = [];
|
|
22
|
-
g.edges().forEach((edge) => normalizeEdge(g, edge));
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const normalizeEdge = (g: Graph, e: Edge) => {
|
|
26
|
-
let v = e.v;
|
|
27
|
-
let vRank = g.node(v)!.rank as number;
|
|
28
|
-
const w = e.w;
|
|
29
|
-
const wRank = g.node(w)!.rank as number;
|
|
30
|
-
const name = e.name;
|
|
31
|
-
const edgeLabel = g.edge(e)!;
|
|
32
|
-
const labelRank = edgeLabel.labelRank;
|
|
33
|
-
|
|
34
|
-
if (wRank === vRank + 1) return;
|
|
35
|
-
|
|
36
|
-
g.removeEdgeObj(e);
|
|
37
|
-
|
|
38
|
-
const graph = g.graph();
|
|
39
|
-
|
|
40
|
-
let dummy: string;
|
|
41
|
-
let attrs: Node<Record<string, any>>;
|
|
42
|
-
let i;
|
|
43
|
-
for (i = 0, ++vRank; vRank < wRank; ++i, ++vRank) {
|
|
44
|
-
edgeLabel.points = [];
|
|
45
|
-
attrs = {
|
|
46
|
-
edgeLabel,
|
|
47
|
-
width: 0,
|
|
48
|
-
height: 0,
|
|
49
|
-
edgeObj: e,
|
|
50
|
-
rank: vRank,
|
|
51
|
-
};
|
|
52
|
-
dummy = addDummyNode(g, "edge", attrs, "_d");
|
|
53
|
-
if (vRank === labelRank) {
|
|
54
|
-
attrs.width = edgeLabel.width!;
|
|
55
|
-
attrs.height = edgeLabel.height!;
|
|
56
|
-
attrs.dummy = "edge-label";
|
|
57
|
-
attrs.labelpos = edgeLabel.labelpos;
|
|
58
|
-
}
|
|
59
|
-
g.setEdge(v, dummy, { weight: edgeLabel.weight }, name);
|
|
60
|
-
if (i === 0) {
|
|
61
|
-
if (!graph.dummyChains) graph.dummyChains = [];
|
|
62
|
-
graph.dummyChains!.push(dummy);
|
|
63
|
-
}
|
|
64
|
-
v = dummy;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
g.setEdge(v, w, { weight: edgeLabel.weight }, name);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const undo = (g: Graph) => {
|
|
71
|
-
g.graph().dummyChains?.forEach((v) => {
|
|
72
|
-
let node = g.node(v)!;
|
|
73
|
-
const origLabel = node.edgeLabel;
|
|
74
|
-
let w;
|
|
75
|
-
if (node.edgeObj) {
|
|
76
|
-
g.setEdgeObj(node.edgeObj, origLabel);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
let currentV = v;
|
|
80
|
-
while (node.dummy) {
|
|
81
|
-
w = g.successors(currentV)![0];
|
|
82
|
-
g.removeNode(currentV);
|
|
83
|
-
origLabel.points.push({ x: node.x, y: node.y });
|
|
84
|
-
if (node.dummy === "edge-label") {
|
|
85
|
-
origLabel.x = node.x;
|
|
86
|
-
origLabel.y = node.y;
|
|
87
|
-
origLabel.width = node.width;
|
|
88
|
-
origLabel.height = node.height;
|
|
89
|
-
}
|
|
90
|
-
currentV = w;
|
|
91
|
-
node = g.node(currentV)!;
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export default { run, undo };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Graph } from "../../graph";
|
|
2
|
-
|
|
3
|
-
const addSubgraphConstraints = (g: Graph, cg: Graph, vs: string[]) => {
|
|
4
|
-
const prev: Record<string, string> = {};
|
|
5
|
-
let rootPrev: string;
|
|
6
|
-
|
|
7
|
-
vs?.forEach((v) => {
|
|
8
|
-
let child = g.parent(v);
|
|
9
|
-
let parent;
|
|
10
|
-
let prevChild;
|
|
11
|
-
while (child) {
|
|
12
|
-
parent = g.parent(child);
|
|
13
|
-
if (parent) {
|
|
14
|
-
prevChild = prev[parent];
|
|
15
|
-
prev[parent] = child;
|
|
16
|
-
} else {
|
|
17
|
-
prevChild = rootPrev;
|
|
18
|
-
rootPrev = child;
|
|
19
|
-
}
|
|
20
|
-
if (prevChild && prevChild !== child) {
|
|
21
|
-
cg.setEdge(prevChild, child);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
child = parent;
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default addSubgraphConstraints;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Graph } from "../../graph";
|
|
2
|
-
|
|
3
|
-
const barycenter = (g: Graph, movable: string[]) => {
|
|
4
|
-
return movable.map((v) => {
|
|
5
|
-
const inV = g.inEdges(v);
|
|
6
|
-
if (!inV?.length) {
|
|
7
|
-
return { v };
|
|
8
|
-
} {
|
|
9
|
-
const result = { sum: 0, weight: 0 };
|
|
10
|
-
inV?.forEach((e) => {
|
|
11
|
-
const edge = g.edge(e)!;
|
|
12
|
-
const nodeU = g.node(e.v)!;
|
|
13
|
-
result.sum += (edge.weight! * (nodeU.order as number));
|
|
14
|
-
result.weight += edge.weight!;
|
|
15
|
-
});
|
|
16
|
-
return {
|
|
17
|
-
v,
|
|
18
|
-
barycenter: result.sum / result.weight,
|
|
19
|
-
weight: result.weight
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export default barycenter;
|
|
26
|
-
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { Graph } from "../../graph";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Constructs a graph that can be used to sort a layer of nodes. The graph will
|
|
5
|
-
* contain all base and subgraph nodes from the request layer in their original
|
|
6
|
-
* hierarchy and any edges that are incident on these nodes and are of the type
|
|
7
|
-
* requested by the "relationship" parameter.
|
|
8
|
-
*
|
|
9
|
-
* Nodes from the requested rank that do not have parents are assigned a root
|
|
10
|
-
* node in the output graph, which is set in the root graph attribute. This
|
|
11
|
-
* makes it easy to walk the hierarchy of movable nodes during ordering.
|
|
12
|
-
*
|
|
13
|
-
* Pre-conditions:
|
|
14
|
-
*
|
|
15
|
-
* 1. Input graph is a DAG
|
|
16
|
-
* 2. Base nodes in the input graph have a rank attribute
|
|
17
|
-
* 3. Subgraph nodes in the input graph has minRank and maxRank attributes
|
|
18
|
-
* 4. Edges have an assigned weight
|
|
19
|
-
*
|
|
20
|
-
* Post-conditions:
|
|
21
|
-
*
|
|
22
|
-
* 1. Output graph has all nodes in the movable rank with preserved
|
|
23
|
-
* hierarchy.
|
|
24
|
-
* 2. Root nodes in the movable layer are made children of the node
|
|
25
|
-
* indicated by the root attribute of the graph.
|
|
26
|
-
* 3. Non-movable nodes incident on movable nodes, selected by the
|
|
27
|
-
* relationship parameter, are included in the graph (without hierarchy).
|
|
28
|
-
* 4. Edges incident on movable nodes, selected by the relationship
|
|
29
|
-
* parameter, are added to the output graph.
|
|
30
|
-
* 5. The weights for copied edges are aggregated as need, since the output
|
|
31
|
-
* graph is not a multi-graph.
|
|
32
|
-
*/
|
|
33
|
-
const buildLayerGraph = (
|
|
34
|
-
g: Graph,
|
|
35
|
-
rank: number,
|
|
36
|
-
relationship: "inEdges" | "outEdges"
|
|
37
|
-
) => {
|
|
38
|
-
const root = createRootNode(g);
|
|
39
|
-
const result = new Graph({ compound: true })
|
|
40
|
-
.setGraph({ root })
|
|
41
|
-
.setDefaultNodeLabel((v: string) => {
|
|
42
|
-
return g.node(v)!;
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
g.nodes().forEach((v) => {
|
|
46
|
-
const node = g.node(v)!;
|
|
47
|
-
const parent = g.parent(v);
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
node.rank === rank ||
|
|
51
|
-
((node.minRank as number) <= rank && rank <= (node.maxRank as number))
|
|
52
|
-
) {
|
|
53
|
-
result.setNode(v);
|
|
54
|
-
result.setParent(v, parent || root);
|
|
55
|
-
|
|
56
|
-
// This assumes we have only short edges!
|
|
57
|
-
g[relationship](v)?.forEach((e) => {
|
|
58
|
-
const u = e.v === v ? e.w : e.v;
|
|
59
|
-
const edge = result.edgeFromArgs(u, v);
|
|
60
|
-
const weight = edge !== undefined ? edge.weight : 0;
|
|
61
|
-
result.setEdge(u, v, { weight: g.edge(e)!.weight! + weight! });
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
if (node.hasOwnProperty("minRank")) {
|
|
65
|
-
result.setNode(v, {
|
|
66
|
-
borderLeft: node.borderLeft[rank],
|
|
67
|
-
borderRight: node.borderRight[rank],
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
return result;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const createRootNode = (g: Graph) => {
|
|
77
|
-
let v;
|
|
78
|
-
while (g.hasNode((v = `_root${Math.random()}`)));
|
|
79
|
-
return v;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export default buildLayerGraph;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* A function that takes a layering (an array of layers, each with an array of
|
|
3
|
-
* ordererd nodes) and a graph and returns a weighted crossing count.
|
|
4
|
-
*
|
|
5
|
-
* Pre-conditions:
|
|
6
|
-
*
|
|
7
|
-
* 1. Input graph must be simple (not a multigraph), directed, and include
|
|
8
|
-
* only simple edges.
|
|
9
|
-
* 2. Edges in the input graph must have assigned weights.
|
|
10
|
-
*
|
|
11
|
-
* Post-conditions:
|
|
12
|
-
*
|
|
13
|
-
* 1. The graph and layering matrix are left unchanged.
|
|
14
|
-
*
|
|
15
|
-
* This algorithm is derived from Barth, et al., "Bilayer Cross Counting."
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import { Graph } from "../../graph";
|
|
19
|
-
import { zipObject } from "../util";
|
|
20
|
-
|
|
21
|
-
const twoLayerCrossCount = (
|
|
22
|
-
g: Graph,
|
|
23
|
-
northLayer: string[],
|
|
24
|
-
southLayer: string[]
|
|
25
|
-
) => {
|
|
26
|
-
// Sort all of the edges between the north and south layers by their position
|
|
27
|
-
// in the north layer and then the south. Map these edges to the position of
|
|
28
|
-
// their head in the south layer.
|
|
29
|
-
const southPos = zipObject(
|
|
30
|
-
southLayer,
|
|
31
|
-
southLayer.map((v, i) => i)
|
|
32
|
-
);
|
|
33
|
-
const unflat = northLayer.map((v) => {
|
|
34
|
-
const unsort = g.outEdges(v)?.map((e) => {
|
|
35
|
-
return { pos: southPos[e.w] || 0, weight: g.edge(e)!.weight };
|
|
36
|
-
});
|
|
37
|
-
return unsort?.sort((a, b) => a.pos - b.pos);
|
|
38
|
-
});
|
|
39
|
-
const southEntries = unflat.flat().filter((entry) => entry !== undefined);
|
|
40
|
-
|
|
41
|
-
// Build the accumulator tree
|
|
42
|
-
let firstIndex = 1;
|
|
43
|
-
while (firstIndex < southLayer.length) firstIndex <<= 1;
|
|
44
|
-
const treeSize = 2 * firstIndex - 1;
|
|
45
|
-
firstIndex -= 1;
|
|
46
|
-
const tree = Array(treeSize).fill(0, 0, treeSize);
|
|
47
|
-
|
|
48
|
-
// Calculate the weighted crossings
|
|
49
|
-
let cc = 0;
|
|
50
|
-
southEntries?.forEach((entry) => {
|
|
51
|
-
if (entry) {
|
|
52
|
-
let index = entry.pos + firstIndex;
|
|
53
|
-
tree[index] += entry.weight;
|
|
54
|
-
let weightSum = 0;
|
|
55
|
-
while (index > 0) {
|
|
56
|
-
if (index % 2) {
|
|
57
|
-
weightSum += tree[index + 1];
|
|
58
|
-
}
|
|
59
|
-
index = (index - 1) >> 1;
|
|
60
|
-
tree[index] += entry.weight;
|
|
61
|
-
}
|
|
62
|
-
cc += entry.weight! * weightSum;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
return cc;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const crossCount = (g: Graph, layering: string[][]) => {
|
|
70
|
-
let cc = 0;
|
|
71
|
-
for (let i = 1; i < layering?.length; i += 1) {
|
|
72
|
-
cc += twoLayerCrossCount(g, layering[i - 1], layering[i]);
|
|
73
|
-
}
|
|
74
|
-
return cc;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export default crossCount;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import initOrder from "./init-order";
|
|
2
|
-
import crossCount from "./cross-count";
|
|
3
|
-
import buildLayerGraph from "./build-layer-graph";
|
|
4
|
-
import addSubgraphConstraints from "./add-subgraph-constraints";
|
|
5
|
-
import sortSubgraph from "./sort-subgraph";
|
|
6
|
-
import { clone } from "../../../../util";
|
|
7
|
-
import { Graph } from "../../graph";
|
|
8
|
-
import { buildLayerMatrix, maxRank } from "../util";
|
|
9
|
-
|
|
10
|
-
/*
|
|
11
|
-
* Applies heuristics to minimize edge crossings in the graph and sets the best
|
|
12
|
-
* order solution as an order attribute on each node.
|
|
13
|
-
*
|
|
14
|
-
* Pre-conditions:
|
|
15
|
-
*
|
|
16
|
-
* 1. Graph must be DAG
|
|
17
|
-
* 2. Graph nodes must be objects with a "rank" attribute
|
|
18
|
-
* 3. Graph edges must have the "weight" attribute
|
|
19
|
-
*
|
|
20
|
-
* Post-conditions:
|
|
21
|
-
*
|
|
22
|
-
* 1. Graph nodes will have an "order" attribute based on the results of the
|
|
23
|
-
* algorithm.
|
|
24
|
-
*/
|
|
25
|
-
const order = (g: Graph) => {
|
|
26
|
-
const mxRank = maxRank(g);
|
|
27
|
-
const range1 = [];
|
|
28
|
-
const range2 = [];
|
|
29
|
-
for (let i = 1; i < mxRank + 1; i++) range1.push(i);
|
|
30
|
-
for (let i = mxRank - 1; i > -1; i--) range2.push(i);
|
|
31
|
-
const downLayerGraphs = buildLayerGraphs(g, range1, "inEdges");
|
|
32
|
-
const upLayerGraphs = buildLayerGraphs(g, range2, "outEdges");
|
|
33
|
-
|
|
34
|
-
let layering = initOrder(g);
|
|
35
|
-
assignOrder(g, layering);
|
|
36
|
-
|
|
37
|
-
let bestCC = Number.POSITIVE_INFINITY;
|
|
38
|
-
let best: string[][];
|
|
39
|
-
for (let i = 0, lastBest = 0; lastBest < 4; ++i, ++lastBest) {
|
|
40
|
-
sweepLayerGraphs(i % 2 ? downLayerGraphs : upLayerGraphs, i % 4 >= 2);
|
|
41
|
-
|
|
42
|
-
layering = buildLayerMatrix(g);
|
|
43
|
-
const cc = crossCount(g, layering);
|
|
44
|
-
if (cc < bestCC) {
|
|
45
|
-
lastBest = 0;
|
|
46
|
-
best = clone(layering);
|
|
47
|
-
bestCC = cc;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// consider use previous result, maybe somewhat reduendant
|
|
52
|
-
layering = initOrder(g);
|
|
53
|
-
assignOrder(g, layering);
|
|
54
|
-
for (let i = 0, lastBest = 0; lastBest < 4; ++i, ++lastBest) {
|
|
55
|
-
sweepLayerGraphs(i % 2 ? downLayerGraphs : upLayerGraphs, i % 4 >= 2, true);
|
|
56
|
-
|
|
57
|
-
layering = buildLayerMatrix(g);
|
|
58
|
-
const cc = crossCount(g, layering);
|
|
59
|
-
if (cc < bestCC) {
|
|
60
|
-
lastBest = 0;
|
|
61
|
-
best = clone(layering);
|
|
62
|
-
bestCC = cc;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
assignOrder(g, best!);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const buildLayerGraphs = (
|
|
69
|
-
g: Graph,
|
|
70
|
-
ranks: number[],
|
|
71
|
-
relationship: "inEdges" | "outEdges"
|
|
72
|
-
) => {
|
|
73
|
-
return ranks.map((rank) => {
|
|
74
|
-
return buildLayerGraph(g, rank, relationship);
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const sweepLayerGraphs = (
|
|
79
|
-
layerGraphs: Graph[],
|
|
80
|
-
biasRight: boolean,
|
|
81
|
-
usePrev?: boolean
|
|
82
|
-
) => {
|
|
83
|
-
const cg = new Graph();
|
|
84
|
-
layerGraphs?.forEach((lg) => {
|
|
85
|
-
const root = lg.graph().root as string;
|
|
86
|
-
const sorted = sortSubgraph(lg, root, cg, biasRight, usePrev);
|
|
87
|
-
for (let i = 0; i < sorted.vs?.length || 0; i++) {
|
|
88
|
-
const lnode = lg.node(sorted.vs[i]);
|
|
89
|
-
if (lnode) {
|
|
90
|
-
lnode.order = i;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
addSubgraphConstraints(lg, cg, sorted.vs);
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const assignOrder = (g: Graph, layering: string[][]) => {
|
|
98
|
-
layering?.forEach((layer) => {
|
|
99
|
-
layer?.forEach((v: string, i: number) => {
|
|
100
|
-
g.node(v)!.order = i;
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export default order;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Graph } from "../../graph";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 按照数据中的结果设置fixorder
|
|
5
|
-
*/
|
|
6
|
-
const initDataOrder = (g: Graph, nodeOrder: string[]) => {
|
|
7
|
-
const simpleNodes = g.nodes().filter((v) => {
|
|
8
|
-
return !g.children(v)?.length;
|
|
9
|
-
});
|
|
10
|
-
const ranks = simpleNodes.map((v) => g.node(v)!.rank as number);
|
|
11
|
-
const maxRank = Math.max(...ranks);
|
|
12
|
-
const layers: string[][] = Array(maxRank + 1).fill([]);
|
|
13
|
-
|
|
14
|
-
nodeOrder?.forEach((n) => {
|
|
15
|
-
const node = g.node(n);
|
|
16
|
-
// 只考虑原有节点,dummy节点需要按照后续算法排出
|
|
17
|
-
if (!node || node?.dummy) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (!isNaN(node.rank as number)) {
|
|
21
|
-
node.fixorder = layers[node.rank as number].length; // 设置fixorder为当层的顺序
|
|
22
|
-
layers[node.rank as number].push(n);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export default initDataOrder;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Graph } from "../../graph";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Assigns an initial order value for each node by performing a DFS search
|
|
5
|
-
* starting from nodes in the first rank. Nodes are assigned an order in their
|
|
6
|
-
* rank as they are first visited.
|
|
7
|
-
*
|
|
8
|
-
* This approach comes from Gansner, et al., "A Technique for Drawing Directed
|
|
9
|
-
* Graphs."
|
|
10
|
-
*
|
|
11
|
-
* Returns a layering matrix with an array per layer and each layer sorted by
|
|
12
|
-
* the order of its nodes.
|
|
13
|
-
*/
|
|
14
|
-
const initOrder = (g: Graph) => {
|
|
15
|
-
const visited: Record<string, boolean> = {};
|
|
16
|
-
const simpleNodes = g.nodes().filter((v) => {
|
|
17
|
-
return !g.children(v)?.length;
|
|
18
|
-
});
|
|
19
|
-
const nodeRanks = simpleNodes.map((v) => (g.node(v)!.rank as number));
|
|
20
|
-
const maxRank = Math.max(...nodeRanks);
|
|
21
|
-
const layers: string[][] = [];
|
|
22
|
-
for (let i = 0; i < maxRank + 1; i++) {
|
|
23
|
-
layers.push([]);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const dfs = (v: string) => {
|
|
27
|
-
if (visited.hasOwnProperty(v)) return;
|
|
28
|
-
visited[v] = true;
|
|
29
|
-
const node = g.node(v)!;
|
|
30
|
-
if (!isNaN(node.rank as number)) {
|
|
31
|
-
layers[node.rank as number].push(v);
|
|
32
|
-
}
|
|
33
|
-
g.successors(v)?.forEach((child) => dfs(child as any));
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const orderedVs = simpleNodes.sort((a, b) => (g.node(a)!.rank as number) - (g.node(b)!.rank as number));
|
|
37
|
-
// const orderedVs = _.sortBy(simpleNodes, function(v) { return g.node(v)!.rank; });
|
|
38
|
-
|
|
39
|
-
// 有fixOrder的,直接排序好放进去
|
|
40
|
-
const beforeSort = orderedVs.filter((n) => {
|
|
41
|
-
return g.node(n)!.fixorder !== undefined;
|
|
42
|
-
});
|
|
43
|
-
const fixOrderNodes = beforeSort.sort((a, b) => (g.node(a)!.fixorder as number) - (g.node(b)!.fixorder as number));
|
|
44
|
-
fixOrderNodes?.forEach((n) => {
|
|
45
|
-
if (!isNaN(g.node(n)!.rank as number)) {
|
|
46
|
-
layers[g.node(n)!.rank as number].push(n);
|
|
47
|
-
}
|
|
48
|
-
visited[n] = true;
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
orderedVs?.forEach(dfs);
|
|
52
|
-
|
|
53
|
-
return layers;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export default initOrder;
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { Graph } from "../../graph";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Given a list of entries of the form {v, barycenter, weight} and a
|
|
5
|
-
* constraint graph this function will resolve any conflicts between the
|
|
6
|
-
* constraint graph and the barycenters for the entries. If the barycenters for
|
|
7
|
-
* an entry would violate a constraint in the constraint graph then we coalesce
|
|
8
|
-
* the nodes in the conflict into a new node that respects the contraint and
|
|
9
|
-
* aggregates barycenter and weight information.
|
|
10
|
-
*
|
|
11
|
-
* This implementation is based on the description in Forster, "A Fast and
|
|
12
|
-
* Simple Hueristic for Constrained Two-Level Crossing Reduction," thought it
|
|
13
|
-
* differs in some specific details.
|
|
14
|
-
*
|
|
15
|
-
* Pre-conditions:
|
|
16
|
-
*
|
|
17
|
-
* 1. Each entry has the form {v, barycenter, weight}, or if the node has
|
|
18
|
-
* no barycenter, then {v}.
|
|
19
|
-
*
|
|
20
|
-
* Returns:
|
|
21
|
-
*
|
|
22
|
-
* A new list of entries of the form {vs, i, barycenter, weight}. The list
|
|
23
|
-
* `vs` may either be a singleton or it may be an aggregation of nodes
|
|
24
|
-
* ordered such that they do not violate constraints from the constraint
|
|
25
|
-
* graph. The property `i` is the lowest original index of any of the
|
|
26
|
-
* elements in `vs`.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
export type ConflictEntry = {
|
|
30
|
-
i: number;
|
|
31
|
-
indegree?: number;
|
|
32
|
-
in?: ConflictEntry[];
|
|
33
|
-
out?: ConflictEntry[];
|
|
34
|
-
vs: string[];
|
|
35
|
-
barycenter?: number;
|
|
36
|
-
weight?: number;
|
|
37
|
-
merged?: boolean;
|
|
38
|
-
fixorder?: number;
|
|
39
|
-
order?: number;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const resolveConflicts = (
|
|
43
|
-
entries: {
|
|
44
|
-
v: string;
|
|
45
|
-
barycenter?: number;
|
|
46
|
-
weight?: number;
|
|
47
|
-
}[],
|
|
48
|
-
cg: Graph
|
|
49
|
-
) => {
|
|
50
|
-
const mappedEntries: Record<string, ConflictEntry> = {};
|
|
51
|
-
entries?.forEach((entry, i: number) => {
|
|
52
|
-
mappedEntries[entry.v] = {
|
|
53
|
-
i,
|
|
54
|
-
indegree: 0,
|
|
55
|
-
in: [],
|
|
56
|
-
out: [],
|
|
57
|
-
vs: [entry.v],
|
|
58
|
-
};
|
|
59
|
-
const tmp = mappedEntries[entry.v];
|
|
60
|
-
if (entry.barycenter !== undefined) {
|
|
61
|
-
tmp.barycenter = entry.barycenter;
|
|
62
|
-
tmp.weight = entry.weight;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
cg.edges()?.forEach((e) => {
|
|
67
|
-
const entryV = mappedEntries[e.v];
|
|
68
|
-
const entryW = mappedEntries[e.w];
|
|
69
|
-
if (entryV !== undefined && entryW !== undefined) {
|
|
70
|
-
entryW.indegree!++;
|
|
71
|
-
entryV.out!.push(mappedEntries[e.w]);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
const sourceSet = Object.values(mappedEntries).filter?.(
|
|
76
|
-
(entry: ConflictEntry) => !entry.indegree
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
return doResolveConflicts(sourceSet);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const doResolveConflicts = (sourceSet: ConflictEntry[]) => {
|
|
83
|
-
const entries = [];
|
|
84
|
-
|
|
85
|
-
const handleIn = (vEntry: ConflictEntry) => {
|
|
86
|
-
return (uEntry: ConflictEntry) => {
|
|
87
|
-
if (uEntry.merged) return;
|
|
88
|
-
if (
|
|
89
|
-
uEntry.barycenter === undefined ||
|
|
90
|
-
vEntry.barycenter === undefined ||
|
|
91
|
-
uEntry.barycenter >= vEntry.barycenter
|
|
92
|
-
) {
|
|
93
|
-
mergeEntries(vEntry, uEntry);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const handleOut = (vEntry: ConflictEntry) => {
|
|
99
|
-
return (wEntry: ConflictEntry) => {
|
|
100
|
-
wEntry["in"]!.push(vEntry);
|
|
101
|
-
if (--wEntry.indegree! === 0) {
|
|
102
|
-
sourceSet.push(wEntry);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
while (sourceSet?.length) {
|
|
108
|
-
const entry = sourceSet.pop()!;
|
|
109
|
-
entries.push(entry);
|
|
110
|
-
entry["in"]!.reverse()?.forEach((e: ConflictEntry) => handleIn(entry)(e));
|
|
111
|
-
entry.out?.forEach((e: ConflictEntry) => handleOut(entry)(e));
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const filtered = entries.filter((entry) => !entry.merged);
|
|
115
|
-
const keys: ("vs" | "i" | "barycenter" | "weight")[] = [
|
|
116
|
-
"vs",
|
|
117
|
-
"i",
|
|
118
|
-
"barycenter",
|
|
119
|
-
"weight",
|
|
120
|
-
];
|
|
121
|
-
return filtered.map((entry) => {
|
|
122
|
-
const picked: Record<string, any> = {};
|
|
123
|
-
keys?.forEach((key) => {
|
|
124
|
-
if (entry[key] === undefined) return;
|
|
125
|
-
picked[key] = entry[key];
|
|
126
|
-
});
|
|
127
|
-
return picked as ConflictEntry;
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const mergeEntries = (target: ConflictEntry, source: ConflictEntry) => {
|
|
132
|
-
let sum = 0;
|
|
133
|
-
let weight = 0;
|
|
134
|
-
|
|
135
|
-
if (target.weight) {
|
|
136
|
-
sum += target.barycenter! * target.weight;
|
|
137
|
-
weight += target.weight;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (source.weight) {
|
|
141
|
-
sum += source.barycenter! * source.weight;
|
|
142
|
-
weight += source.weight;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
target.vs = source.vs?.concat(target.vs);
|
|
146
|
-
target.barycenter = sum / weight;
|
|
147
|
-
target.weight = weight;
|
|
148
|
-
target.i = Math.min(source.i, target.i);
|
|
149
|
-
source.merged = true;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
export default resolveConflicts;
|