@ac-kit/math-graph 0.1.0 → 0.2.1

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 (37) hide show
  1. package/CHANGELOG.md +122 -0
  2. package/README.md +42 -16
  3. package/dist/layout/_force-forces.d.ts +140 -16
  4. package/dist/layout/_force-forces.d.ts.map +1 -1
  5. package/dist/layout/_force-forces.js +1204 -122
  6. package/dist/layout/_force-forces.js.map +1 -1
  7. package/dist/layout/_hierarchy-table.js.map +1 -1
  8. package/dist/layout/_layer-order.d.ts +52 -10
  9. package/dist/layout/_layer-order.d.ts.map +1 -1
  10. package/dist/layout/_layer-order.js +565 -73
  11. package/dist/layout/_layer-order.js.map +1 -1
  12. package/dist/layout/_layered-rank.d.ts +8 -4
  13. package/dist/layout/_layered-rank.d.ts.map +1 -1
  14. package/dist/layout/_layered-rank.js +113 -20
  15. package/dist/layout/_layered-rank.js.map +1 -1
  16. package/dist/layout/_treemap-tiling.d.ts +13 -2
  17. package/dist/layout/_treemap-tiling.d.ts.map +1 -1
  18. package/dist/layout/_treemap-tiling.js +70 -10
  19. package/dist/layout/_treemap-tiling.js.map +1 -1
  20. package/dist/layout/create-force-step.d.ts +39 -24
  21. package/dist/layout/create-force-step.d.ts.map +1 -1
  22. package/dist/layout/create-force-step.js +45 -12
  23. package/dist/layout/create-force-step.js.map +1 -1
  24. package/dist/layout/layered-layout.d.ts +15 -2
  25. package/dist/layout/layered-layout.d.ts.map +1 -1
  26. package/dist/layout/layered-layout.js +5 -1
  27. package/dist/layout/layered-layout.js.map +1 -1
  28. package/dist/layout/sankey-layout.d.ts +10 -1
  29. package/dist/layout/sankey-layout.d.ts.map +1 -1
  30. package/dist/layout/sankey-layout.js +5 -0
  31. package/dist/layout/sankey-layout.js.map +1 -1
  32. package/dist/layout/tidy-tree-layout.js.map +1 -1
  33. package/dist/layout/treemap-layout.d.ts +14 -5
  34. package/dist/layout/treemap-layout.d.ts.map +1 -1
  35. package/dist/layout/treemap-layout.js +13 -8
  36. package/dist/layout/treemap-layout.js.map +1 -1
  37. package/package.json +11 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,127 @@
1
1
  # @ac-kit/math-graph
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [5c203e7]
8
+ - Updated dependencies [5c203e7]
9
+ - Updated dependencies [5c203e7]
10
+ - Updated dependencies [5c203e7]
11
+ - Updated dependencies [5c203e7]
12
+ - Updated dependencies [5c203e7]
13
+ - Updated dependencies [5c203e7]
14
+ - Updated dependencies [5c203e7]
15
+ - Updated dependencies [5c203e7]
16
+ - Updated dependencies [5c203e7]
17
+ - Updated dependencies [5c203e7]
18
+ - Updated dependencies [5c203e7]
19
+ - Updated dependencies [5c203e7]
20
+ - Updated dependencies [5c203e7]
21
+ - Updated dependencies [5c203e7]
22
+ - Updated dependencies [5c203e7]
23
+ - Updated dependencies [5c203e7]
24
+ - Updated dependencies [5c203e7]
25
+ - Updated dependencies [5c203e7]
26
+ - @ac-kit/algo@0.7.0
27
+ - @ac-kit/core@0.14.0
28
+ - @ac-kit/data@0.6.0
29
+ - @ac-kit/math-geometry@0.5.0
30
+ - @ac-kit/math-linear@0.5.0
31
+ - @ac-kit/math-scalar@0.5.0
32
+
33
+ ## 0.2.0
34
+
35
+ ### Minor Changes
36
+
37
+ - 0b4fe43: `forceDirectedLayout` is a d3-force-style simulation that no longer inherits
38
+ d3-force's Barnes–Hut limits. A node's own charge is never applied (a cell
39
+ holding the node is always opened), `distanceMax` applies to each body (a cell
40
+ straddling it is opened), and the positive and negative charges of a cell are
41
+ kept apart, so each monopole's error is bounded as for same-sign charges (a
42
+ node's error relative to its unsigned contributions, Σ |q| / d, not to its net
43
+ force) and a cell whose charges sum to zero still acts. Every force and the
44
+ integration keep positions and velocities finite for any finite inputs and
45
+ options, across the whole binary64 range: differences, sums, means, squares,
46
+ products, the `distanceMin` clamp, ratios and shares are scaled by powers of
47
+ two where they would leave the doubles (each end's share applied before
48
+ scaling back), positions beyond ±1e150 are indexed in a scaled quadtree, and
49
+ a position or velocity whose exact value lies beyond the doubles saturates at
50
+ ±`Number.MAX_VALUE`, in either approximation and with `compatibility:
51
+ "d3-force"`. Collisions never
52
+ miss a pair a node was pushed into earlier in the same pass nor one the active
53
+ node moved into by its own pushes, every node of a chain of coincident nodes
54
+ collides, and a self-link exerts no force. `compatibility: "d3-force"`
55
+ reproduces d3-force 3 instead, quirks included: with the same random source the
56
+ Barnes–Hut mode then matches d3-force's (same θ) and the `"exact"` mode
57
+ d3-force with θ = 0, to rounding. `createForceStep` allocates nothing per step
58
+ once warmed up.
59
+ - 0b4fe43: `layeredLayout` reduces crossings by sweeps, transposition and, with the new
60
+ `orderingEffort: "thorough"` (the default), by sifting each vertex to its best
61
+ slot, which leaves the local minima the sweeps stop in. It never has more
62
+ weighted crossings than `orderingEffort: "fast"`, which skips the sifting; where
63
+ rounded counts are too close to tell two orders apart, the exact weighted totals
64
+ decide. Each layer pair's weighted count is the exact `Σ wᵢ·wⱼ` over its
65
+ crossing pairs rounded once, for any finite weights ≥ 0, at the cost of the
66
+ compensated count it replaces wherever a rigorous bound certifies that
67
+ rounding. Network-simplex ranking charges the work budget, and yields, before each
68
+ exact scan that settles a cut value. `sankeyLayout` accepts `ordering:
69
+ "crossings"` to order its nodes with the layered crossing reduction and its
70
+ `orderingEffort`, instead of d3-sankey's relaxation.
71
+ - 0b4fe43: `treemapLayout` reserves a parent's own value in every tiling, so the area of a
72
+ cell is proportional to its value and small children keep their share beside a
73
+ huge one. `compatibility: "d3-hierarchy"` reproduces d3-hierarchy's binary
74
+ tiling, which does not.
75
+
76
+ ### Patch Changes
77
+
78
+ - Updated dependencies [0b4fe43]
79
+ - Updated dependencies [0b4fe43]
80
+ - Updated dependencies [0b4fe43]
81
+ - Updated dependencies [0b4fe43]
82
+ - Updated dependencies [0b4fe43]
83
+ - Updated dependencies [0b4fe43]
84
+ - Updated dependencies [0b4fe43]
85
+ - Updated dependencies [0b4fe43]
86
+ - Updated dependencies [0b4fe43]
87
+ - Updated dependencies [0b4fe43]
88
+ - Updated dependencies [0b4fe43]
89
+ - Updated dependencies [0b4fe43]
90
+ - Updated dependencies [0b4fe43]
91
+ - Updated dependencies [0b4fe43]
92
+ - Updated dependencies [0b4fe43]
93
+ - Updated dependencies [0b4fe43]
94
+ - Updated dependencies [0b4fe43]
95
+ - Updated dependencies [0b4fe43]
96
+ - Updated dependencies [0b4fe43]
97
+ - Updated dependencies [0b4fe43]
98
+ - Updated dependencies [0b4fe43]
99
+ - Updated dependencies [0b4fe43]
100
+ - Updated dependencies [0b4fe43]
101
+ - Updated dependencies [0b4fe43]
102
+ - Updated dependencies [0b4fe43]
103
+ - Updated dependencies [0b4fe43]
104
+ - Updated dependencies [0b4fe43]
105
+ - Updated dependencies [0b4fe43]
106
+ - Updated dependencies [0b4fe43]
107
+ - Updated dependencies [0b4fe43]
108
+ - Updated dependencies [0b4fe43]
109
+ - Updated dependencies [0b4fe43]
110
+ - Updated dependencies [0b4fe43]
111
+ - Updated dependencies [0b4fe43]
112
+ - Updated dependencies [0b4fe43]
113
+ - Updated dependencies [0b4fe43]
114
+ - Updated dependencies [0b4fe43]
115
+ - Updated dependencies [0b4fe43]
116
+ - Updated dependencies [0b4fe43]
117
+ - Updated dependencies [0b4fe43]
118
+ - @ac-kit/algo@0.6.0
119
+ - @ac-kit/core@0.13.0
120
+ - @ac-kit/data@0.5.0
121
+ - @ac-kit/math-geometry@0.4.0
122
+ - @ac-kit/math-linear@0.4.0
123
+ - @ac-kit/math-scalar@0.4.0
124
+
3
125
  ## 0.1.0
4
126
 
5
127
  ### Minor Changes
package/README.md CHANGED
@@ -41,24 +41,37 @@ Network layouts take explicit links (`sourceOf`, `targetOf` return indices into
41
41
  `nodes`) and return `Float64Array` buffers in input order. The force layout
42
42
  applies link, many-body (Barnes–Hut by default, `"exact"` on request),
43
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
44
+ `random` is required: pass a seeded generator such as `mulberry32(seed)`, which
47
45
  separates coincident nodes reproducibly.
48
46
 
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).
47
+ Barnes–Hut is a bounded approximation of `"exact"` whose error tends to 0 with
48
+ θ (Barnes and Hut 1986). A cell is never summarised while the node lies inside
49
+ it, enlarged by 20 % as in GADGET-2 (Springel 2005), so a node never feels its
50
+ own charge however large θ is, the failure Salmon and Warren (1994) show
51
+ unbounds the plain criterion. Each cell keeps its positive and its negative
52
+ charges as two monopoles, so each monopole's error is bounded as for same-sign
53
+ charges and a cell whose charges sum to zero still acts: a node's error is
54
+ bounded relative to its unsigned contributions, Σ |q| / d over the other
55
+ bodies, not relative to its net force, which cancelling charges can make far
56
+ smaller than that error. `distanceMax` applies to each body: a cell straddling
57
+ it is opened. Differences, means, distances, the cutoff, the `distanceMin`
58
+ clamp and the force are scaled by powers of two wherever they, a square or the
59
+ clamp's product would underflow or overflow, cell centres are running means,
60
+ and positions beyond the quadtree's ±1e150 are indexed scaled, so any finite
61
+ coordinates and charges keep their force. Every force and the integration keep
62
+ positions and velocities finite for any finite inputs and options: one whose
63
+ exact value lies beyond the doubles saturates at ±`Number.MAX_VALUE`.
64
+ Collisions widen their pruning by how far any node
65
+ has moved in the pass (the skin of Verlet's neighbour lists), so a node pushed
66
+ into another's reach earlier in the same pass is still caught; the active
67
+ node's own prediction is refreshed after each push and its walk repeated on it,
68
+ so its later pairs are tested where it now stands. A self-link exerts no force.
69
+
70
+ `compatibility: "d3-force"` reproduces d3-force 3 to rounding instead, quirks
71
+ included: with the same random source, Barnes–Hut mode then matches d3-force's
72
+ own Barnes–Hut (same θ) and `"exact"` mode matches d3-force with θ = 0. A
73
+ pinned axis keeps its pin even when the node has no initial position (d3-force
74
+ would replace it with the phyllotaxis coordinate until the first tick).
62
75
 
63
76
  ```ts
64
77
  import { forceDirectedLayout, createForceStep } from "@ac-kit/math-graph";
@@ -89,5 +102,18 @@ step(positions, velocities, 0.3);
89
102
  `forceDirectedLayoutAsync` takes `signal` and `sliceMs`, yields between steps
90
103
  and returns the same result.
91
104
 
105
+ ## Layered layout
106
+
107
+ `layeredLayout` reduces crossings with barycentre and median sweeps (Sugiyama,
108
+ Tagawa and Toda 1981; Eades and Wormald 1994) and adjacent transpositions
109
+ (Gansner et al. 1993) from two depth-first starting orders. With
110
+ `orderingEffort: "thorough"`, the default, it then sifts (Matuszewski,
111
+ Schönfeld and Molitor 1999): each vertex in turn moves to the slot of its layer
112
+ with the fewest crossings, which leaves the local minima the sweeps stop in, at
113
+ O(k · e) per round and layer of k vertices and e segments. `"fast"` stops after
114
+ the sweeps. Either effort returns the fewest-crossing order it saw, and
115
+ `"thorough"` never has more crossings than `"fast"`. `sankeyLayout`'s
116
+ `ordering: "crossings"` takes the same `orderingEffort`.
117
+
92
118
  See the [generated API docs](https://anthochamp.pages.grenadine.io/node-essentials/api/math-graph/)
93
119
  for the full reference.
@@ -10,7 +10,11 @@ export type LinkForceData = {
10
10
  };
11
11
  /**
12
12
  * Springs between linked nodes, on positions advanced by their velocities (the
13
- * velocity-Verlet predictor); the correction goes to the velocities.
13
+ * velocity-Verlet predictor); the correction goes to the velocities. A link
14
+ * whose squared length, ratio `(l − d) / l` or move would leave the doubles is
15
+ * settled on lengths scaled by a power of two, each end's share applied before
16
+ * scaling back, so that it pulls or pushes wherever its share of the move is
17
+ * finite (a rest length of `Number.MAX_VALUE` included).
14
18
  */
15
19
  export declare function applyLinkForce(positions: Float64Array, velocities: Float64Array, alpha: number, data: LinkForceData, random: RandomFn): void;
16
20
  export type ManyBodyOptions = {
@@ -19,32 +23,90 @@ export type ManyBodyOptions = {
19
23
  readonly distanceMin: number;
20
24
  readonly distanceMax: number;
21
25
  readonly random: RandomFn;
26
+ /** D3-force's Barnes–Hut criterion and its quirks (`compatibility`). */
27
+ readonly isD3: boolean;
22
28
  };
23
29
  /**
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.
30
+ * Charges repelling or attracting each other with strength / distance, every
31
+ * pair in `"exact"` mode or Barnes–Hut (Barnes and Hut, "A hierarchical O(N log
32
+ * N) force-calculation algorithm", Nature 324, 1986) over a `Quadtree`.
33
+ *
34
+ * Each cell keeps two monopoles: the sum of its positive charges at their
35
+ * centre, and the sum of its negative charges at theirs. A cell is summarised
36
+ * only when each of its monopoles looks small enough from the node (width / θ <
37
+ * the distance to that monopole's centre, d3-force's form of the criterion), so
38
+ * each monopole's error is bounded relative to its own charge over its
39
+ * distance, as for same-sign charges, and a cell is never skipped because its
40
+ * charges sum to 0. The error of a node's force is therefore bounded relative
41
+ * to its unsigned contributions, Σ |q_j| / d_j over the other bodies, not
42
+ * relative to the net force: where contributions of opposite signs cancel, the
43
+ * net force can be any number of times smaller than that error. A cell is
44
+ * always opened when the node lies inside it, enlarged by 20 % (Springel, "The
45
+ * cosmological simulation code GADGET-2", MNRAS 364, 2005, §3.1), so no node
46
+ * feels its own charge however large θ is: the self-interaction that Salmon and
47
+ * Warren ("Skeletons from the treecode closet", J. Comput. Phys. 111, 1994)
48
+ * show unbounds the error of the plain criterion. A cell that straddles
49
+ * `distanceMax` is opened too, so the cutoff applies to each body, as in
50
+ * `"exact"` mode. Centres are running charge-weighted means (a convex
51
+ * combination where a step would overflow), differences beyond the doubles are
52
+ * taken from halves, distances, the cutoff, the clamp and the force are scaled
53
+ * by powers of two wherever a square would underflow or overflow, a cell's
54
+ * charge sums by the power of two that keeps the total of every |charge|
55
+ * finite, and positions beyond the quadtree's ±1e150 are indexed scaled by a
56
+ * power of two (the cells scaled back), so any finite coordinates, distances
57
+ * down to the least subnormal and charges up to the double range keep their
58
+ * force; a velocity beyond the doubles saturates at ±`Number.MAX_VALUE`.
59
+ *
60
+ * `isD3` keeps d3-force's own approximation instead: one signed monopole at the
61
+ * |charge|-weighted centre, a cell summarised even when it holds the node,
62
+ * `distanceMax` tested against the cell's centre, cells whose charges sum to 0
63
+ * skipped, and coincident offsets drawn whenever one axis difference is 0.
28
64
  */
29
65
  export declare class ManyBodyForce {
30
66
  private readonly charges;
31
67
  private readonly options;
32
68
  private readonly tree;
69
+ /** Positive charge of each cell (its signed sum when `isD3`). */
33
70
  private values;
34
71
  private centersX;
35
72
  private centersY;
73
+ /** Negative charge of each cell (unused when `isD3`). */
74
+ private negativeValues;
75
+ private negativeCentersX;
76
+ private negativeCentersY;
36
77
  private readonly scratch;
37
78
  private positions;
38
79
  private velocities;
39
80
  private readonly order;
40
81
  private orderLength;
41
82
  private readonly isExact;
83
+ private readonly isD3;
42
84
  private readonly isInert;
43
85
  private readonly theta2;
44
86
  private readonly distanceMin2;
45
87
  private readonly distanceMax2;
88
+ /**
89
+ * The charges a cell sums, scaled down by `monopoleScale`, a power of two
90
+ * from 1 up: so far that the sum of every |charge| stays finite, and no
91
+ * further, so a charge loses no digit unless it is subnormal already.
92
+ */
93
+ private readonly scaledCharges;
94
+ private readonly monopoleScale;
95
+ /**
96
+ * Positions scaled into the quadtree's range when one lies beyond it (grown,
97
+ * then reused), and the power of two the tree's cells are to be multiplied
98
+ * by: 1 while the positions are indexed as they are.
99
+ */
100
+ private treePositions;
101
+ private cellScale;
46
102
  constructor(charges: Float64Array, options: ManyBodyOptions);
47
103
  apply(positions: Float64Array, velocities: Float64Array, alpha: number): void;
104
+ /**
105
+ * Indexes the positions, scaled by a power of two into the quadtree's range
106
+ * where one lies beyond it: the cells are then `cellScale` times the tree's,
107
+ * and every force still reads the positions themselves.
108
+ */
109
+ private assignTree;
48
110
  /**
49
111
  * Every pair, the others taken in the tree's leaf order: the order the
50
112
  * Barnes–Hut walk sums them in, so exact and approximate runs differ only by
@@ -52,39 +114,100 @@ export declare class ManyBodyForce {
52
114
  */
53
115
  private applyExact;
54
116
  private readonly collectLeaves;
55
- /** Signed charge and |charge|-weighted centre of every cell, children first. */
117
+ /**
118
+ * `isD3`: signed charge and |charge|-weighted centre of every cell, children
119
+ * first.
120
+ */
121
+ private readonly accumulateD3;
122
+ /**
123
+ * Positive and negative charge of every cell, scaled down by `monopoleScale`,
124
+ * each at its own charge-weighted centre, children first. A sign with no
125
+ * charge has its centre at the origin; it is never read.
126
+ */
56
127
  private readonly accumulate;
128
+ /**
129
+ * The Barnes–Hut walk for the node in `scratch`: a cell is summarised by its
130
+ * two monopoles, opened, or skipped whole (no charge, or every body beyond
131
+ * `distanceMax`); a leaf is summed body by body.
132
+ */
57
133
  private readonly visit;
134
+ /**
135
+ * Every body of the leaf `node` but the node in `scratch`, as `"exact"` sums
136
+ * them: the cutoff per body, coincident bodies parted by a jiggle.
137
+ */
138
+ private applyLeaf;
139
+ /** `isD3`: d3-force's walk, quirks included (see the class). */
140
+ private readonly visitD3;
141
+ /**
142
+ * {@link visitD3} for a cell whose centre is so far from the node that the
143
+ * difference leaves the doubles (taken from halves in `PAIR_`): d3-force's
144
+ * tests on scaled lengths, and the force from `addPull_`. No offset is drawn,
145
+ * as the two cannot coincide.
146
+ */
147
+ private visitD3Wide;
58
148
  }
59
149
  /**
60
150
  * Pushes overlapping discs apart, nodes tested on their predicted positions
61
151
  * (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).
152
+ * result is exact whatever the many-body approximation. The pruning is widened
153
+ * by how far any prediction has moved since the pass started (the "skin" of
154
+ * Verlet's neighbour lists: Verlet, Phys. Rev. 159, 1967), so a node pushed
155
+ * into another's reach by an earlier pair of the same pass is still tested, and
156
+ * every pair of a chain of coincident nodes collides. The active node's own
157
+ * prediction is refreshed after each push, and its walk repeated on the moved
158
+ * prediction (skipping the pairs already pushed) until a walk pushes none, so
159
+ * no later pair is tested on where it no longer stands. Where a squared radius,
160
+ * reach or distance would overflow or underflow, the pair is settled on lengths
161
+ * scaled by a power of two and the shares on the ratio of the radii, each
162
+ * node's share applied before scaling back, so any finite radii and distances
163
+ * push (radii of `Number.MAX_VALUE` included) and only a node's part of a
164
+ * displacement beyond the doubles overflows.
165
+ *
166
+ * `isD3` keeps d3-force's behaviour instead: cells bounded on the predictions
167
+ * made when the pass starts, so such a pair is missed until the next pass, and
168
+ * only the newest node of a coincident chain tested (and its radius taken as
169
+ * the leaf's).
67
170
  */
68
171
  export declare class CollideForce {
69
172
  private readonly radii;
70
173
  private readonly strength;
71
174
  private readonly iterations;
72
175
  private readonly random;
73
- private readonly isLive;
176
+ private readonly isD3;
74
177
  private readonly tree;
75
178
  private readonly predicted;
179
+ /**
180
+ * Per node, the walk (`scratch[7]`) that last pushed it against the active
181
+ * node.
182
+ */
183
+ private readonly pushedIn;
76
184
  private cellRadii;
77
185
  private readonly scratch;
78
186
  private positions;
79
187
  private velocities;
80
- constructor(radii: Float64Array, strength: number, iterations: number, random: RandomFn, isLive?: boolean);
188
+ /** The power of two the tree's cells are to be multiplied by. */
189
+ private cellScale;
190
+ constructor(radii: Float64Array, strength: number, iterations: number, random: RandomFn, isD3: boolean);
81
191
  apply(positions: Float64Array, velocities: Float64Array): void;
82
- /** Largest radius under every cell. */
192
+ /**
193
+ * Indexes the predictions `position + velocity`, scaled by a power of two
194
+ * into the quadtree's range where one lies beyond it (or beyond the doubles):
195
+ * the cells are then `cellScale` times the tree's.
196
+ */
197
+ private assignTree;
198
+ /**
199
+ * Writes the node's prediction into `scratch[0]` and `scratch[1]`, for the
200
+ * pruning test: saturated at ±`Number.MAX_VALUE` beyond the doubles, which
201
+ * only prunes less.
202
+ */
203
+ private notePrediction;
204
+ /** Largest radius under every cell (`isD3`: a leaf's newest node's). */
83
205
  private readonly prepare;
84
206
  private readonly visit;
85
207
  /**
86
208
  * 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.
209
+ * pruning test widens them by how far any prediction has moved since (in the
210
+ * tree's units, scaled back: beyond the doubles it only prunes less).
88
211
  */
89
212
  private noteShift;
90
213
  }
@@ -97,7 +220,8 @@ export declare function applyGravity(positions: Float64Array, velocities: Float6
97
220
  export declare function applyCentering(positions: Float64Array, strength: number, centerX: number, centerY: number): void;
98
221
  /**
99
222
  * Velocity Verlet: v ← v · keep, x ← x + v; a pinned axis (finite entry of
100
- * `fixedPositions`) is set to its pin with zero velocity.
223
+ * `fixedPositions`) is set to its pin with zero velocity. A position beyond the
224
+ * doubles saturates at ±`Number.MAX_VALUE`.
101
225
  */
102
226
  export declare function integrate(positions: Float64Array, velocities: Float64Array, keep: number, fixedPositions: Float64Array | undefined): void;
103
227
  //# sourceMappingURL=_force-forces.d.ts.map
@@ -1 +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;IA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