@ac-kit/math-graph 0.0.0-stage → 0.1.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/LICENSE +28 -0
  3. package/README.md +92 -2
  4. package/dist/index.d.ts +12 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +11 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/layout/_force-forces.d.ts +103 -0
  9. package/dist/layout/_force-forces.d.ts.map +1 -0
  10. package/dist/layout/_force-forces.js +490 -0
  11. package/dist/layout/_force-forces.js.map +1 -0
  12. package/dist/layout/_hierarchy-table.d.ts +34 -0
  13. package/dist/layout/_hierarchy-table.d.ts.map +1 -0
  14. package/dist/layout/_hierarchy-table.js +131 -0
  15. package/dist/layout/_hierarchy-table.js.map +1 -0
  16. package/dist/layout/_index-graph.d.ts +32 -0
  17. package/dist/layout/_index-graph.d.ts.map +1 -0
  18. package/dist/layout/_index-graph.js +51 -0
  19. package/dist/layout/_index-graph.js.map +1 -0
  20. package/dist/layout/_layer-order.d.ts +96 -0
  21. package/dist/layout/_layer-order.d.ts.map +1 -0
  22. package/dist/layout/_layer-order.js +462 -0
  23. package/dist/layout/_layer-order.js.map +1 -0
  24. package/dist/layout/_layered-acyclic.d.ts +28 -0
  25. package/dist/layout/_layered-acyclic.d.ts.map +1 -0
  26. package/dist/layout/_layered-acyclic.js +179 -0
  27. package/dist/layout/_layered-acyclic.js.map +1 -0
  28. package/dist/layout/_layered-position.d.ts +56 -0
  29. package/dist/layout/_layered-position.d.ts.map +1 -0
  30. package/dist/layout/_layered-position.js +369 -0
  31. package/dist/layout/_layered-position.js.map +1 -0
  32. package/dist/layout/_layered-rank.d.ts +54 -0
  33. package/dist/layout/_layered-rank.d.ts.map +1 -0
  34. package/dist/layout/_layered-rank.js +436 -0
  35. package/dist/layout/_layered-rank.js.map +1 -0
  36. package/dist/layout/_tree-common.d.ts +38 -0
  37. package/dist/layout/_tree-common.d.ts.map +1 -0
  38. package/dist/layout/_tree-common.js +73 -0
  39. package/dist/layout/_tree-common.js.map +1 -0
  40. package/dist/layout/_treemap-tiling.d.ts +62 -0
  41. package/dist/layout/_treemap-tiling.d.ts.map +1 -0
  42. package/dist/layout/_treemap-tiling.js +187 -0
  43. package/dist/layout/_treemap-tiling.js.map +1 -0
  44. package/dist/layout/circular-layout.d.ts +27 -0
  45. package/dist/layout/circular-layout.d.ts.map +1 -0
  46. package/dist/layout/circular-layout.js +35 -0
  47. package/dist/layout/circular-layout.js.map +1 -0
  48. package/dist/layout/create-force-step.d.ts +112 -0
  49. package/dist/layout/create-force-step.d.ts.map +1 -0
  50. package/dist/layout/create-force-step.js +134 -0
  51. package/dist/layout/create-force-step.js.map +1 -0
  52. package/dist/layout/dendrogram-layout.d.ts +32 -0
  53. package/dist/layout/dendrogram-layout.d.ts.map +1 -0
  54. package/dist/layout/dendrogram-layout.js +110 -0
  55. package/dist/layout/dendrogram-layout.js.map +1 -0
  56. package/dist/layout/force-directed-layout.d.ts +42 -0
  57. package/dist/layout/force-directed-layout.d.ts.map +1 -0
  58. package/dist/layout/force-directed-layout.js +112 -0
  59. package/dist/layout/force-directed-layout.js.map +1 -0
  60. package/dist/layout/layered-layout.d.ts +96 -0
  61. package/dist/layout/layered-layout.d.ts.map +1 -0
  62. package/dist/layout/layered-layout.js +120 -0
  63. package/dist/layout/layered-layout.js.map +1 -0
  64. package/dist/layout/partition-layout.d.ts +31 -0
  65. package/dist/layout/partition-layout.d.ts.map +1 -0
  66. package/dist/layout/partition-layout.js +78 -0
  67. package/dist/layout/partition-layout.js.map +1 -0
  68. package/dist/layout/phyllotaxis-layout.d.ts +17 -0
  69. package/dist/layout/phyllotaxis-layout.d.ts.map +1 -0
  70. package/dist/layout/phyllotaxis-layout.js +32 -0
  71. package/dist/layout/phyllotaxis-layout.js.map +1 -0
  72. package/dist/layout/sankey-layout.d.ts +104 -0
  73. package/dist/layout/sankey-layout.d.ts.map +1 -0
  74. package/dist/layout/sankey-layout.js +636 -0
  75. package/dist/layout/sankey-layout.js.map +1 -0
  76. package/dist/layout/tidy-tree-layout.d.ts +25 -0
  77. package/dist/layout/tidy-tree-layout.d.ts.map +1 -0
  78. package/dist/layout/tidy-tree-layout.js +197 -0
  79. package/dist/layout/tidy-tree-layout.js.map +1 -0
  80. package/dist/layout/treemap-layout.d.ts +54 -0
  81. package/dist/layout/treemap-layout.d.ts.map +1 -0
  82. package/dist/layout/treemap-layout.js +121 -0
  83. package/dist/layout/treemap-layout.js.map +1 -0
  84. package/dist/layout/types.d.ts +90 -0
  85. package/dist/layout/types.d.ts.map +1 -0
  86. package/dist/layout/types.js +2 -0
  87. package/dist/layout/types.js.map +1 -0
  88. package/package.json +66 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,91 @@
1
+ # @ac-kit/math-graph
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 34e8cfa: New package `@ac-kit/math-graph`, numerical graph theory, starting with layouts.
8
+ Hierarchy layouts take a `childrenOf` callback and return a pre-order table
9
+ (`nodes`, `parentIndices`, `depths`, geometry), with an optional work budget on
10
+ untrusted input: `partitionLayout` (icicle, flamegraph), `treemapLayout`
11
+ (squarified by default, other tilings selectable), `tidyTreeLayout`
12
+ (Reingold–Tilford in linear time) and `dendrogramLayout`. `circularLayout` and
13
+ `phyllotaxisLayout` place a given number of points on a circle and on a
14
+ sunflower spiral, as `x, y` pairs in a `Float64Array`.
15
+
16
+ Network layouts take explicit links (`sourceOf`, `targetOf` indices into
17
+ `nodes`) and return columnar results in input order, no object per node.
18
+ `layeredLayout` is a Sugiyama drawing (cycle removal, network-simplex or
19
+ longest-path ranking, crossing reduction, Brandes–Köpf coordinates) in four
20
+ directions: it accepts cycles by reversing links (flagged in `reversed`) and
21
+ gives a self-loop an empty path, returning a `LayeredLayout` (`positions`,
22
+ `ranks`, `orders`, `edgePoints` with `edgeStarts`, `reversed`, `width`,
23
+ `height`). `sankeyLayout` draws a flow diagram: a `SankeyLayout` of
24
+ `nodeBoxes`, `nodeValues`, `columns`, `linkWidths` and `linkEnds`, with the
25
+ four d3-sankey alignments and its relaxation. It needs an acyclic flow: a cycle
26
+ or a self-loop throws a `RangeError` naming a link on it, as does a negative,
27
+ non-finite or over-1e150 value, or a fixed node value below its flow.
28
+ `forceDirectedLayout` runs d3-force's simulation (link, many-body with
29
+ Barnes–Hut or exact summation, collision, gravity, centring, pins, velocity
30
+ decay) for a fixed iteration count and returns positions as a `Float64Array`.
31
+ With the same random source its Barnes–Hut mode matches d3-force's Barnes–Hut
32
+ (same θ) and its `"exact"` mode matches d3-force with θ = 0, to rounding; it
33
+ keeps d3's Barnes–Hut limits (self-cell approximation at large θ, no error
34
+ bound for mixed-sign charges, `distanceMax` applied per cell). `random` is
35
+ required, and `budget` is charged per step. `createForceStep` returns one velocity-Verlet step
36
+ over caller-owned `positions` and `velocities`, for an animation loop.
37
+ `forceDirectedLayoutAsync`, `layeredLayoutAsync` and `sankeyLayoutAsync` give the same results in time
38
+ slices, yield between steps, and reject with `signal.reason` when aborted at
39
+ the next step, discarding the work.
40
+
41
+ ### Patch Changes
42
+
43
+ - Updated dependencies [34e8cfa]
44
+ - Updated dependencies [34e8cfa]
45
+ - Updated dependencies [34e8cfa]
46
+ - Updated dependencies [34e8cfa]
47
+ - Updated dependencies [34e8cfa]
48
+ - Updated dependencies [34e8cfa]
49
+ - Updated dependencies [34e8cfa]
50
+ - Updated dependencies [34e8cfa]
51
+ - Updated dependencies [34e8cfa]
52
+ - Updated dependencies [34e8cfa]
53
+ - Updated dependencies [34e8cfa]
54
+ - Updated dependencies [34e8cfa]
55
+ - Updated dependencies [34e8cfa]
56
+ - Updated dependencies [34e8cfa]
57
+ - Updated dependencies [34e8cfa]
58
+ - Updated dependencies [34e8cfa]
59
+ - Updated dependencies [34e8cfa]
60
+ - Updated dependencies [34e8cfa]
61
+ - Updated dependencies [34e8cfa]
62
+ - Updated dependencies [34e8cfa]
63
+ - Updated dependencies [34e8cfa]
64
+ - Updated dependencies [34e8cfa]
65
+ - Updated dependencies [34e8cfa]
66
+ - Updated dependencies [34e8cfa]
67
+ - Updated dependencies [34e8cfa]
68
+ - Updated dependencies [34e8cfa]
69
+ - Updated dependencies [34e8cfa]
70
+ - Updated dependencies [34e8cfa]
71
+ - Updated dependencies [34e8cfa]
72
+ - Updated dependencies [34e8cfa]
73
+ - Updated dependencies [34e8cfa]
74
+ - Updated dependencies [34e8cfa]
75
+ - Updated dependencies [34e8cfa]
76
+ - Updated dependencies [34e8cfa]
77
+ - Updated dependencies [34e8cfa]
78
+ - Updated dependencies [34e8cfa]
79
+ - Updated dependencies [34e8cfa]
80
+ - Updated dependencies [34e8cfa]
81
+ - Updated dependencies [34e8cfa]
82
+ - Updated dependencies [34e8cfa]
83
+ - Updated dependencies [34e8cfa]
84
+ - Updated dependencies [34e8cfa]
85
+ - Updated dependencies [34e8cfa]
86
+ - @ac-kit/algo@0.5.0
87
+ - @ac-kit/core@0.12.0
88
+ - @ac-kit/math-scalar@0.3.0
89
+ - @ac-kit/data@0.4.0
90
+ - @ac-kit/math-linear@0.3.0
91
+ - @ac-kit/math-geometry@0.3.0
package/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024-2026 Anthony Champagne and contributors
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,3 +1,93 @@
1
- # Temporary Holding Version
1
+ # @ac-kit/math-graph
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Numerical graph theory: what is _computed_ over a graph — positions today,
4
+ scores and partitions later. Traversals, shortest paths and structural
5
+ predicates stay in `@ac-kit/algo`.
6
+
7
+ Portable: no Node.js built-ins. Depends on `@ac-kit/core`, `@ac-kit/algo`,
8
+ `@ac-kit/data`, `@ac-kit/math-scalar`, `@ac-kit/math-linear` and
9
+ `@ac-kit/math-geometry`.
10
+
11
+ Every hierarchy layout takes its structure as callbacks (`childrenOf`,
12
+ `ownValueOf`, `separationOf`, `heightOf`, depending on the layout) and returns a
13
+ table in pre-order: the caller's `nodes`, `parentIndices` into the same table,
14
+ `depths` and the geometry (`positions` or `boxes`). Pre-order is draw order, so
15
+ a renderer iterates the result directly.
16
+
17
+ ```ts
18
+ import { hierarchyFromParents } from "@ac-kit/algo";
19
+ import { treemapLayout } from "@ac-kit/math-graph";
20
+ ```
21
+
22
+ ## Contents
23
+
24
+ | Symbol | Description |
25
+ | ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
26
+ | `partitionLayout(root, traits, options)` | Stacked bars along one axis: icicle and flamegraph |
27
+ | `treemapLayout(root, traits, options)` | Treemap with a choice of tiling, squarified by default |
28
+ | `tidyTreeLayout(root, traits, options)` | Reingold–Tilford node placement, linear time |
29
+ | `dendrogramLayout(root, traits, options)` | Leaf placement for a merge tree |
30
+ | `circularLayout(count, options)`, `phyllotaxisLayout(count, options)` | Deterministic placements on a circle and on a sunflower spiral, as `x, y` pairs in a `Float64Array` |
31
+ | `sankeyLayout(nodes, links, traits, options)`, `sankeyLayoutAsync(…)` | Flow diagram: columns, node heights by value, stacked link bands, d3-sankey's relaxation |
32
+ | `layeredLayout(nodes, links, traits, options)`, `layeredLayoutAsync(…)` | Sugiyama drawing: ranks, crossing reduction, Brandes–Köpf coordinates |
33
+ | `forceDirectedLayout(nodes, links, traits, options)`, `forceDirectedLayoutAsync(…)` | d3-force's simulation run to a fixed iteration count, positions as `Float64Array` |
34
+ | `createForceStep(nodes, links, traits, options)` | One velocity-Verlet step over caller-owned arrays, for an animation loop |
35
+ | `ForceTraits`, `ForceOptions`, `ForceStep`, `ForceDirectedLayoutOptions` | The force layout's traits, options and step types |
36
+ | `HierarchyTable`, `HierarchyPointLayout`, `HierarchyBoxLayout`, `TreeTraits`, … | The shared result and traits types |
37
+
38
+ ## Force layout
39
+
40
+ Network layouts take explicit links (`sourceOf`, `targetOf` return indices into
41
+ `nodes`) and return `Float64Array` buffers in input order. The force layout
42
+ applies link, many-body (Barnes–Hut by default, `"exact"` on request),
43
+ collision, gravity and centring forces, then velocity decay, as d3-force does.
44
+ With the same random source, Barnes–Hut mode matches d3-force's own Barnes–Hut
45
+ (same θ) and `"exact"` mode matches d3-force with θ = 0, to rounding. `random`
46
+ is required: pass a seeded generator such as `mulberry32(seed)`, which
47
+ separates coincident nodes reproducibly.
48
+
49
+ Barnes–Hut keeps d3-force's approximations, so it is not a bounded
50
+ approximation of `"exact"` in every setting. Its error is small for same-sign
51
+ charges and θ ≤ 1. A cell that holds the node itself is summarised too at a
52
+ large θ, so the node feels a force from its own charge. Charges of mixed sign
53
+ have no relative error bound, because a cell is summarised by its signed sum at
54
+ its |charge|-weighted centre. `distanceMax` is applied per cell, to the
55
+ distance to the cell's centre, so a cell straddling the cutoff counts whole or
56
+ not at all. Use `"exact"` when any of this matters. Collision cells are bounded
57
+ on the predictions made when a pass starts, as in d3-force; `collideBounds:
58
+ "live"` also catches a node pushed into another's reach earlier in the same
59
+ pass. A pinned axis keeps its pin even when the node has no initial position
60
+ (d3-force would replace it with the phyllotaxis coordinate until the first
61
+ tick).
62
+
63
+ ```ts
64
+ import { forceDirectedLayout, createForceStep } from "@ac-kit/math-graph";
65
+ import { mulberry32 } from "@ac-kit/math-random";
66
+
67
+ const nodes = ["a", "b", "c", "d"];
68
+ const links: [number, number][] = [
69
+ [0, 1],
70
+ [1, 2],
71
+ [2, 3],
72
+ [3, 0],
73
+ ];
74
+ const traits = {
75
+ sourceOf: (link: [number, number]) => link[0],
76
+ targetOf: (link: [number, number]) => link[1],
77
+ };
78
+ const positions = forceDirectedLayout(nodes, links, traits, {
79
+ random: mulberry32(1),
80
+ });
81
+
82
+ // An animation loop owns the state and ticks the step.
83
+ const step = createForceStep(nodes, links, traits, { random: mulberry32(1) });
84
+ const velocities = new Float64Array(positions.length);
85
+ step(positions, velocities, 0.3);
86
+ ```
87
+
88
+ `forceDirectedLayout` takes an optional `budget` charged `n + m` per step;
89
+ `forceDirectedLayoutAsync` takes `signal` and `sliceMs`, yields between steps
90
+ and returns the same result.
91
+
92
+ See the [generated API docs](https://anthochamp.pages.grenadine.io/node-essentials/api/math-graph/)
93
+ for the full reference.
@@ -0,0 +1,12 @@
1
+ export * from "./layout/circular-layout.js";
2
+ export * from "./layout/create-force-step.js";
3
+ export * from "./layout/dendrogram-layout.js";
4
+ export * from "./layout/force-directed-layout.js";
5
+ export * from "./layout/layered-layout.js";
6
+ export * from "./layout/partition-layout.js";
7
+ export * from "./layout/phyllotaxis-layout.js";
8
+ export * from "./layout/sankey-layout.js";
9
+ export * from "./layout/tidy-tree-layout.js";
10
+ export * from "./layout/treemap-layout.js";
11
+ export type { AsyncLayoutOptions, HierarchyBoxLayout, HierarchyOrder, HierarchyPointLayout, HierarchyTable, HierarchyWalkOptions, NetworkTraits, TreeSizeOptions, TreeTraits, ValuedHierarchyTraits, } from "./layout/types.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,YAAY,EACX,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,UAAU,EACV,qBAAqB,GACrB,MAAM,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ export * from "./layout/circular-layout.js";
2
+ export * from "./layout/create-force-step.js";
3
+ export * from "./layout/dendrogram-layout.js";
4
+ export * from "./layout/force-directed-layout.js";
5
+ export * from "./layout/layered-layout.js";
6
+ export * from "./layout/partition-layout.js";
7
+ export * from "./layout/phyllotaxis-layout.js";
8
+ export * from "./layout/sankey-layout.js";
9
+ export * from "./layout/tidy-tree-layout.js";
10
+ export * from "./layout/treemap-layout.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,103 @@
1
+ import type { RandomFn } from "@ac-kit/core";
2
+ export type LinkForceData = {
3
+ readonly sources: Uint32Array;
4
+ readonly targets: Uint32Array;
5
+ readonly distances: Float64Array;
6
+ readonly strengths: Float64Array;
7
+ /** Share of the correction taken by the target. */
8
+ readonly biases: Float64Array;
9
+ readonly iterations: number;
10
+ };
11
+ /**
12
+ * Springs between linked nodes, on positions advanced by their velocities (the
13
+ * velocity-Verlet predictor); the correction goes to the velocities.
14
+ */
15
+ export declare function applyLinkForce(positions: Float64Array, velocities: Float64Array, alpha: number, data: LinkForceData, random: RandomFn): void;
16
+ export type ManyBodyOptions = {
17
+ readonly approximation: "barnesHut" | "exact";
18
+ readonly theta: number;
19
+ readonly distanceMin: number;
20
+ readonly distanceMax: number;
21
+ readonly random: RandomFn;
22
+ };
23
+ /**
24
+ * Charges repelling or attracting each other with strength / distance:
25
+ * Barnes–Hut (Barnes and Hut, 1986) over a `Quadtree`, each cell standing for
26
+ * its charges at their |charge|-weighted centre once it looks small enough
27
+ * (width² / θ² < distance²), or every pair in `"exact"` mode.
28
+ */
29
+ export declare class ManyBodyForce {
30
+ private readonly charges;
31
+ private readonly options;
32
+ private readonly tree;
33
+ private values;
34
+ private centersX;
35
+ private centersY;
36
+ private readonly scratch;
37
+ private positions;
38
+ private velocities;
39
+ private readonly order;
40
+ private orderLength;
41
+ private readonly isExact;
42
+ private readonly isInert;
43
+ private readonly theta2;
44
+ private readonly distanceMin2;
45
+ private readonly distanceMax2;
46
+ constructor(charges: Float64Array, options: ManyBodyOptions);
47
+ apply(positions: Float64Array, velocities: Float64Array, alpha: number): void;
48
+ /**
49
+ * Every pair, the others taken in the tree's leaf order: the order the
50
+ * Barnes–Hut walk sums them in, so exact and approximate runs differ only by
51
+ * the approximation, not by rounding that chaotic dynamics would amplify.
52
+ */
53
+ private applyExact;
54
+ private readonly collectLeaves;
55
+ /** Signed charge and |charge|-weighted centre of every cell, children first. */
56
+ private readonly accumulate;
57
+ private readonly visit;
58
+ }
59
+ /**
60
+ * Pushes overlapping discs apart, nodes tested on their predicted positions
61
+ * (position + velocity). The tree prunes cells by their largest radius, so the
62
+ * result is exact whatever the many-body approximation. Its cells are bounded
63
+ * on the predictions made when the pass starts, as d3-force's are: a node
64
+ * pushed into another's reach by an earlier pair of the same pass can be missed
65
+ * until the next pass. `isLive` widens the pruning by how far any prediction
66
+ * has moved, so no pair is missed (and results differ from d3's).
67
+ */
68
+ export declare class CollideForce {
69
+ private readonly radii;
70
+ private readonly strength;
71
+ private readonly iterations;
72
+ private readonly random;
73
+ private readonly isLive;
74
+ private readonly tree;
75
+ private readonly predicted;
76
+ private cellRadii;
77
+ private readonly scratch;
78
+ private positions;
79
+ private velocities;
80
+ constructor(radii: Float64Array, strength: number, iterations: number, random: RandomFn, isLive?: boolean);
81
+ apply(positions: Float64Array, velocities: Float64Array): void;
82
+ /** Largest radius under every cell. */
83
+ private readonly prepare;
84
+ private readonly visit;
85
+ /**
86
+ * Cells were bounded on the predictions made at the start of the pass; the
87
+ * pruning test widens them by how far any prediction has moved since.
88
+ */
89
+ private noteShift;
90
+ }
91
+ /** Pull of strength · alpha toward `(centerX, centerY)` on each axis. */
92
+ export declare function applyGravity(positions: Float64Array, velocities: Float64Array, alpha: number, strength: number, centerX: number, centerY: number): void;
93
+ /**
94
+ * Shifts every position so that their mean moves `strength` of the way to the
95
+ * centre.
96
+ */
97
+ export declare function applyCentering(positions: Float64Array, strength: number, centerX: number, centerY: number): void;
98
+ /**
99
+ * Velocity Verlet: v ← v · keep, x ← x + v; a pinned axis (finite entry of
100
+ * `fixedPositions`) is set to its pin with zero velocity.
101
+ */
102
+ export declare function integrate(positions: Float64Array, velocities: Float64Array, keep: number, fixedPositions: Float64Array | undefined): void;
103
+ //# sourceMappingURL=_force-forces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_force-forces.d.ts","sourceRoot":"","sources":["../../src/layout/_force-forces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AA2D7C,MAAM,MAAM,aAAa,GAAG;IAC3B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;IACjC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;IACjC,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,cAAc,CAC7B,SAAS,EAAE,YAAY,EACvB,UAAU,EAAE,YAAY,EACxB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,QAAQ,GACd,IAAI,CAoCN;AAED,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,CAAC,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;CAC1B,CAAC;AAUF;;;;;GAKG;AACH,qBAAa,aAAa;IAiBxB,OAAO,CAAC,QAAQ,CAAC,OAAO;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