@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,165 +0,0 @@
|
|
|
1
|
-
import { slack } from './util';
|
|
2
|
-
import { minBy } from '../util';
|
|
3
|
-
import { Graph } from '../../graph';
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* Constructs a spanning tree with tight edges and adjusted the input node's
|
|
7
|
-
* ranks to achieve this. A tight edge is one that is has a length that matches
|
|
8
|
-
* its "minlen" attribute.
|
|
9
|
-
*
|
|
10
|
-
* The basic structure for this function is derived from Gansner, et al., "A
|
|
11
|
-
* Technique for Drawing Directed Graphs."
|
|
12
|
-
*
|
|
13
|
-
* Pre-conditions:
|
|
14
|
-
*
|
|
15
|
-
* 1. Graph must be a DAG.
|
|
16
|
-
* 2. Graph must be connected.
|
|
17
|
-
* 3. Graph must have at least one node.
|
|
18
|
-
* 5. Graph nodes must have been previously assigned a "rank" property that
|
|
19
|
-
* respects the "minlen" property of incident edges.
|
|
20
|
-
* 6. Graph edges must have a "minlen" property.
|
|
21
|
-
*
|
|
22
|
-
* Post-conditions:
|
|
23
|
-
*
|
|
24
|
-
* - Graph nodes will have their rank adjusted to ensure that all edges are
|
|
25
|
-
* tight.
|
|
26
|
-
*
|
|
27
|
-
* Returns a tree (undirected graph) that is constructed using only "tight"
|
|
28
|
-
* edges.
|
|
29
|
-
*/
|
|
30
|
-
const feasibleTree = (g: Graph) => {
|
|
31
|
-
const t = new Graph({ directed: false });
|
|
32
|
-
|
|
33
|
-
// Choose arbitrary node from which to start our tree
|
|
34
|
-
const start = g.nodes()[0];
|
|
35
|
-
const size = g.nodeCount();
|
|
36
|
-
t.setNode(start, {});
|
|
37
|
-
|
|
38
|
-
let edge: any;
|
|
39
|
-
let delta: number;
|
|
40
|
-
while (tightTree(t, g) < size) {
|
|
41
|
-
edge = findMinSlackEdge(t, g);
|
|
42
|
-
delta = t.hasNode(edge.v) ? slack(g, edge) : -slack(g, edge);
|
|
43
|
-
shiftRanks(t, g, delta);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return t;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/*
|
|
50
|
-
* Finds a maximal tree of tight edges and returns the number of nodes in the
|
|
51
|
-
* tree.
|
|
52
|
-
*/
|
|
53
|
-
const tightTree = (t: Graph, g: Graph) => {
|
|
54
|
-
const dfs = (v: string) => {
|
|
55
|
-
g.nodeEdges(v)!.forEach((e) => {
|
|
56
|
-
const edgeV = e.v;
|
|
57
|
-
const w = (v === edgeV) ? e.w : edgeV;
|
|
58
|
-
if (!t.hasNode(w) && !slack(g, e)) {
|
|
59
|
-
t.setNode(w, {});
|
|
60
|
-
t.setEdge(v, w, {});
|
|
61
|
-
dfs(w);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
t.nodes().forEach(dfs);
|
|
67
|
-
return t.nodeCount();
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/*
|
|
71
|
-
* Constructs a spanning tree with tight edges and adjusted the input node's
|
|
72
|
-
* ranks to achieve this. A tight edge is one that is has a length that matches
|
|
73
|
-
* its "minlen" attribute.
|
|
74
|
-
*
|
|
75
|
-
* The basic structure for this function is derived from Gansner, et al., "A
|
|
76
|
-
* Technique for Drawing Directed Graphs."
|
|
77
|
-
*
|
|
78
|
-
* Pre-conditions:
|
|
79
|
-
*
|
|
80
|
-
* 1. Graph must be a DAG.
|
|
81
|
-
* 2. Graph must be connected.
|
|
82
|
-
* 3. Graph must have at least one node.
|
|
83
|
-
* 5. Graph nodes must have been previously assigned a "rank" property that
|
|
84
|
-
* respects the "minlen" property of incident edges.
|
|
85
|
-
* 6. Graph edges must have a "minlen" property.
|
|
86
|
-
*
|
|
87
|
-
* Post-conditions:
|
|
88
|
-
*
|
|
89
|
-
* - Graph nodes will have their rank adjusted to ensure that all edges are
|
|
90
|
-
* tight.
|
|
91
|
-
*
|
|
92
|
-
* Returns a tree (undirected graph) that is constructed using only "tight"
|
|
93
|
-
* edges.
|
|
94
|
-
*/
|
|
95
|
-
const feasibleTreeWithLayer = (g: Graph) => {
|
|
96
|
-
const t = new Graph({ directed: false }) as any;
|
|
97
|
-
|
|
98
|
-
// Choose arbitrary node from which to start our tree
|
|
99
|
-
const start = g.nodes()[0];
|
|
100
|
-
const size = g.nodes().filter(n => !!g.node(n)).length;
|
|
101
|
-
t.setNode(start, {});
|
|
102
|
-
|
|
103
|
-
let edge: any;
|
|
104
|
-
let delta: number;
|
|
105
|
-
while (tightTreeWithLayer(t, g)! < size) {
|
|
106
|
-
edge = findMinSlackEdge(t, g);
|
|
107
|
-
delta = t.hasNode(edge.v) ? slack(g, edge) : -slack(g, edge);
|
|
108
|
-
shiftRanks(t, g, delta);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return t;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
/*
|
|
116
|
-
* Finds a maximal tree of tight edges and returns the number of nodes in the
|
|
117
|
-
* tree.
|
|
118
|
-
*/
|
|
119
|
-
const tightTreeWithLayer = (t: Graph, g: Graph) => {
|
|
120
|
-
const dfs = (v: string) => {
|
|
121
|
-
g.nodeEdges(v)?.forEach((e) => {
|
|
122
|
-
const edgeV = e.v;
|
|
123
|
-
const w = (v === edgeV) ? e.w : edgeV;
|
|
124
|
-
// 对于指定layer的,直接加入tight-tree,不参与调整
|
|
125
|
-
if (!t.hasNode(w) && (g.node(w)!.layer !== undefined || !slack(g, e))) {
|
|
126
|
-
t.setNode(w, {});
|
|
127
|
-
t.setEdge(v, w, {});
|
|
128
|
-
dfs(w);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
t.nodes().forEach(dfs);
|
|
134
|
-
return t.nodeCount();
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
/*
|
|
138
|
-
* Finds the edge with the smallest slack that is incident on tree and returns
|
|
139
|
-
* it.
|
|
140
|
-
*/
|
|
141
|
-
const findMinSlackEdge = (t: Graph, g: Graph) => {
|
|
142
|
-
return minBy(g.edges(), (e: any) => {
|
|
143
|
-
if (t.hasNode(e.v) !== t.hasNode(e.w)) {
|
|
144
|
-
return slack(g, e);
|
|
145
|
-
}
|
|
146
|
-
return Infinity;
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
const shiftRanks = (t: Graph, g: Graph, delta: number) => {
|
|
151
|
-
t.nodes().forEach((v: string) => {
|
|
152
|
-
if (!g.node(v)!.rank) g.node(v)!.rank = 0;
|
|
153
|
-
(g.node(v)!.rank as number) += delta;
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
export {
|
|
158
|
-
feasibleTree,
|
|
159
|
-
feasibleTreeWithLayer
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
export default {
|
|
163
|
-
feasibleTree,
|
|
164
|
-
feasibleTreeWithLayer
|
|
165
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// "use strict";
|
|
2
|
-
|
|
3
|
-
// var rankUtil = require("./util");
|
|
4
|
-
// var longestPath = rankUtil.longestPathWithLayer;
|
|
5
|
-
// var feasibleTree = require("./feasible-tree").feasibleTreeWithLayer;
|
|
6
|
-
// var networkSimplex = require("./network-simplex");
|
|
7
|
-
|
|
8
|
-
import { longestPath, longestPathWithLayer } from './util';
|
|
9
|
-
import { feasibleTreeWithLayer as feasibleTree } from './feasible-tree';
|
|
10
|
-
import networkSimplex from './network-simplex';
|
|
11
|
-
import { Graph } from '../../graph';
|
|
12
|
-
|
|
13
|
-
/*
|
|
14
|
-
* Assigns a rank to each node in the input graph that respects the "minlen"
|
|
15
|
-
* constraint specified on edges between nodes.
|
|
16
|
-
*
|
|
17
|
-
* This basic structure is derived from Gansner, et al., "A Technique for
|
|
18
|
-
* Drawing Directed Graphs."
|
|
19
|
-
*
|
|
20
|
-
* Pre-conditions:
|
|
21
|
-
*
|
|
22
|
-
* 1. Graph must be a connected DAG
|
|
23
|
-
* 2. Graph nodes must be objects
|
|
24
|
-
* 3. Graph edges must have "weight" and "minlen" attributes
|
|
25
|
-
*
|
|
26
|
-
* Post-conditions:
|
|
27
|
-
*
|
|
28
|
-
* 1. Graph nodes will have a "rank" attribute based on the results of the
|
|
29
|
-
* algorithm. Ranks can start at any index (including negative), we'll
|
|
30
|
-
* fix them up later.
|
|
31
|
-
*/
|
|
32
|
-
const rank = (g: Graph) => {
|
|
33
|
-
switch(g.graph().ranker) {
|
|
34
|
-
case "network-simplex": networkSimplexRanker(g); break;
|
|
35
|
-
case "tight-tree": tightTreeRanker(g); break;
|
|
36
|
-
case "longest-path": longestPathRanker(g); break;
|
|
37
|
-
// default: networkSimplexRanker(g);
|
|
38
|
-
default: tightTreeRanker(g);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// A fast and simple ranker, but results are far from optimal.
|
|
43
|
-
const longestPathRanker = longestPath;
|
|
44
|
-
|
|
45
|
-
const tightTreeRanker = (g: Graph) => {
|
|
46
|
-
longestPathWithLayer(g);
|
|
47
|
-
feasibleTree(g);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const networkSimplexRanker = (g: Graph) => {
|
|
51
|
-
networkSimplex(g);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export default rank;
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import { feasibleTree } from './feasible-tree';
|
|
2
|
-
import { slack, longestPath as initRank } from './util';
|
|
3
|
-
import { minBy, simplify } from '../util';
|
|
4
|
-
import { algorithm } from '@antv/graphlib';
|
|
5
|
-
import { Edge, Graph } from '../../graph';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const { preorder, postorder } = algorithm;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/*
|
|
12
|
-
* The network simplex algorithm assigns ranks to each node in the input graph
|
|
13
|
-
* and iteratively improves the ranking to reduce the length of edges.
|
|
14
|
-
*
|
|
15
|
-
* Preconditions:
|
|
16
|
-
*
|
|
17
|
-
* 1. The input graph must be a DAG.
|
|
18
|
-
* 2. All nodes in the graph must have an object value.
|
|
19
|
-
* 3. All edges in the graph must have "minlen" and "weight" attributes.
|
|
20
|
-
*
|
|
21
|
-
* Postconditions:
|
|
22
|
-
*
|
|
23
|
-
* 1. All nodes in the graph will have an assigned "rank" attribute that has
|
|
24
|
-
* been optimized by the network simplex algorithm. Ranks start at 0.
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* A rough sketch of the algorithm is as follows:
|
|
28
|
-
*
|
|
29
|
-
* 1. Assign initial ranks to each node. We use the longest path algorithm,
|
|
30
|
-
* which assigns ranks to the lowest position possible. In general this
|
|
31
|
-
* leads to very wide bottom ranks and unnecessarily long edges.
|
|
32
|
-
* 2. Construct a feasible tight tree. A tight tree is one such that all
|
|
33
|
-
* edges in the tree have no slack (difference between length of edge
|
|
34
|
-
* and minlen for the edge). This by itself greatly improves the assigned
|
|
35
|
-
* rankings by shorting edges.
|
|
36
|
-
* 3. Iteratively find edges that have negative cut values. Generally a
|
|
37
|
-
* negative cut value indicates that the edge could be removed and a new
|
|
38
|
-
* tree edge could be added to produce a more compact graph.
|
|
39
|
-
*
|
|
40
|
-
* Much of the algorithms here are derived from Gansner, et al., "A Technique
|
|
41
|
-
* for Drawing Directed Graphs." The structure of the file roughly follows the
|
|
42
|
-
* structure of the overall algorithm.
|
|
43
|
-
*/
|
|
44
|
-
const networkSimplex = (og: Graph) => {
|
|
45
|
-
const g = simplify(og);
|
|
46
|
-
initRank(g);
|
|
47
|
-
const t = feasibleTree(g);
|
|
48
|
-
initLowLimValues(t);
|
|
49
|
-
initCutValues(t, g);
|
|
50
|
-
|
|
51
|
-
let e;
|
|
52
|
-
let f;
|
|
53
|
-
while ((e = leaveEdge(t))) {
|
|
54
|
-
f = enterEdge(t, g, e);
|
|
55
|
-
exchangeEdges(t, g, e, f);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/*
|
|
60
|
-
* Initializes cut values for all edges in the tree.
|
|
61
|
-
*/
|
|
62
|
-
export const initCutValues = (t: Graph, g: Graph) => {
|
|
63
|
-
let vs = postorder(t, t.nodes());
|
|
64
|
-
vs = vs?.slice(0, vs?.length - 1);
|
|
65
|
-
vs?.forEach((v: string) => {
|
|
66
|
-
assignCutValue(t, g, v);
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const assignCutValue = (t: Graph, g: Graph, child: string) => {
|
|
71
|
-
const childLab = t.node(child)!;
|
|
72
|
-
const parent = childLab.parent!;
|
|
73
|
-
t.edgeFromArgs(child, parent)!.cutvalue = calcCutValue(t, g, child);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/*
|
|
77
|
-
* Given the tight tree, its graph, and a child in the graph calculate and
|
|
78
|
-
* return the cut value for the edge between the child and its parent.
|
|
79
|
-
*/
|
|
80
|
-
export const calcCutValue = (t: Graph, g: Graph, child: string) => {
|
|
81
|
-
const childLab = t.node(child)!;
|
|
82
|
-
const parent = childLab.parent as string;
|
|
83
|
-
// True if the child is on the tail end of the edge in the directed graph
|
|
84
|
-
let childIsTail = true;
|
|
85
|
-
// The graph's view of the tree edge we're inspecting
|
|
86
|
-
let graphEdge = g.edgeFromArgs(child, parent)!;
|
|
87
|
-
// The accumulated cut value for the edge between this node and its parent
|
|
88
|
-
let cutValue = 0;
|
|
89
|
-
|
|
90
|
-
if (!graphEdge) {
|
|
91
|
-
childIsTail = false;
|
|
92
|
-
graphEdge = g.edgeFromArgs(parent, child)!;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
cutValue = graphEdge.weight!;
|
|
96
|
-
|
|
97
|
-
g.nodeEdges(child)?.forEach((e) => {
|
|
98
|
-
const isOutEdge = e.v === child;
|
|
99
|
-
const other = isOutEdge ? e.w : e.v;
|
|
100
|
-
|
|
101
|
-
if (other !== parent) {
|
|
102
|
-
const pointsToHead = isOutEdge === childIsTail;
|
|
103
|
-
const otherWeight = g.edge(e)!.weight!;
|
|
104
|
-
|
|
105
|
-
cutValue += pointsToHead ? otherWeight : -otherWeight;
|
|
106
|
-
if (isTreeEdge(t, child, other)) {
|
|
107
|
-
const otherCutValue = t.edgeFromArgs(child, other)!.cutvalue;
|
|
108
|
-
cutValue += pointsToHead ? -otherCutValue : otherCutValue;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
return cutValue;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export const initLowLimValues = (tree: Graph, root: string = tree.nodes()[0]) => {
|
|
117
|
-
dfsAssignLowLim(tree, {}, 1, root);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const dfsAssignLowLim = (tree: Graph, visited: Record<string, boolean>, nextLim: number, v: string, parent?: string) => {
|
|
121
|
-
const low = nextLim;
|
|
122
|
-
let useNextLim = nextLim;
|
|
123
|
-
const label = tree.node(v)!;
|
|
124
|
-
|
|
125
|
-
visited[v] = true;
|
|
126
|
-
tree.neighbors(v)?.forEach((w) => {
|
|
127
|
-
if (!visited[w]) {
|
|
128
|
-
useNextLim = dfsAssignLowLim(tree, visited, useNextLim, w, v);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
label.low = low;
|
|
133
|
-
label.lim = useNextLim++;
|
|
134
|
-
if (parent) {
|
|
135
|
-
label.parent = parent;
|
|
136
|
-
} else {
|
|
137
|
-
// TODO should be able to remove this when we incrementally update low lim
|
|
138
|
-
delete label.parent;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return useNextLim;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export const leaveEdge = (tree: Graph) => {
|
|
145
|
-
return tree.edges().find((e) => {
|
|
146
|
-
return tree.edge(e)!.cutvalue < 0;
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
export const enterEdge = (t: Graph, g: Graph, edge: any) => {
|
|
151
|
-
let v = edge.v;
|
|
152
|
-
let w = edge.w;
|
|
153
|
-
|
|
154
|
-
// For the rest of this function we assume that v is the tail and w is the
|
|
155
|
-
// head, so if we don't have this edge in the graph we should flip it to
|
|
156
|
-
// match the correct orientation.
|
|
157
|
-
if (!g.hasEdge(v, w)) {
|
|
158
|
-
v = edge.w;
|
|
159
|
-
w = edge.v;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const vLabel = t.node(v)!;
|
|
163
|
-
const wLabel = t.node(w)!;
|
|
164
|
-
let tailLabel = vLabel;
|
|
165
|
-
let flip = false;
|
|
166
|
-
|
|
167
|
-
// If the root is in the tail of the edge then we need to flip the logic that
|
|
168
|
-
// checks for the head and tail nodes in the candidates function below.
|
|
169
|
-
if ((vLabel.lim as number) > (wLabel.lim as number)) {
|
|
170
|
-
tailLabel = wLabel;
|
|
171
|
-
flip = true;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const candidates = g.edges().filter((edge) => {
|
|
175
|
-
return flip === isDescendant(t, t.node(edge.v), tailLabel) &&
|
|
176
|
-
flip !== isDescendant(t, t.node(edge.w), tailLabel);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
return minBy(candidates, (edge) => { return slack(g, edge); });
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
export const exchangeEdges = (t: Graph, g: Graph, e: Edge, f: Edge) => {
|
|
183
|
-
const v = e.v;
|
|
184
|
-
const w = e.w;
|
|
185
|
-
t.removeEdge(v, w);
|
|
186
|
-
t.setEdge(f.v, f.w, {});
|
|
187
|
-
initLowLimValues(t);
|
|
188
|
-
initCutValues(t, g);
|
|
189
|
-
updateRanks(t, g);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
const updateRanks = (t: Graph, g: Graph) => {
|
|
193
|
-
const root = t.nodes().find((v) =>{ return !g.node(v)?.parent; })!;
|
|
194
|
-
let vs = preorder(t, root);
|
|
195
|
-
vs = vs?.slice(1);
|
|
196
|
-
vs?.forEach((v: string) => {
|
|
197
|
-
const parent = t.node(v)!.parent as string;
|
|
198
|
-
let edge = g.edgeFromArgs(v, parent);
|
|
199
|
-
let flipped = false;
|
|
200
|
-
|
|
201
|
-
if (!edge) {
|
|
202
|
-
edge = g.edgeFromArgs(parent, v)!;
|
|
203
|
-
flipped = true;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
g.node(v)!.rank = g.node(parent)!.rank! + (flipped ? edge.minlen! : -edge.minlen!);
|
|
207
|
-
});
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
/*
|
|
211
|
-
* Returns true if the edge is in the tree.
|
|
212
|
-
*/
|
|
213
|
-
const isTreeEdge = (tree: Graph, u: string, v: string) => {
|
|
214
|
-
return tree.hasEdge(u, v);
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
/*
|
|
218
|
-
* Returns true if the specified node is descendant of the root node per the
|
|
219
|
-
* assigned low and lim attributes in the tree.
|
|
220
|
-
*/
|
|
221
|
-
const isDescendant = (tree: Graph, vLabel: any, rootLabel: any) => {
|
|
222
|
-
return rootLabel.low <= vLabel.lim && vLabel.lim <= rootLabel.lim;
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
export default networkSimplex;
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { Edge, Graph } from "../../graph";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Initializes ranks for the input graph using the longest path algorithm. This
|
|
5
|
-
* algorithm scales well and is fast in practice, it yields rather poor
|
|
6
|
-
* solutions. Nodes are pushed to the lowest layer possible, leaving the bottom
|
|
7
|
-
* ranks wide and leaving edges longer than necessary. However, due to its
|
|
8
|
-
* speed, this algorithm is good for getting an initial ranking that can be fed
|
|
9
|
-
* into other algorithms.
|
|
10
|
-
*
|
|
11
|
-
* This algorithm does not normalize layers because it will be used by other
|
|
12
|
-
* algorithms in most cases. If using this algorithm directly, be sure to
|
|
13
|
-
* run normalize at the end.
|
|
14
|
-
*
|
|
15
|
-
* Pre-conditions:
|
|
16
|
-
*
|
|
17
|
-
* 1. Input graph is a DAG.
|
|
18
|
-
* 2. Input graph node labels can be assigned properties.
|
|
19
|
-
*
|
|
20
|
-
* Post-conditions:
|
|
21
|
-
*
|
|
22
|
-
* 1. Each node will be assign an (unnormalized) "rank" property.
|
|
23
|
-
*/
|
|
24
|
-
const longestPath = (g: Graph) => {
|
|
25
|
-
const visited: Record<string, boolean> = {};
|
|
26
|
-
|
|
27
|
-
const dfs = (v: string) => {
|
|
28
|
-
const label = g.node(v)!;
|
|
29
|
-
if (!label) return 0;
|
|
30
|
-
if (visited[v]) {
|
|
31
|
-
return label.rank!;
|
|
32
|
-
}
|
|
33
|
-
visited[v] = true;
|
|
34
|
-
|
|
35
|
-
let rank: number;
|
|
36
|
-
|
|
37
|
-
g.outEdges(v)?.forEach(
|
|
38
|
-
(edgeObj) => {
|
|
39
|
-
const wRank = dfs(edgeObj.w);
|
|
40
|
-
const minLen = g.edge(edgeObj)!.minlen!;
|
|
41
|
-
const r = wRank - minLen;
|
|
42
|
-
if (r) {
|
|
43
|
-
if (rank === undefined || r < rank) {
|
|
44
|
-
rank = r;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (!rank!) {
|
|
52
|
-
rank = 0;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
label.rank = rank;
|
|
56
|
-
return rank;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
g.sources()?.forEach((source) => dfs(source));
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const longestPathWithLayer = (g: Graph) => {
|
|
63
|
-
// 用longest path,找出最深的点
|
|
64
|
-
const visited: Record<string, boolean> = {};
|
|
65
|
-
let minRank: number;
|
|
66
|
-
|
|
67
|
-
const dfs = (v: string) => {
|
|
68
|
-
const label = g.node(v)!;
|
|
69
|
-
if (!label) return 0;
|
|
70
|
-
if (visited[v]) {
|
|
71
|
-
return label.rank!;
|
|
72
|
-
}
|
|
73
|
-
visited[v] = true;
|
|
74
|
-
|
|
75
|
-
let rank: number;
|
|
76
|
-
|
|
77
|
-
g.outEdges(v)?.forEach(
|
|
78
|
-
(edgeObj) => {
|
|
79
|
-
const wRank = dfs(edgeObj.w);
|
|
80
|
-
const minLen = g.edge(edgeObj)!.minlen!;
|
|
81
|
-
const r = wRank - minLen;
|
|
82
|
-
if (r) {
|
|
83
|
-
if (rank === undefined || r < rank) {
|
|
84
|
-
rank = r;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (!rank!) {
|
|
92
|
-
rank = 0;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (minRank === undefined || rank < minRank) {
|
|
96
|
-
minRank = rank;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
label.rank = rank;
|
|
100
|
-
return rank;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
g.sources()?.forEach((source) => {
|
|
104
|
-
if (g.node(source)) dfs(source)
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
if (minRank! === undefined) {
|
|
108
|
-
minRank = 0;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// minRank += 1; // NOTE: 最小的层级是dummy root,+1
|
|
112
|
-
|
|
113
|
-
// forward一遍,赋值层级
|
|
114
|
-
const forwardVisited: Record<string, boolean> = {};
|
|
115
|
-
const dfsForward = (v: string, nextRank: number) => {
|
|
116
|
-
const label = g.node(v)!;
|
|
117
|
-
|
|
118
|
-
const currRank = (
|
|
119
|
-
!isNaN(label.layer as number) ? label.layer : nextRank
|
|
120
|
-
) as number;
|
|
121
|
-
|
|
122
|
-
// 没有指定,取最大值
|
|
123
|
-
if (label.rank === undefined || label.rank < currRank) {
|
|
124
|
-
label.rank = currRank;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (forwardVisited[v]) return;
|
|
128
|
-
forwardVisited[v] = true;
|
|
129
|
-
|
|
130
|
-
// DFS遍历子节点
|
|
131
|
-
g.outEdges(v)?.map((e) => {
|
|
132
|
-
dfsForward(e.w, currRank + g.edge(e)!.minlen!);
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
// 指定层级的,更新下游
|
|
137
|
-
g.nodes().forEach((n) => {
|
|
138
|
-
const label = g.node(n)!;
|
|
139
|
-
if(!label) return;
|
|
140
|
-
if (!isNaN(label.layer as number)) {
|
|
141
|
-
dfsForward(n, label.layer as number); // 默认的dummy root所在层的rank是-1
|
|
142
|
-
} else {
|
|
143
|
-
(label.rank as number) -= minRank;
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
/*
|
|
149
|
-
* Returns the amount of slack for the given edge. The slack is defined as the
|
|
150
|
-
* difference between the length of the edge and its minimum length.
|
|
151
|
-
*/
|
|
152
|
-
const slack = (g: Graph, e: Edge) => {
|
|
153
|
-
return (
|
|
154
|
-
(g.node(e.w)!.rank as number) -
|
|
155
|
-
(g.node(e.v)!.rank as number) -
|
|
156
|
-
(g.edge(e)!.minlen as number)
|
|
157
|
-
);
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
export { longestPath, longestPathWithLayer, slack };
|
|
161
|
-
|
|
162
|
-
export default {
|
|
163
|
-
longestPath,
|
|
164
|
-
longestPathWithLayer,
|
|
165
|
-
slack,
|
|
166
|
-
};
|