@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.
- package/CHANGELOG.md +91 -0
- package/LICENSE +28 -0
- package/README.md +92 -2
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/layout/_force-forces.d.ts +103 -0
- package/dist/layout/_force-forces.d.ts.map +1 -0
- package/dist/layout/_force-forces.js +490 -0
- package/dist/layout/_force-forces.js.map +1 -0
- package/dist/layout/_hierarchy-table.d.ts +34 -0
- package/dist/layout/_hierarchy-table.d.ts.map +1 -0
- package/dist/layout/_hierarchy-table.js +131 -0
- package/dist/layout/_hierarchy-table.js.map +1 -0
- package/dist/layout/_index-graph.d.ts +32 -0
- package/dist/layout/_index-graph.d.ts.map +1 -0
- package/dist/layout/_index-graph.js +51 -0
- package/dist/layout/_index-graph.js.map +1 -0
- package/dist/layout/_layer-order.d.ts +96 -0
- package/dist/layout/_layer-order.d.ts.map +1 -0
- package/dist/layout/_layer-order.js +462 -0
- package/dist/layout/_layer-order.js.map +1 -0
- package/dist/layout/_layered-acyclic.d.ts +28 -0
- package/dist/layout/_layered-acyclic.d.ts.map +1 -0
- package/dist/layout/_layered-acyclic.js +179 -0
- package/dist/layout/_layered-acyclic.js.map +1 -0
- package/dist/layout/_layered-position.d.ts +56 -0
- package/dist/layout/_layered-position.d.ts.map +1 -0
- package/dist/layout/_layered-position.js +369 -0
- package/dist/layout/_layered-position.js.map +1 -0
- package/dist/layout/_layered-rank.d.ts +54 -0
- package/dist/layout/_layered-rank.d.ts.map +1 -0
- package/dist/layout/_layered-rank.js +436 -0
- package/dist/layout/_layered-rank.js.map +1 -0
- package/dist/layout/_tree-common.d.ts +38 -0
- package/dist/layout/_tree-common.d.ts.map +1 -0
- package/dist/layout/_tree-common.js +73 -0
- package/dist/layout/_tree-common.js.map +1 -0
- package/dist/layout/_treemap-tiling.d.ts +62 -0
- package/dist/layout/_treemap-tiling.d.ts.map +1 -0
- package/dist/layout/_treemap-tiling.js +187 -0
- package/dist/layout/_treemap-tiling.js.map +1 -0
- package/dist/layout/circular-layout.d.ts +27 -0
- package/dist/layout/circular-layout.d.ts.map +1 -0
- package/dist/layout/circular-layout.js +35 -0
- package/dist/layout/circular-layout.js.map +1 -0
- package/dist/layout/create-force-step.d.ts +112 -0
- package/dist/layout/create-force-step.d.ts.map +1 -0
- package/dist/layout/create-force-step.js +134 -0
- package/dist/layout/create-force-step.js.map +1 -0
- package/dist/layout/dendrogram-layout.d.ts +32 -0
- package/dist/layout/dendrogram-layout.d.ts.map +1 -0
- package/dist/layout/dendrogram-layout.js +110 -0
- package/dist/layout/dendrogram-layout.js.map +1 -0
- package/dist/layout/force-directed-layout.d.ts +42 -0
- package/dist/layout/force-directed-layout.d.ts.map +1 -0
- package/dist/layout/force-directed-layout.js +112 -0
- package/dist/layout/force-directed-layout.js.map +1 -0
- package/dist/layout/layered-layout.d.ts +96 -0
- package/dist/layout/layered-layout.d.ts.map +1 -0
- package/dist/layout/layered-layout.js +120 -0
- package/dist/layout/layered-layout.js.map +1 -0
- package/dist/layout/partition-layout.d.ts +31 -0
- package/dist/layout/partition-layout.d.ts.map +1 -0
- package/dist/layout/partition-layout.js +78 -0
- package/dist/layout/partition-layout.js.map +1 -0
- package/dist/layout/phyllotaxis-layout.d.ts +17 -0
- package/dist/layout/phyllotaxis-layout.d.ts.map +1 -0
- package/dist/layout/phyllotaxis-layout.js +32 -0
- package/dist/layout/phyllotaxis-layout.js.map +1 -0
- package/dist/layout/sankey-layout.d.ts +104 -0
- package/dist/layout/sankey-layout.d.ts.map +1 -0
- package/dist/layout/sankey-layout.js +636 -0
- package/dist/layout/sankey-layout.js.map +1 -0
- package/dist/layout/tidy-tree-layout.d.ts +25 -0
- package/dist/layout/tidy-tree-layout.d.ts.map +1 -0
- package/dist/layout/tidy-tree-layout.js +197 -0
- package/dist/layout/tidy-tree-layout.js.map +1 -0
- package/dist/layout/treemap-layout.d.ts +54 -0
- package/dist/layout/treemap-layout.d.ts.map +1 -0
- package/dist/layout/treemap-layout.js +121 -0
- package/dist/layout/treemap-layout.js.map +1 -0
- package/dist/layout/types.d.ts +90 -0
- package/dist/layout/types.d.ts.map +1 -0
- package/dist/layout/types.js +2 -0
- package/dist/layout/types.js.map +1 -0
- package/package.json +66 -3
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import { Quadtree } from "@ac-kit/math-geometry";
|
|
2
|
+
/**
|
|
3
|
+
* Where {@link drawJiggle} leaves its offset. Callers read it from here instead
|
|
4
|
+
* of taking a return value: merging a call's result with a computed double
|
|
5
|
+
* forces V8 to box that double, once per link or pair.
|
|
6
|
+
*/
|
|
7
|
+
const JIGGLE = new Float64Array(1);
|
|
8
|
+
/**
|
|
9
|
+
* Offset separating two coincident points that one call moves apart (a link or
|
|
10
|
+
* a collision applies it to both ends, with opposite signs): a seeded value in
|
|
11
|
+
* [−5e-7, 5e-7], as d3-force draws it. A draw that is 0, NaN or outside that
|
|
12
|
+
* range (a generator returning 0.5 or anything outside [0, 1)) takes ±5e-7 by
|
|
13
|
+
* node order, positive when `to > from`.
|
|
14
|
+
*/
|
|
15
|
+
function drawJiggle(random, from, to) {
|
|
16
|
+
const value = (random() - 0.5) * 1e-6;
|
|
17
|
+
JIGGLE[0] =
|
|
18
|
+
value !== 0 && Math.abs(value) <= 5e-7 ? value : to > from ? 5e-7 : -5e-7;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* {@link drawJiggle} for one end of a coincident pair whose two ends draw
|
|
22
|
+
* separately (the charge): they part only if their offsets differ. The draw is
|
|
23
|
+
* kept, as d3-force's, unless it is 0, NaN, not inside (−5e-7, 5e-7), or equal
|
|
24
|
+
* to the previous draw (left in `scratch[slot]`), as a constant generator gives
|
|
25
|
+
* both ends; then the offset is ±5e-7 by node order, positive when `to > from`,
|
|
26
|
+
* which no kept draw equals, and opposite at the two ends.
|
|
27
|
+
*/
|
|
28
|
+
function drawPairJiggle(random, from, to, scratch, slot) {
|
|
29
|
+
const value = (random() - 0.5) * 1e-6;
|
|
30
|
+
const previous = scratch[slot];
|
|
31
|
+
scratch[slot] = value;
|
|
32
|
+
JIGGLE[0] =
|
|
33
|
+
value !== 0 && Math.abs(value) < 5e-7 && value !== previous
|
|
34
|
+
? value
|
|
35
|
+
: to > from
|
|
36
|
+
? 5e-7
|
|
37
|
+
: -5e-7;
|
|
38
|
+
}
|
|
39
|
+
function grown(array, length) {
|
|
40
|
+
return array.length >= length
|
|
41
|
+
? array
|
|
42
|
+
: new Float64Array(Math.max(length, array.length * 2));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Springs between linked nodes, on positions advanced by their velocities (the
|
|
46
|
+
* velocity-Verlet predictor); the correction goes to the velocities.
|
|
47
|
+
*/
|
|
48
|
+
export function applyLinkForce(positions, velocities, alpha, data, random) {
|
|
49
|
+
const { sources, targets, distances, strengths, biases, iterations } = data;
|
|
50
|
+
for (let iteration = 0; iteration < iterations; iteration++) {
|
|
51
|
+
for (let link = 0; link < sources.length; link++) {
|
|
52
|
+
const source = sources[link] * 2;
|
|
53
|
+
const target = targets[link] * 2;
|
|
54
|
+
let dx = positions[target] +
|
|
55
|
+
velocities[target] -
|
|
56
|
+
positions[source] -
|
|
57
|
+
velocities[source];
|
|
58
|
+
if (dx === 0) {
|
|
59
|
+
drawJiggle(random, sources[link], targets[link]);
|
|
60
|
+
dx = JIGGLE[0];
|
|
61
|
+
}
|
|
62
|
+
let dy = positions[target + 1] +
|
|
63
|
+
velocities[target + 1] -
|
|
64
|
+
positions[source + 1] -
|
|
65
|
+
velocities[source + 1];
|
|
66
|
+
if (dy === 0) {
|
|
67
|
+
drawJiggle(random, sources[link], targets[link]);
|
|
68
|
+
dy = JIGGLE[0];
|
|
69
|
+
}
|
|
70
|
+
let scale = Math.sqrt(dx * dx + dy * dy);
|
|
71
|
+
scale = ((scale - distances[link]) / scale) * alpha * strengths[link];
|
|
72
|
+
dx *= scale;
|
|
73
|
+
dy *= scale;
|
|
74
|
+
let share = biases[link];
|
|
75
|
+
velocities[target] -= dx * share;
|
|
76
|
+
velocities[target + 1] -= dy * share;
|
|
77
|
+
share = 1 - share;
|
|
78
|
+
velocities[source] += dx * share;
|
|
79
|
+
velocities[source + 1] += dy * share;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Slots of the scratch buffers the visitors read: a visitor cannot take the
|
|
84
|
+
// current node as an argument, and a captured `let` would box every double.
|
|
85
|
+
const NODE_X = 0;
|
|
86
|
+
const NODE_Y = 1;
|
|
87
|
+
const ALPHA = 2;
|
|
88
|
+
const SELF = 3;
|
|
89
|
+
const PREVIOUS_DRAW = 4;
|
|
90
|
+
/**
|
|
91
|
+
* Charges repelling or attracting each other with strength / distance:
|
|
92
|
+
* Barnes–Hut (Barnes and Hut, 1986) over a `Quadtree`, each cell standing for
|
|
93
|
+
* its charges at their |charge|-weighted centre once it looks small enough
|
|
94
|
+
* (width² / θ² < distance²), or every pair in `"exact"` mode.
|
|
95
|
+
*/
|
|
96
|
+
export class ManyBodyForce {
|
|
97
|
+
charges;
|
|
98
|
+
options;
|
|
99
|
+
tree = new Quadtree();
|
|
100
|
+
values = new Float64Array(0);
|
|
101
|
+
centersX = new Float64Array(0);
|
|
102
|
+
centersY = new Float64Array(0);
|
|
103
|
+
scratch = Float64Array.of(0, 0, 0, 0, NaN);
|
|
104
|
+
positions = new Float64Array(0);
|
|
105
|
+
velocities = new Float64Array(0);
|
|
106
|
+
order;
|
|
107
|
+
orderLength = 0;
|
|
108
|
+
isExact;
|
|
109
|
+
isInert;
|
|
110
|
+
theta2;
|
|
111
|
+
distanceMin2;
|
|
112
|
+
distanceMax2;
|
|
113
|
+
constructor(charges, options) {
|
|
114
|
+
this.charges = charges;
|
|
115
|
+
this.options = options;
|
|
116
|
+
this.isExact = options.approximation === "exact";
|
|
117
|
+
this.order = new Uint32Array(charges.length);
|
|
118
|
+
this.isInert = charges.every((charge) => charge === 0);
|
|
119
|
+
this.theta2 = options.theta * options.theta;
|
|
120
|
+
this.distanceMin2 = options.distanceMin * options.distanceMin;
|
|
121
|
+
this.distanceMax2 = options.distanceMax * options.distanceMax;
|
|
122
|
+
}
|
|
123
|
+
apply(positions, velocities, alpha) {
|
|
124
|
+
if (this.isInert) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
this.positions = positions;
|
|
128
|
+
this.velocities = velocities;
|
|
129
|
+
this.scratch[ALPHA] = alpha;
|
|
130
|
+
if (this.isExact) {
|
|
131
|
+
this.applyExact(positions, velocities, alpha);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const tree = this.tree;
|
|
135
|
+
tree.assign(positions);
|
|
136
|
+
const needed = tree.nodeCount();
|
|
137
|
+
this.values = grown(this.values, needed);
|
|
138
|
+
this.centersX = grown(this.centersX, needed);
|
|
139
|
+
this.centersY = grown(this.centersY, needed);
|
|
140
|
+
tree.visitAfter(this.accumulate);
|
|
141
|
+
for (let node = 0; node < this.charges.length; node++) {
|
|
142
|
+
this.scratch[NODE_X] = positions[2 * node];
|
|
143
|
+
this.scratch[NODE_Y] = positions[2 * node + 1];
|
|
144
|
+
this.scratch[SELF] = node;
|
|
145
|
+
tree.visit(this.visit);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Every pair, the others taken in the tree's leaf order: the order the
|
|
150
|
+
* Barnes–Hut walk sums them in, so exact and approximate runs differ only by
|
|
151
|
+
* the approximation, not by rounding that chaotic dynamics would amplify.
|
|
152
|
+
*/
|
|
153
|
+
applyExact(positions, velocities, alpha) {
|
|
154
|
+
const { charges, distanceMin2, distanceMax2, tree, order, scratch } = this;
|
|
155
|
+
const { random } = this.options;
|
|
156
|
+
tree.assign(positions);
|
|
157
|
+
this.orderLength = 0;
|
|
158
|
+
tree.visit(this.collectLeaves);
|
|
159
|
+
for (let node = 0; node < charges.length; node++) {
|
|
160
|
+
const x = positions[2 * node];
|
|
161
|
+
const y = positions[2 * node + 1];
|
|
162
|
+
for (let slot = 0; slot < charges.length; slot++) {
|
|
163
|
+
const other = order[slot];
|
|
164
|
+
const charge = charges[other];
|
|
165
|
+
if (other === node || charge === 0) {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
let dx = positions[2 * other] - x;
|
|
169
|
+
let dy = positions[2 * other + 1] - y;
|
|
170
|
+
let squared = dx * dx + dy * dy;
|
|
171
|
+
if (squared >= distanceMax2) {
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (dx === 0) {
|
|
175
|
+
drawPairJiggle(random, node, other, scratch, PREVIOUS_DRAW);
|
|
176
|
+
dx = JIGGLE[0];
|
|
177
|
+
squared += dx * dx;
|
|
178
|
+
}
|
|
179
|
+
if (dy === 0) {
|
|
180
|
+
drawPairJiggle(random, node, other, scratch, PREVIOUS_DRAW);
|
|
181
|
+
dy = JIGGLE[0];
|
|
182
|
+
squared += dy * dy;
|
|
183
|
+
}
|
|
184
|
+
if (squared < distanceMin2) {
|
|
185
|
+
squared = Math.sqrt(distanceMin2 * squared);
|
|
186
|
+
}
|
|
187
|
+
const weight = (charge * alpha) / squared;
|
|
188
|
+
velocities[2 * node] += dx * weight;
|
|
189
|
+
velocities[2 * node + 1] += dy * weight;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
collectLeaves = (node) => {
|
|
194
|
+
const tree = this.tree;
|
|
195
|
+
if (tree.isLeaf(node)) {
|
|
196
|
+
for (let id = tree.nodeFirstPoint(node); id !== -1; id = tree.nextPoint(id)) {
|
|
197
|
+
this.order[this.orderLength++] = id;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return false;
|
|
201
|
+
};
|
|
202
|
+
/** Signed charge and |charge|-weighted centre of every cell, children first. */
|
|
203
|
+
accumulate = (node) => {
|
|
204
|
+
const tree = this.tree;
|
|
205
|
+
let strength = 0;
|
|
206
|
+
let weight = 0;
|
|
207
|
+
let x = 0;
|
|
208
|
+
let y = 0;
|
|
209
|
+
if (tree.isLeaf(node)) {
|
|
210
|
+
const first = tree.nodeFirstPoint(node);
|
|
211
|
+
x = this.positions[2 * first];
|
|
212
|
+
y = this.positions[2 * first + 1];
|
|
213
|
+
for (let id = first; id !== -1; id = tree.nextPoint(id)) {
|
|
214
|
+
strength += this.charges[id];
|
|
215
|
+
}
|
|
216
|
+
this.values[node] = strength;
|
|
217
|
+
this.centersX[node] = x;
|
|
218
|
+
this.centersY[node] = y;
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
for (let quadrant = 0; quadrant < 4; quadrant++) {
|
|
222
|
+
const child = tree.nodeChild(node, quadrant);
|
|
223
|
+
if (child === -1) {
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
const childValue = this.values[child];
|
|
227
|
+
const magnitude = Math.abs(childValue);
|
|
228
|
+
if (magnitude !== 0) {
|
|
229
|
+
strength += childValue;
|
|
230
|
+
weight += magnitude;
|
|
231
|
+
x += magnitude * this.centersX[child];
|
|
232
|
+
y += magnitude * this.centersY[child];
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
this.values[node] = strength;
|
|
236
|
+
this.centersX[node] = x / weight;
|
|
237
|
+
this.centersY[node] = y / weight;
|
|
238
|
+
return false;
|
|
239
|
+
};
|
|
240
|
+
visit = (node, cell) => {
|
|
241
|
+
const value = this.values[node];
|
|
242
|
+
if (value === 0 || Number.isNaN(value)) {
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
const { scratch, tree, distanceMin2, distanceMax2 } = this;
|
|
246
|
+
const { random } = this.options;
|
|
247
|
+
const self = scratch[SELF];
|
|
248
|
+
const alpha = scratch[ALPHA];
|
|
249
|
+
let dx = this.centersX[node] - scratch[NODE_X];
|
|
250
|
+
let dy = this.centersY[node] - scratch[NODE_Y];
|
|
251
|
+
let squared = dx * dx + dy * dy;
|
|
252
|
+
const width = cell[2] - cell[0];
|
|
253
|
+
if ((width * width) / this.theta2 < squared) {
|
|
254
|
+
if (squared < distanceMax2) {
|
|
255
|
+
if (dx === 0) {
|
|
256
|
+
drawJiggle(random, self, -1);
|
|
257
|
+
dx = JIGGLE[0];
|
|
258
|
+
squared += dx * dx;
|
|
259
|
+
}
|
|
260
|
+
if (dy === 0) {
|
|
261
|
+
drawJiggle(random, self, -1);
|
|
262
|
+
dy = JIGGLE[0];
|
|
263
|
+
squared += dy * dy;
|
|
264
|
+
}
|
|
265
|
+
if (squared < distanceMin2) {
|
|
266
|
+
squared = Math.sqrt(distanceMin2 * squared);
|
|
267
|
+
}
|
|
268
|
+
this.velocities[2 * self] += (dx * value * alpha) / squared;
|
|
269
|
+
this.velocities[2 * self + 1] += (dy * value * alpha) / squared;
|
|
270
|
+
}
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
if (!tree.isLeaf(node) || squared >= distanceMax2) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
const first = tree.nodeFirstPoint(node);
|
|
277
|
+
if (first !== self || tree.nextPoint(first) !== -1) {
|
|
278
|
+
// The other point of the leaf, so that two coincident nodes part ways.
|
|
279
|
+
const partner = first === self ? tree.nextPoint(first) : first;
|
|
280
|
+
if (dx === 0) {
|
|
281
|
+
drawPairJiggle(random, self, partner, scratch, PREVIOUS_DRAW);
|
|
282
|
+
dx = JIGGLE[0];
|
|
283
|
+
squared += dx * dx;
|
|
284
|
+
}
|
|
285
|
+
if (dy === 0) {
|
|
286
|
+
drawPairJiggle(random, self, partner, scratch, PREVIOUS_DRAW);
|
|
287
|
+
dy = JIGGLE[0];
|
|
288
|
+
squared += dy * dy;
|
|
289
|
+
}
|
|
290
|
+
if (squared < distanceMin2) {
|
|
291
|
+
squared = Math.sqrt(distanceMin2 * squared);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
for (let id = first; id !== -1; id = tree.nextPoint(id)) {
|
|
295
|
+
if (id !== self) {
|
|
296
|
+
const weight = (this.charges[id] * alpha) / squared;
|
|
297
|
+
this.velocities[2 * self] += dx * weight;
|
|
298
|
+
this.velocities[2 * self + 1] += dy * weight;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return false;
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Pushes overlapping discs apart, nodes tested on their predicted positions
|
|
306
|
+
* (position + velocity). The tree prunes cells by their largest radius, so the
|
|
307
|
+
* result is exact whatever the many-body approximation. Its cells are bounded
|
|
308
|
+
* on the predictions made when the pass starts, as d3-force's are: a node
|
|
309
|
+
* pushed into another's reach by an earlier pair of the same pass can be missed
|
|
310
|
+
* until the next pass. `isLive` widens the pruning by how far any prediction
|
|
311
|
+
* has moved, so no pair is missed (and results differ from d3's).
|
|
312
|
+
*/
|
|
313
|
+
export class CollideForce {
|
|
314
|
+
radii;
|
|
315
|
+
strength;
|
|
316
|
+
iterations;
|
|
317
|
+
random;
|
|
318
|
+
isLive;
|
|
319
|
+
tree = new Quadtree();
|
|
320
|
+
predicted;
|
|
321
|
+
cellRadii = new Float64Array(0);
|
|
322
|
+
scratch = new Float64Array(6);
|
|
323
|
+
positions = new Float64Array(0);
|
|
324
|
+
velocities = new Float64Array(0);
|
|
325
|
+
constructor(radii, strength, iterations, random, isLive = false) {
|
|
326
|
+
this.radii = radii;
|
|
327
|
+
this.strength = strength;
|
|
328
|
+
this.iterations = iterations;
|
|
329
|
+
this.random = random;
|
|
330
|
+
this.isLive = isLive;
|
|
331
|
+
this.predicted = new Float64Array(radii.length * 2);
|
|
332
|
+
}
|
|
333
|
+
apply(positions, velocities) {
|
|
334
|
+
this.positions = positions;
|
|
335
|
+
this.velocities = velocities;
|
|
336
|
+
const { tree, predicted, scratch, radii } = this;
|
|
337
|
+
for (let iteration = 0; iteration < this.iterations; iteration++) {
|
|
338
|
+
for (let index = 0; index < predicted.length; index++) {
|
|
339
|
+
predicted[index] = positions[index] + velocities[index];
|
|
340
|
+
}
|
|
341
|
+
tree.assign(predicted);
|
|
342
|
+
scratch[5] = 0;
|
|
343
|
+
this.cellRadii = grown(this.cellRadii, tree.nodeCount());
|
|
344
|
+
tree.visitAfter(this.prepare);
|
|
345
|
+
for (let node = 0; node < radii.length; node++) {
|
|
346
|
+
const radius = radii[node];
|
|
347
|
+
scratch[0] = positions[2 * node] + velocities[2 * node];
|
|
348
|
+
scratch[1] = positions[2 * node + 1] + velocities[2 * node + 1];
|
|
349
|
+
scratch[2] = radius;
|
|
350
|
+
scratch[3] = radius * radius;
|
|
351
|
+
scratch[4] = node;
|
|
352
|
+
tree.visit(this.visit);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
/** Largest radius under every cell. */
|
|
357
|
+
prepare = (node) => {
|
|
358
|
+
const tree = this.tree;
|
|
359
|
+
let largest = 0;
|
|
360
|
+
if (tree.isLeaf(node)) {
|
|
361
|
+
for (let id = tree.nodeFirstPoint(node); id !== -1; id = tree.nextPoint(id)) {
|
|
362
|
+
largest = Math.max(largest, this.radii[id]);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
for (let quadrant = 0; quadrant < 4; quadrant++) {
|
|
367
|
+
const child = tree.nodeChild(node, quadrant);
|
|
368
|
+
if (child !== -1 && this.cellRadii[child] > largest) {
|
|
369
|
+
largest = this.cellRadii[child];
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
this.cellRadii[node] = largest;
|
|
374
|
+
return false;
|
|
375
|
+
};
|
|
376
|
+
visit = (node, cell) => {
|
|
377
|
+
const { scratch, tree, positions, velocities, radii } = this;
|
|
378
|
+
const xi = scratch[0];
|
|
379
|
+
const yi = scratch[1];
|
|
380
|
+
const radius = scratch[2];
|
|
381
|
+
const radiusSquared = scratch[3];
|
|
382
|
+
const self = scratch[4];
|
|
383
|
+
if (!tree.isLeaf(node)) {
|
|
384
|
+
const reach = radius + this.cellRadii[node] + scratch[5];
|
|
385
|
+
return (cell[0] > xi + reach ||
|
|
386
|
+
cell[2] < xi - reach ||
|
|
387
|
+
cell[1] > yi + reach ||
|
|
388
|
+
cell[3] < yi - reach);
|
|
389
|
+
}
|
|
390
|
+
for (let other = tree.nodeFirstPoint(node); other !== -1; other = tree.nextPoint(other)) {
|
|
391
|
+
if (other <= self) {
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
let otherRadius = radii[other];
|
|
395
|
+
let reach = radius + otherRadius;
|
|
396
|
+
let dx = xi - positions[2 * other] - velocities[2 * other];
|
|
397
|
+
let dy = yi - positions[2 * other + 1] - velocities[2 * other + 1];
|
|
398
|
+
let squared = dx * dx + dy * dy;
|
|
399
|
+
if (squared >= reach * reach) {
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
if (dx === 0) {
|
|
403
|
+
drawJiggle(this.random, other, self);
|
|
404
|
+
dx = JIGGLE[0];
|
|
405
|
+
squared += dx * dx;
|
|
406
|
+
}
|
|
407
|
+
if (dy === 0) {
|
|
408
|
+
drawJiggle(this.random, other, self);
|
|
409
|
+
dy = JIGGLE[0];
|
|
410
|
+
squared += dy * dy;
|
|
411
|
+
}
|
|
412
|
+
const distance = Math.sqrt(squared);
|
|
413
|
+
const push = ((reach - distance) / distance) * this.strength;
|
|
414
|
+
dx *= push;
|
|
415
|
+
dy *= push;
|
|
416
|
+
otherRadius *= otherRadius;
|
|
417
|
+
reach = otherRadius / (radiusSquared + otherRadius);
|
|
418
|
+
velocities[2 * self] += dx * reach;
|
|
419
|
+
velocities[2 * self + 1] += dy * reach;
|
|
420
|
+
reach = 1 - reach;
|
|
421
|
+
velocities[2 * other] -= dx * reach;
|
|
422
|
+
velocities[2 * other + 1] -= dy * reach;
|
|
423
|
+
if (this.isLive) {
|
|
424
|
+
this.noteShift(self);
|
|
425
|
+
this.noteShift(other);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return false;
|
|
429
|
+
};
|
|
430
|
+
/**
|
|
431
|
+
* Cells were bounded on the predictions made at the start of the pass; the
|
|
432
|
+
* pruning test widens them by how far any prediction has moved since.
|
|
433
|
+
*/
|
|
434
|
+
noteShift(node) {
|
|
435
|
+
const { predicted, positions, velocities, scratch } = this;
|
|
436
|
+
const shiftX = Math.abs(positions[2 * node] + velocities[2 * node] - predicted[2 * node]);
|
|
437
|
+
const shiftY = Math.abs(positions[2 * node + 1] +
|
|
438
|
+
velocities[2 * node + 1] -
|
|
439
|
+
predicted[2 * node + 1]);
|
|
440
|
+
scratch[5] = Math.max(scratch[5], shiftX, shiftY);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
/** Pull of strength · alpha toward `(centerX, centerY)` on each axis. */
|
|
444
|
+
export function applyGravity(positions, velocities, alpha, strength, centerX, centerY) {
|
|
445
|
+
for (let index = 0; index < positions.length; index += 2) {
|
|
446
|
+
velocities[index] += (centerX - positions[index]) * strength * alpha;
|
|
447
|
+
velocities[index + 1] +=
|
|
448
|
+
(centerY - positions[index + 1]) * strength * alpha;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Shifts every position so that their mean moves `strength` of the way to the
|
|
453
|
+
* centre.
|
|
454
|
+
*/
|
|
455
|
+
export function applyCentering(positions, strength, centerX, centerY) {
|
|
456
|
+
const count = positions.length / 2;
|
|
457
|
+
if (count === 0) {
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
let sumX = 0;
|
|
461
|
+
let sumY = 0;
|
|
462
|
+
for (let index = 0; index < positions.length; index += 2) {
|
|
463
|
+
sumX += positions[index];
|
|
464
|
+
sumY += positions[index + 1];
|
|
465
|
+
}
|
|
466
|
+
sumX = (sumX / count - centerX) * strength;
|
|
467
|
+
sumY = (sumY / count - centerY) * strength;
|
|
468
|
+
for (let index = 0; index < positions.length; index += 2) {
|
|
469
|
+
positions[index] -= sumX;
|
|
470
|
+
positions[index + 1] -= sumY;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Velocity Verlet: v ← v · keep, x ← x + v; a pinned axis (finite entry of
|
|
475
|
+
* `fixedPositions`) is set to its pin with zero velocity.
|
|
476
|
+
*/
|
|
477
|
+
export function integrate(positions, velocities, keep, fixedPositions) {
|
|
478
|
+
for (let index = 0; index < positions.length; index++) {
|
|
479
|
+
const pin = fixedPositions === undefined ? NaN : fixedPositions[index];
|
|
480
|
+
if (Number.isNaN(pin)) {
|
|
481
|
+
velocities[index] *= keep;
|
|
482
|
+
positions[index] += velocities[index];
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
positions[index] = pin;
|
|
486
|
+
velocities[index] = 0;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
//# sourceMappingURL=_force-forces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_force-forces.js","sourceRoot":"","sources":["../../src/layout/_force-forces.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD;;;;GAIG;AACH,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;AAEnC;;;;;;GAMG;AACH,SAAS,UAAU,CAAC,MAAgB,EAAE,IAAY,EAAE,EAAU;IAC7D,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC;IACtC,MAAM,CAAC,CAAC,CAAC;QACR,KAAK,KAAK,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5E,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,cAAc,CACtB,MAAgB,EAChB,IAAY,EACZ,EAAU,EACV,OA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C,IAAI,GAAG,KAAK,GAAG,OAAO,CAAC,GAAG,QAAQ,CAAC;IAC3C,IAAI,GAAG,CAAC,IAAI,GAAG,KAAK,GAAG,OAAO,CAAC,GAAG,QAAQ,CAAC;IAC3C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC1D,SAAS,CAAC,KAAK,CAAE,IAAI,IAAI,CAAC;QAC1B,SAAS,CAAC,KAAK,GAAG,CAAC,CAAE,IAAI,IAAI,CAAC;IAC/B,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CACxB,SAAuB,EACvB,UAAwB,EACxB,IAAY,EACZ,cAAwC;IAExC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACvD,MAAM,GAAG,GAAG,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAE,CAAC;QACxE,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,UAAU,CAAC,KAAK,CAAE,IAAI,IAAI,CAAC;YAC3B,SAAS,CAAC,KAAK,CAAE,IAAI,UAAU,CAAC,KAAK,CAAE,CAAC;QACzC,CAAC;aAAM,CAAC;YACP,SAAS,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;YACvB,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;IACF,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ChildrenOf } from "@ac-kit/algo";
|
|
2
|
+
import type { HierarchyOrder, HierarchyTable, HierarchyWalkOptions, ValuedHierarchyTraits } from "./types.js";
|
|
3
|
+
export type ValuedHierarchyTable<TNode> = HierarchyTable<TNode> & {
|
|
4
|
+
readonly values: Float64Array;
|
|
5
|
+
};
|
|
6
|
+
export type ValuedHierarchyTableOptions = HierarchyWalkOptions & {
|
|
7
|
+
readonly order?: HierarchyOrder;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Flattens the hierarchy under `root` in pre-order over `walkTree`: no
|
|
11
|
+
* recursion, one budget unit per row. A node reachable through several branches
|
|
12
|
+
* is a separate row each time; a node met again below itself is a cycle.
|
|
13
|
+
*
|
|
14
|
+
* Complexity: O(n) time, O(n) memory.
|
|
15
|
+
*
|
|
16
|
+
* @throws {RangeError} A cycle, naming the repeated row and its ancestor row.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildHierarchyTable<TNode>(root: TNode, childrenOf: ChildrenOf<TNode>, options?: HierarchyWalkOptions, functionName?: string): HierarchyTable<TNode>;
|
|
19
|
+
/**
|
|
20
|
+
* {@link buildHierarchyTable} plus the summed value per row (d3 `sum`/`count`)
|
|
21
|
+
* and, for `"valueDescending"`, children reordered by value, stable.
|
|
22
|
+
*
|
|
23
|
+
* `ownValueOf` is read once per row, in pre-order of the input order, and
|
|
24
|
+
* checked finite and ≥ 0. The sum of a row is its own value plus its
|
|
25
|
+
* children's, added from the last child to the first.
|
|
26
|
+
*
|
|
27
|
+
* Complexity: O(n) time and memory, plus O(k log k) per child list of k
|
|
28
|
+
* children when reordering.
|
|
29
|
+
*
|
|
30
|
+
* @throws {RangeError} A cycle, a value that is not finite and ≥ 0, a sum that
|
|
31
|
+
* overflows (naming the row), or an unknown `order`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildValuedHierarchyTable<TNode>(root: TNode, traits: ValuedHierarchyTraits<TNode>, options?: ValuedHierarchyTableOptions, functionName?: string): ValuedHierarchyTable<TNode>;
|
|
34
|
+
//# sourceMappingURL=_hierarchy-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_hierarchy-table.d.ts","sourceRoot":"","sources":["../../src/layout/_hierarchy-table.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/C,OAAO,KAAK,EACX,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,qBAAqB,EACrB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,oBAAoB,CAAC,KAAK,IAAI,cAAc,CAAC,KAAK,CAAC,GAAG;IACjE,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,oBAAoB,GAAG;IAChE,QAAQ,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;CAChC,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EACxC,IAAI,EAAE,KAAK,EACX,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,EAC7B,OAAO,GAAE,oBAAyB,EAClC,YAAY,SAAW,GACrB,cAAc,CAAC,KAAK,CAAC,CAqCvB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAC9C,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,qBAAqB,CAAC,KAAK,CAAC,EACpC,OAAO,GAAE,2BAAgC,EACzC,YAAY,SAAW,GACrB,oBAAoB,CAAC,KAAK,CAAC,CAkD7B"}
|