@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
package/src/util/gpu.ts
DELETED
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import { OutNode, Edge, IndexMap } from '../layout/types';
|
|
2
|
-
import { isNumber } from './';
|
|
3
|
-
import { getEdgeTerminal } from './math';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 将 number | Function 类型的参数转换为 return number 的 Function
|
|
8
|
-
* @param {number | Function} value 需要被转换的值
|
|
9
|
-
* @param {number} defaultV 返回函数的默认返回值
|
|
10
|
-
* @return {Function} 转换后的函数
|
|
11
|
-
*/
|
|
12
|
-
export const proccessToFunc = (value: number | Function | undefined, defaultV?: number): ((d?: any) => number) => {
|
|
13
|
-
let func;
|
|
14
|
-
if (!value) {
|
|
15
|
-
func = () => {
|
|
16
|
-
return defaultV || 1;
|
|
17
|
-
};
|
|
18
|
-
} else if (isNumber(value)) {
|
|
19
|
-
func = () => {
|
|
20
|
-
return value;
|
|
21
|
-
};
|
|
22
|
-
} else {
|
|
23
|
-
func = value;
|
|
24
|
-
}
|
|
25
|
-
return func as ((d?: any) => number);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 将节点和边数据转换为 GPU 可读的数组。并返回 maxEdgePerVetex,每个节点上最多的边数
|
|
30
|
-
* @param {NodeConfig[]} nodes 需要被转换的值
|
|
31
|
-
* @param {EdgeConfig[]} edges 返回函数的默认返回值
|
|
32
|
-
* @return {Object} 转换后的数组及 maxEdgePerVetex 组成的对象
|
|
33
|
-
*/
|
|
34
|
-
export const buildTextureData = (nodes: OutNode[], edges: Edge[]): {
|
|
35
|
-
array: Float32Array,
|
|
36
|
-
maxEdgePerVetex: number
|
|
37
|
-
} => {
|
|
38
|
-
const dataArray = [];
|
|
39
|
-
const nodeDict: any = [];
|
|
40
|
-
const mapIdPos: IndexMap = {};
|
|
41
|
-
let i = 0;
|
|
42
|
-
for (i = 0; i < nodes.length; i++) {
|
|
43
|
-
const n = nodes[i];
|
|
44
|
-
mapIdPos[n.id] = i;
|
|
45
|
-
dataArray.push(n.x);
|
|
46
|
-
dataArray.push(n.y);
|
|
47
|
-
dataArray.push(0);
|
|
48
|
-
dataArray.push(0);
|
|
49
|
-
nodeDict.push([]);
|
|
50
|
-
}
|
|
51
|
-
for (i = 0; i < edges.length; i++) {
|
|
52
|
-
const e = edges[i];
|
|
53
|
-
const source = getEdgeTerminal(e, 'source');
|
|
54
|
-
const target = getEdgeTerminal(e, 'target');
|
|
55
|
-
if (!isNaN(mapIdPos[source]) && !isNaN(mapIdPos[target])) {
|
|
56
|
-
nodeDict[mapIdPos[source]].push(mapIdPos[target]);
|
|
57
|
-
nodeDict[mapIdPos[target]].push(mapIdPos[source]);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
let maxEdgePerVetex = 0;
|
|
62
|
-
for (i = 0; i < nodes.length; i++) {
|
|
63
|
-
const offset: number = dataArray.length;
|
|
64
|
-
const dests = nodeDict[i];
|
|
65
|
-
const len = dests.length;
|
|
66
|
-
dataArray[i * 4 + 2] = offset;
|
|
67
|
-
dataArray[i * 4 + 3] = len;
|
|
68
|
-
maxEdgePerVetex = Math.max(maxEdgePerVetex, len);
|
|
69
|
-
for (let j = 0; j < len; ++j) {
|
|
70
|
-
const dest = dests[j];
|
|
71
|
-
dataArray.push(+dest);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
while (dataArray.length % 4 !== 0) {
|
|
76
|
-
dataArray.push(0);
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
maxEdgePerVetex,
|
|
80
|
-
array: new Float32Array(dataArray),
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* 将节点和边数据转换为 GPU 可读的数组,每条边带有一个属性。并返回 maxEdgePerVetex,每个节点上最多的边数
|
|
86
|
-
* @param {NodeConfig[]} nodes 节点数组
|
|
87
|
-
* @param {EdgeConfig[]} edges 边数组
|
|
88
|
-
* @param {Function} attrs 读取边属性的函数
|
|
89
|
-
* @return {Object} 转换后的数组及 maxEdgePerVetex 组成的对象
|
|
90
|
-
*/
|
|
91
|
-
// export const buildTextureDataWithOneEdgeAttr = (nodes: OutNode[], edges: Edge[], attrs: Function): {
|
|
92
|
-
// array: Float32Array,
|
|
93
|
-
// maxEdgePerVetex: number
|
|
94
|
-
// } => {
|
|
95
|
-
// const dataArray = [];
|
|
96
|
-
// const nodeDict: any = [];
|
|
97
|
-
// const mapIdPos: IndexMap = {};
|
|
98
|
-
// let i = 0;
|
|
99
|
-
// for (i = 0; i < nodes.length; i++) {
|
|
100
|
-
// const n = nodes[i];
|
|
101
|
-
// mapIdPos[n.id] = i;
|
|
102
|
-
// dataArray.push(n.x);
|
|
103
|
-
// dataArray.push(n.y);
|
|
104
|
-
// dataArray.push(0);
|
|
105
|
-
// dataArray.push(0);
|
|
106
|
-
// nodeDict.push([]);
|
|
107
|
-
// }
|
|
108
|
-
// for (i = 0; i < edges.length; i++) {
|
|
109
|
-
// const e = edges[i];
|
|
110
|
-
// nodeDict[mapIdPos[e.source]].push(mapIdPos[e.target]);
|
|
111
|
-
// nodeDict[mapIdPos[e.source]].push(attrs(e)); // 理想边长,后续可以改成每条边不同
|
|
112
|
-
// nodeDict[mapIdPos[e.target]].push(mapIdPos[e.source]);
|
|
113
|
-
// nodeDict[mapIdPos[e.target]].push(attrs(e)); // 理想边长,后续可以改成每条边不同
|
|
114
|
-
// }
|
|
115
|
-
|
|
116
|
-
// let maxEdgePerVetex = 0;
|
|
117
|
-
// for (i = 0; i < nodes.length; i++) {
|
|
118
|
-
// const offset: number = dataArray.length;
|
|
119
|
-
// const dests = nodeDict[i]; // dest 中节点 id 与边长间隔存储,即一位节点 id,一位边长……
|
|
120
|
-
// const len = dests.length;
|
|
121
|
-
// dataArray[i * 4 + 2] = offset;
|
|
122
|
-
// dataArray[i * 4 + 3] = len / 2; // 第四位存储与该节点相关的所有节点个数
|
|
123
|
-
// maxEdgePerVetex = Math.max(maxEdgePerVetex, len / 2);
|
|
124
|
-
// for (let j = 0; j < len; ++j) {
|
|
125
|
-
// const dest = dests[j];
|
|
126
|
-
// dataArray.push(+dest);
|
|
127
|
-
// }
|
|
128
|
-
// }
|
|
129
|
-
|
|
130
|
-
// // 不是 4 的倍数,填充 0
|
|
131
|
-
// while (dataArray.length % 4 !== 0) {
|
|
132
|
-
// dataArray.push(0);
|
|
133
|
-
// }
|
|
134
|
-
// return {
|
|
135
|
-
// array: new Float32Array(dataArray),
|
|
136
|
-
// maxEdgePerVetex
|
|
137
|
-
// }
|
|
138
|
-
// }
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* 将节点和边数据转换为 GPU 可读的数组,每条边带有一个以上属性。并返回 maxEdgePerVetex,每个节点上最多的边数
|
|
142
|
-
* @param {NodeConfig[]} nodes 节点数组
|
|
143
|
-
* @param {EdgeConfig[]} edges 边数组
|
|
144
|
-
* @param {Function} attrs 读取边属性的函数
|
|
145
|
-
* @return {Object} 转换后的数组及 maxEdgePerVetex 组成的对象
|
|
146
|
-
*/
|
|
147
|
-
export const buildTextureDataWithTwoEdgeAttr = (nodes: OutNode[], edges: Edge[], attrs1: Function, attrs2: Function): {
|
|
148
|
-
array: Float32Array,
|
|
149
|
-
maxEdgePerVetex: number
|
|
150
|
-
} => {
|
|
151
|
-
const dataArray = [];
|
|
152
|
-
const nodeDict: any = [];
|
|
153
|
-
const mapIdPos: IndexMap = {};
|
|
154
|
-
let i = 0;
|
|
155
|
-
for (i = 0; i < nodes.length; i++) {
|
|
156
|
-
const n = nodes[i];
|
|
157
|
-
mapIdPos[n.id] = i;
|
|
158
|
-
dataArray.push(n.x);
|
|
159
|
-
dataArray.push(n.y);
|
|
160
|
-
dataArray.push(0);
|
|
161
|
-
dataArray.push(0);
|
|
162
|
-
nodeDict.push([]);
|
|
163
|
-
}
|
|
164
|
-
for (i = 0; i < edges.length; i++) {
|
|
165
|
-
const e = edges[i];
|
|
166
|
-
const source = getEdgeTerminal(e, 'source');
|
|
167
|
-
const target = getEdgeTerminal(e, 'target');
|
|
168
|
-
nodeDict[mapIdPos[source]].push(mapIdPos[target]);
|
|
169
|
-
nodeDict[mapIdPos[source]].push(attrs1(e));
|
|
170
|
-
nodeDict[mapIdPos[source]].push(attrs2(e));
|
|
171
|
-
nodeDict[mapIdPos[source]].push(0);
|
|
172
|
-
nodeDict[mapIdPos[target]].push(mapIdPos[source]);
|
|
173
|
-
nodeDict[mapIdPos[target]].push(attrs1(e));
|
|
174
|
-
nodeDict[mapIdPos[target]].push(attrs2(e));
|
|
175
|
-
nodeDict[mapIdPos[target]].push(0);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
let maxEdgePerVetex = 0;
|
|
179
|
-
for (i = 0; i < nodes.length; i++) {
|
|
180
|
-
const offset: number = dataArray.length;
|
|
181
|
-
const dests = nodeDict[i]; // dest 中节点 id 与边长间隔存储,即一位节点 id,一位边长……
|
|
182
|
-
const len = dests.length;
|
|
183
|
-
// dataArray[i * 4 + 2] = offset;
|
|
184
|
-
// dataArray[i * 4 + 3] = len / 4; // 第四位存储与该节点相关的所有节点个数
|
|
185
|
-
// pack offset & length into float32: offset 20bit, length 12bit
|
|
186
|
-
dataArray[i * 4 + 2] = offset + 1048576 * len / 4;
|
|
187
|
-
dataArray[i * 4 + 3] = 0; // 第四位存储与上一次的距离差值
|
|
188
|
-
maxEdgePerVetex = Math.max(maxEdgePerVetex, len / 4);
|
|
189
|
-
for (let j = 0; j < len; ++j) {
|
|
190
|
-
const dest = dests[j];
|
|
191
|
-
dataArray.push(+dest);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// 不是 4 的倍数,填充 0
|
|
196
|
-
while (dataArray.length % 4 !== 0) {
|
|
197
|
-
dataArray.push(0);
|
|
198
|
-
}
|
|
199
|
-
return {
|
|
200
|
-
maxEdgePerVetex,
|
|
201
|
-
array: new Float32Array(dataArray),
|
|
202
|
-
};
|
|
203
|
-
};
|
|
204
|
-
/**
|
|
205
|
-
* transform the extended attributes of nodes or edges to a texture array
|
|
206
|
-
* @param {string[]} attributeNames attributes' name to be read from items and put into output array
|
|
207
|
-
* @param {ModelConfig[]} items the items to be read
|
|
208
|
-
* @return {Float32Array} the attributes' value array to be read by GPU
|
|
209
|
-
*/
|
|
210
|
-
export const attributesToTextureData = (attributeNames: string[], items: any[]): { array: Float32Array, count: number } => {
|
|
211
|
-
const dataArray: any[] = [];
|
|
212
|
-
const attributeNum = attributeNames.length;
|
|
213
|
-
const attributteStringMap: any = {};
|
|
214
|
-
items.forEach((item: any) => {
|
|
215
|
-
attributeNames.forEach((name: string, i) => {
|
|
216
|
-
if (attributteStringMap[item[name]] === undefined) {
|
|
217
|
-
attributteStringMap[item[name]] = Object.keys(attributteStringMap).length;
|
|
218
|
-
}
|
|
219
|
-
dataArray.push(attributteStringMap[item[name]]);
|
|
220
|
-
// insure each node's attributes take inter number of grids
|
|
221
|
-
if (i === attributeNum - 1) {
|
|
222
|
-
while (dataArray.length % 4 !== 0) {
|
|
223
|
-
dataArray.push(0);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
return {
|
|
229
|
-
array: new Float32Array(dataArray),
|
|
230
|
-
count: Object.keys(attributteStringMap).length
|
|
231
|
-
};
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* transform the number array format of extended attributes of nodes or edges to a texture array
|
|
236
|
-
* @param {string[]} attributeNames attributes' name to be read from items and put into output array
|
|
237
|
-
* @return {Float32Array} the attributes' value array to be read by GPU
|
|
238
|
-
*/
|
|
239
|
-
export const arrayToTextureData = (valueArrays: number[][]): Float32Array => {
|
|
240
|
-
const dataArray: any[] = [];
|
|
241
|
-
const attributeNum = valueArrays.length;
|
|
242
|
-
const itemNum = valueArrays[0].length;
|
|
243
|
-
for (let j = 0; j < itemNum; j++) {
|
|
244
|
-
valueArrays.forEach((valueArray, i) => {
|
|
245
|
-
dataArray.push(valueArray[j]);
|
|
246
|
-
// insure each node's attributes take inter number of grids
|
|
247
|
-
if (i === attributeNum - 1) {
|
|
248
|
-
while (dataArray.length % 4 !== 0) {
|
|
249
|
-
dataArray.push(0);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
return new Float32Array(dataArray);
|
|
256
|
-
};
|
package/src/util/index.ts
DELETED
package/src/util/math.ts
DELETED
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import { Matrix, Model, IndexMap, Edge, Node, OutNode, Degree, NodeMap } from '../layout/types';
|
|
2
|
-
import { isArray } from './array';
|
|
3
|
-
import { isNumber } from './number';
|
|
4
|
-
import { isObject } from './object';
|
|
5
|
-
|
|
6
|
-
export const getEdgeTerminal = (edge: Edge, type: 'source' | 'target') => {
|
|
7
|
-
const terminal = edge[type];
|
|
8
|
-
if (isObject(terminal)) {
|
|
9
|
-
return terminal.cell;
|
|
10
|
-
}
|
|
11
|
-
return terminal;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const getDegree = (n: number, nodeIdxMap: IndexMap, edges: Edge[] | null) => {
|
|
15
|
-
const degrees: Degree[] = [];
|
|
16
|
-
for (let i = 0; i < n; i++) {
|
|
17
|
-
degrees[i] = {
|
|
18
|
-
in: 0,
|
|
19
|
-
out: 0,
|
|
20
|
-
all: 0
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
if (!edges) return degrees;
|
|
24
|
-
edges.forEach((e) => {
|
|
25
|
-
const source = getEdgeTerminal(e, 'source');
|
|
26
|
-
const target = getEdgeTerminal(e, 'target');
|
|
27
|
-
if (source && degrees[nodeIdxMap[source]]) {
|
|
28
|
-
degrees[nodeIdxMap[source]].out += 1;
|
|
29
|
-
degrees[nodeIdxMap[source]].all += 1;
|
|
30
|
-
}
|
|
31
|
-
if (target && degrees[nodeIdxMap[target]]) {
|
|
32
|
-
degrees[nodeIdxMap[target]].in += 1;
|
|
33
|
-
degrees[nodeIdxMap[target]].all += 1;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
return degrees;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const getDegreeMap = (nodes: Node[], edges: Edge[] | null) => {
|
|
40
|
-
const degreesMap: { [id: string]: Degree } = {};
|
|
41
|
-
nodes.forEach((node) => {
|
|
42
|
-
degreesMap[node.id] = {
|
|
43
|
-
in: 0,
|
|
44
|
-
out: 0,
|
|
45
|
-
all: 0
|
|
46
|
-
};
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
if (!edges) return degreesMap;
|
|
50
|
-
edges.forEach((e) => {
|
|
51
|
-
const source = getEdgeTerminal(e, 'source');
|
|
52
|
-
const target = getEdgeTerminal(e, 'target');
|
|
53
|
-
if (source) {
|
|
54
|
-
degreesMap[source].out += 1;
|
|
55
|
-
degreesMap[source].all += 1;
|
|
56
|
-
}
|
|
57
|
-
if (target) {
|
|
58
|
-
degreesMap[target].in += 1;
|
|
59
|
-
degreesMap[target].all += 1;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
return degreesMap;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export const floydWarshall = (adjMatrix: Matrix[]): Matrix[] => {
|
|
66
|
-
// initialize
|
|
67
|
-
const dist: Matrix[] = [];
|
|
68
|
-
const size = adjMatrix.length;
|
|
69
|
-
for (let i = 0; i < size; i += 1) {
|
|
70
|
-
dist[i] = [];
|
|
71
|
-
for (let j = 0; j < size; j += 1) {
|
|
72
|
-
if (i === j) {
|
|
73
|
-
dist[i][j] = 0;
|
|
74
|
-
} else if (adjMatrix[i][j] === 0 || !adjMatrix[i][j]) {
|
|
75
|
-
dist[i][j] = Infinity;
|
|
76
|
-
} else {
|
|
77
|
-
dist[i][j] = adjMatrix[i][j];
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
// floyd
|
|
82
|
-
for (let k = 0; k < size; k += 1) {
|
|
83
|
-
for (let i = 0; i < size; i += 1) {
|
|
84
|
-
for (let j = 0; j < size; j += 1) {
|
|
85
|
-
if (dist[i][j] > dist[i][k] + dist[k][j]) {
|
|
86
|
-
dist[i][j] = dist[i][k] + dist[k][j];
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return dist;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export const getAdjMatrix = (data: Model, directed: boolean): Matrix[] => {
|
|
95
|
-
const {
|
|
96
|
-
nodes,
|
|
97
|
-
edges
|
|
98
|
-
} = data;
|
|
99
|
-
const matrix: Matrix[] = [];
|
|
100
|
-
// map node with index in data.nodes
|
|
101
|
-
const nodeMap: {
|
|
102
|
-
[key: string]: number;
|
|
103
|
-
} = {};
|
|
104
|
-
|
|
105
|
-
if (!nodes) {
|
|
106
|
-
throw new Error('invalid nodes data!');
|
|
107
|
-
}
|
|
108
|
-
if (nodes) {
|
|
109
|
-
nodes.forEach((node, i) => {
|
|
110
|
-
nodeMap[node.id] = i;
|
|
111
|
-
const row: number[] = [];
|
|
112
|
-
matrix.push(row);
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
edges?.forEach((e) => {
|
|
117
|
-
const source = getEdgeTerminal(e, 'source');
|
|
118
|
-
const target = getEdgeTerminal(e, 'target');
|
|
119
|
-
const sIndex = nodeMap[source as string];
|
|
120
|
-
const tIndex = nodeMap[target as string];
|
|
121
|
-
if (sIndex === undefined || tIndex === undefined) return;
|
|
122
|
-
matrix[sIndex][tIndex] = 1;
|
|
123
|
-
if (!directed) {
|
|
124
|
-
matrix[tIndex][sIndex] = 1;
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
return matrix;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* scale matrix
|
|
132
|
-
* @param matrix [ [], [], [] ]
|
|
133
|
-
* @param ratio
|
|
134
|
-
*/
|
|
135
|
-
export const scaleMatrix = (matrix: Matrix[], ratio: number) => {
|
|
136
|
-
const result: Matrix[] = [];
|
|
137
|
-
matrix.forEach((row) => {
|
|
138
|
-
const newRow: number[] = [];
|
|
139
|
-
row.forEach((v) => {
|
|
140
|
-
newRow.push(v * ratio);
|
|
141
|
-
});
|
|
142
|
-
result.push(newRow);
|
|
143
|
-
});
|
|
144
|
-
return result;
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* depth first traverse, from leaves to root, children in inverse order
|
|
149
|
-
* if the fn returns false, terminate the traverse
|
|
150
|
-
*/
|
|
151
|
-
const traverseUp = <T extends { children?: T[] }>(data: T, fn: (param: T) => boolean) => {
|
|
152
|
-
if (data && data.children) {
|
|
153
|
-
for (let i = data.children.length - 1; i >= 0; i--) {
|
|
154
|
-
if (!traverseUp(data.children[i], fn)) return;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (!fn(data)) {
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
return true;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* depth first traverse, from leaves to root, children in inverse order
|
|
166
|
-
* if the fn returns false, terminate the traverse
|
|
167
|
-
*/
|
|
168
|
-
export const traverseTreeUp = <T extends { children?: T[] }>(
|
|
169
|
-
data: T,
|
|
170
|
-
fn: (param: T) => boolean,
|
|
171
|
-
) => {
|
|
172
|
-
if (typeof fn !== 'function') {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
traverseUp(data, fn);
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* calculate the bounding box for the nodes according to their x, y, and size
|
|
180
|
-
* @param nodes nodes in the layout
|
|
181
|
-
* @returns
|
|
182
|
-
*/
|
|
183
|
-
export const getLayoutBBox = (nodes: OutNode[]) => {
|
|
184
|
-
let minX = Infinity;
|
|
185
|
-
let minY = Infinity;
|
|
186
|
-
let maxX = -Infinity;
|
|
187
|
-
let maxY = -Infinity;
|
|
188
|
-
nodes.forEach((node) => {
|
|
189
|
-
let size = node.size;
|
|
190
|
-
if (isArray(size)) {
|
|
191
|
-
if (size.length === 1) size = [size[0], size[0]];
|
|
192
|
-
} else if (isNumber(size)) {
|
|
193
|
-
size = [size, size];
|
|
194
|
-
} else if (size === undefined || isNaN(size as any)) {
|
|
195
|
-
size = [30, 30];
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const halfSize = [size[0] / 2, size[1] / 2];
|
|
199
|
-
const left = node.x - halfSize[0];
|
|
200
|
-
const right = node.x + halfSize[0];
|
|
201
|
-
const top = node.y - halfSize[1];
|
|
202
|
-
const bottom = node.y + halfSize[1];
|
|
203
|
-
|
|
204
|
-
if (minX > left) minX = left;
|
|
205
|
-
if (minY > top) minY = top;
|
|
206
|
-
if (maxX < right) maxX = right;
|
|
207
|
-
if (maxY < bottom) maxY = bottom;
|
|
208
|
-
});
|
|
209
|
-
return { minX, minY, maxX, maxY };
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* 获取节点集合的平均位置信息
|
|
214
|
-
* @param nodes 节点集合
|
|
215
|
-
* @returns 平局内置
|
|
216
|
-
*/
|
|
217
|
-
export const getAvgNodePosition = (nodes: OutNode[]) => {
|
|
218
|
-
const totalNodes = { x: 0, y: 0 };
|
|
219
|
-
nodes.forEach((node) => {
|
|
220
|
-
totalNodes.x += node.x || 0;
|
|
221
|
-
totalNodes.y += node.y || 0;
|
|
222
|
-
});
|
|
223
|
-
// 获取均值向量
|
|
224
|
-
const length = nodes.length || 1;
|
|
225
|
-
return {
|
|
226
|
-
x: totalNodes.x / length,
|
|
227
|
-
y: totalNodes.y / length,
|
|
228
|
-
};
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
// 找出指定节点关联的边的起点或终点
|
|
232
|
-
const getCoreNode = (type: 'source' | 'target', node: Node, edges: Edge[]) => {
|
|
233
|
-
if (type === 'source') {
|
|
234
|
-
return (edges?.find((edge) => edge.target === node.id)?.source || {}) as Node;
|
|
235
|
-
}
|
|
236
|
-
return (edges?.find((edge) => edge.source === node.id)?.target || {}) as Node;
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
// 找出指定节点为起点或终点的所有一度叶子节点
|
|
240
|
-
const getRelativeNodeIds = (type: 'source' | 'target' | 'both', coreNode: Node, edges: Edge[]) => {
|
|
241
|
-
let relativeNodes: string[] = [];
|
|
242
|
-
switch (type) {
|
|
243
|
-
case 'source':
|
|
244
|
-
relativeNodes = edges?.filter((edge) => edge.source === coreNode.id).map((edge) => edge.target);
|
|
245
|
-
break;
|
|
246
|
-
case 'target':
|
|
247
|
-
relativeNodes = edges?.filter((edge) => edge.target === coreNode.id).map((edge) => edge.source);
|
|
248
|
-
break;
|
|
249
|
-
case 'both':
|
|
250
|
-
relativeNodes = edges
|
|
251
|
-
?.filter((edge) => edge.source === coreNode.id)
|
|
252
|
-
.map((edge) => edge.target)
|
|
253
|
-
.concat(edges?.filter((edge) => edge.target === coreNode.id).map((edge) => edge.source));
|
|
254
|
-
break;
|
|
255
|
-
default:
|
|
256
|
-
break;
|
|
257
|
-
}
|
|
258
|
-
// 去重
|
|
259
|
-
const set = new Set(relativeNodes);
|
|
260
|
-
return Array.from(set);
|
|
261
|
-
};
|
|
262
|
-
// 找出同类型的节点
|
|
263
|
-
const getSameTypeNodes = (type: 'leaf' | 'all', nodeClusterBy: string, node: Node, relativeNodes: Node[], degreesMap: { [id: string]: Degree }) => {
|
|
264
|
-
// @ts-ignore
|
|
265
|
-
const typeName = node[nodeClusterBy] || '';
|
|
266
|
-
// @ts-ignore
|
|
267
|
-
let sameTypeNodes = relativeNodes?.filter((item) => item[nodeClusterBy] === typeName) || [];
|
|
268
|
-
if (type === 'leaf') {
|
|
269
|
-
sameTypeNodes = sameTypeNodes.filter((node) => degreesMap[node.id]?.in === 0 ||degreesMap[node.id]?.out === 0);
|
|
270
|
-
}
|
|
271
|
-
return sameTypeNodes;
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
// 找出与指定节点关联的边的起点或终点出发的所有一度叶子节点
|
|
276
|
-
export const getCoreNodeAndRelativeLeafNodes = (type: 'leaf' | 'all', node: Node, edges: Edge[], nodeClusterBy: string, degreesMap: { [id: string]: Degree }, nodeMap: NodeMap) => {
|
|
277
|
-
const { in: inDegree, out: outDegree } = degreesMap[node.id];
|
|
278
|
-
let coreNode: Node = node;
|
|
279
|
-
let relativeLeafNodes: Node[] = [];
|
|
280
|
-
if (inDegree === 0) {
|
|
281
|
-
// 如果为没有出边的叶子节点,则找出与它关联的边的起点出发的所有一度节点
|
|
282
|
-
coreNode = getCoreNode('source', node, edges);
|
|
283
|
-
relativeLeafNodes = getRelativeNodeIds('both', coreNode, edges).map((nodeId) => nodeMap[nodeId]);
|
|
284
|
-
} else if (outDegree === 0) {
|
|
285
|
-
// 如果为没有入边边的叶子节点,则找出与它关联的边的起点出发的所有一度节点
|
|
286
|
-
coreNode = getCoreNode('target', node, edges);
|
|
287
|
-
relativeLeafNodes = getRelativeNodeIds('both', coreNode, edges).map((nodeId) => nodeMap[nodeId]);
|
|
288
|
-
}
|
|
289
|
-
relativeLeafNodes = relativeLeafNodes.filter(
|
|
290
|
-
(node) => degreesMap[node.id] && (degreesMap[node.id].in === 0 || degreesMap[node.id].out === 0),
|
|
291
|
-
);
|
|
292
|
-
const sameTypeLeafNodes = getSameTypeNodes(type, nodeClusterBy, node, relativeLeafNodes, degreesMap);
|
|
293
|
-
return { coreNode, relativeLeafNodes, sameTypeLeafNodes };
|
|
294
|
-
};
|
package/src/util/number.ts
DELETED
package/src/util/object.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export const isObject = (val: unknown): val is Record<any, any> =>
|
|
2
|
-
val !== null && typeof val === 'object';
|
|
3
|
-
|
|
4
|
-
export const clone = <T>(target: T): T => {
|
|
5
|
-
if (target === null) {
|
|
6
|
-
return target;
|
|
7
|
-
}
|
|
8
|
-
if (target instanceof Date) {
|
|
9
|
-
return new Date(target.getTime()) as any;
|
|
10
|
-
}
|
|
11
|
-
if (target instanceof Array) {
|
|
12
|
-
const cp = [] as any[]
|
|
13
|
-
;(target as any[]).forEach((v) => {
|
|
14
|
-
cp.push(v);
|
|
15
|
-
});
|
|
16
|
-
return cp.map((n: any) => clone<any>(n)) as any;
|
|
17
|
-
}
|
|
18
|
-
if (typeof target === 'object' && Object.keys(target).length) {
|
|
19
|
-
const cp = { ...(target as { [key: string]: any }) } as {
|
|
20
|
-
[key: string]: any
|
|
21
|
-
};
|
|
22
|
-
Object.keys(cp).forEach((k) => {
|
|
23
|
-
cp[k] = clone<any>(cp[k]);
|
|
24
|
-
});
|
|
25
|
-
return cp as T;
|
|
26
|
-
}
|
|
27
|
-
return target;
|
|
28
|
-
};
|
package/src/util/string.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export const isString = (val: unknown): val is string => typeof val === 'string';
|
|
2
|
-
|
|
3
|
-
const cacheStringFunction = <T extends (str: string) => string>(fn: T): T => {
|
|
4
|
-
const cache: Record<string, string> = Object.create(null);
|
|
5
|
-
return ((str: string) => {
|
|
6
|
-
const hit = cache[str];
|
|
7
|
-
return hit || (cache[str] = fn(str));
|
|
8
|
-
}) as any;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const camelizeRE = /-(\w)/g;
|
|
12
|
-
export const camelize = cacheStringFunction((str: string): string => {
|
|
13
|
-
return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// export const capitalize = cacheStringFunction(
|
|
17
|
-
// (str: string) => str.charAt(0).toUpperCase() + str.slice(1),
|
|
18
|
-
// )
|