@graphty/graphty-element 2.3.1 → 2.4.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 (69) hide show
  1. package/AGENTS.md +4 -3
  2. package/dist/ai.js +3 -3
  3. package/dist/catalog.js +28 -27
  4. package/dist/chunks/{AiManager-BBmGJbH4.js → AiManager-BD9XK30e.js} +5 -5
  5. package/dist/chunks/{DataSource-OeN3NeyD.js → DataSource-B8vf2uhW.js} +3 -3
  6. package/dist/chunks/{GraphSession-Bef1AYw9.js → GraphSession-dcwOjGJh.js} +2821 -2743
  7. package/dist/chunks/{GraphtyError-BwcnblTH.js → GraphtyError-B93WRH3e.js} +8 -6
  8. package/dist/chunks/{GraphtyLogger-5KEttFUo.js → GraphtyLogger-CqOVV13Y.js} +2 -2
  9. package/dist/chunks/{NodeStyle-DKj7HjMJ.js → NodeStyle-CtmA7dXi.js} +16 -14
  10. package/dist/chunks/{VoiceInputAdapter-Dr9Gcmds.js → VoiceInputAdapter-D0tHHi9G.js} +1 -1
  11. package/dist/chunks/{XRPivotCameraController-BbfgZWpS.js → XRPivotCameraController-DTfhvhHz.js} +2 -2
  12. package/dist/chunks/{algorithms-CpX56sUB.js → algorithms-BF0X6RPw.js} +780 -635
  13. package/dist/chunks/{capability-check-Blhb2aBB.js → capability-check-BJzlK4oL.js} +1 -1
  14. package/dist/chunks/{detect-Cqwshr9a.js → detect-vJxK7n0D.js} +2 -2
  15. package/dist/chunks/{format-detection-BXGO1lSn.js → format-detection-C80TLQ2e.js} +1 -1
  16. package/dist/chunks/{index-C0mIoumR.js → index-2xkq7wyD.js} +2623 -2241
  17. package/dist/chunks/{optionsFromZod-17lkrAJs.js → optionsFromZod-BuTOFgVM.js} +146 -139
  18. package/dist/chunks/{paletteRegistry-x7WOEKZY.js → paletteRegistry-A63C71Gn.js} +8 -6
  19. package/dist/chunks/{registry-CSba5QGJ.js → registry-jB46Gmeb.js} +1 -1
  20. package/dist/chunks/{scales-BRwl51k8.js → scales-B2d-7Bf0.js} +572 -399
  21. package/dist/chunks/{types-B7bX5c0K.js → types-C_c53VgR.js} +31 -26
  22. package/dist/commands.d.ts +4 -0
  23. package/dist/custom-elements.json +1 -1
  24. package/dist/extend.js +8 -8
  25. package/dist/graphty-catalog.json +245 -12
  26. package/dist/graphty.bundle.js +37836 -36835
  27. package/dist/graphty.js +11 -11
  28. package/dist/logging.js +2 -2
  29. package/dist/schema.d.ts +1 -1
  30. package/dist/schema.js +42 -40
  31. package/dist/session.js +6 -6
  32. package/dist/src/Graph.d.ts +79 -7
  33. package/dist/src/acceleration/AccelerationController.d.ts +14 -3
  34. package/dist/src/acceleration/types.d.ts +78 -0
  35. package/dist/src/algorithms/KCoreAlgorithm.d.ts +26 -0
  36. package/dist/src/algorithms/LinkPredictionAlgorithm.d.ts +41 -0
  37. package/dist/src/catalog/algorithms.d.ts +5 -5
  38. package/dist/src/catalog/index.d.ts +2 -2
  39. package/dist/src/catalog/layouts.d.ts +7 -6
  40. package/dist/src/catalog/types.d.ts +77 -6
  41. package/dist/src/config/EdgeStyle.d.ts +35 -0
  42. package/dist/src/config/index.d.ts +1 -1
  43. package/dist/src/data/GEXFDataSource.d.ts +23 -0
  44. package/dist/src/errors/codes.d.ts +14 -0
  45. package/dist/src/events.d.ts +30 -0
  46. package/dist/src/graphty-element.d.ts +66 -26
  47. package/dist/src/layout/GridLayoutEngine.d.ts +37 -0
  48. package/dist/src/layout/LayoutEngine.d.ts +7 -7
  49. package/dist/src/layout/NGraphLayoutEngine.d.ts +2 -0
  50. package/dist/src/layout/RadialLayoutEngine.d.ts +37 -0
  51. package/dist/src/layout/SimulationLayoutEngine.d.ts +12 -0
  52. package/dist/src/managers/DataManager.d.ts +69 -2
  53. package/dist/src/managers/EventManager.d.ts +10 -4
  54. package/dist/src/managers/GraphContext.d.ts +2 -1
  55. package/dist/src/managers/LayoutManager.d.ts +30 -3
  56. package/dist/src/meshes/MeshCache.d.ts +18 -0
  57. package/dist/src/meshes/NodeEffects.d.ts +16 -11
  58. package/dist/src/meshes/NodeMesh.d.ts +2 -2
  59. package/dist/src/meshes/RichTextParser.d.ts +26 -0
  60. package/dist/src/meshes/RichTextRenderer.d.ts +0 -1
  61. package/dist/src/session/cost/estimate.d.ts +1 -1
  62. package/dist/src/session/layout.d.ts +3 -3
  63. package/dist/src/session/runs/RunsApi.d.ts +1 -1
  64. package/dist/src/session/styles/StylesApi.d.ts +6 -0
  65. package/dist/src/session/styles/intern.d.ts +26 -5
  66. package/dist/src/session/styles/repaint.d.ts +2 -1
  67. package/dist/src/session/types.d.ts +6 -6
  68. package/dist/webgpu.js +2 -2
  69. package/package.json +6 -6
@@ -1,27 +1,27 @@
1
- import { c as it } from "./common-DWNKjpH_.js";
2
- import { N as st, E as Je } from "./NodeStyle-DKj7HjMJ.js";
3
- import { F as ot, k as rt, a as z, h as N, P as Qe, f as M, A as S, Y as ct, G as lt, H as dt, n as $, L as qe, s as We, e as _, m as oe, i as je, o as Ue } from "./optionsFromZod-17lkrAJs.js";
1
+ import { c as rt } from "./common-DWNKjpH_.js";
2
+ import { E as ct, a as lt, N as dt } from "./NodeStyle-CtmA7dXi.js";
3
+ import { F as ht, k as ut, a as z, h as S, P as tt, f as M, A as v, Y as pt, G as mt, H as gt, n as $, L as Ze, s as je, e as ee, m as re, i as Be, o as Ae } from "./optionsFromZod-BuTOFgVM.js";
4
4
  import { z as c } from "zod/v4";
5
- import { bellmanFord as ht, betweennessCentrality as ut, breadthFirstSearch as pt, bipartitePartition as mt, maximumBipartiteMatching as gt, closenessCentrality as ft, depthFirstSearch as yt, eigenvectorCentrality as bt, ConvergenceError as wt, floydWarshall as vt, girvanNewman as Nt, hits as kt, katzCentrality as St, labelPropagation as Ot, leiden as xt, louvain as It, Graph as _e, fordFulkerson as Mt, kargerMinCut as Ct, stoerWagner as zt, minSTCut as Tt, pageRank as Et, primMST as Dt, stronglyConnectedComponents as Pt } from "@graphty/algorithms";
6
- import { G as et } from "./GraphtyError-BwcnblTH.js";
7
- import { INVALID_INDEX as R } from "@graphty/graph-format";
8
- var Oa = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
9
- function xa(s) {
10
- return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
5
+ import { bellmanFord as ft, betweennessCentrality as yt, breadthFirstSearch as bt, bipartitePartition as wt, maximumBipartiteMatching as vt, closenessCentrality as Nt, depthFirstSearch as kt, eigenvectorCentrality as St, ConvergenceError as Ot, floydWarshall as xt, girvanNewman as It, hits as Mt, katzCentrality as Ct, kCoreDecomposition as zt, labelPropagation as Tt, leiden as Et, commonNeighborsPrediction as Dt, adamicAdarPrediction as Pt, louvain as Rt, Graph as at, fordFulkerson as Ft, kargerMinCut as $t, stoerWagner as Gt, minSTCut as Ht, pageRank as Wt, primMST as Kt, stronglyConnectedComponents as Lt } from "@graphty/algorithms";
6
+ import { G as nt } from "./GraphtyError-B93WRH3e.js";
7
+ import { INVALID_INDEX as F } from "@graphty/graph-format";
8
+ var Fa = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
9
+ function $a(o) {
10
+ return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
11
11
  }
12
- const Rt = /^#?(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;
13
- function Le(s) {
14
- return Number.isFinite(s) ? Math.max(0, Math.min(255, Math.round(s))) : 0;
12
+ const Ut = /^#?(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;
13
+ function qe(o) {
14
+ return Number.isFinite(o) ? Math.max(0, Math.min(255, Math.round(o))) : 0;
15
15
  }
16
- function ne(s) {
17
- return s.toString(16).padStart(2, "0");
16
+ function ie(o) {
17
+ return o.toString(16).padStart(2, "0");
18
18
  }
19
- function Ft(s) {
20
- if (!Rt.test(s))
19
+ function jt(o) {
20
+ if (!Ut.test(o))
21
21
  return null;
22
- const e = s.startsWith("#") ? s.slice(1) : s, t = e.length <= 4, n = (i) => {
23
- const o = t ? e[i].repeat(2) : e.slice(i * 2, i * 2 + 2);
24
- return parseInt(o, 16);
22
+ const e = o.startsWith("#") ? o.slice(1) : o, t = e.length <= 4, n = (i) => {
23
+ const s = t ? e[i].repeat(2) : e.slice(i * 2, i * 2 + 2);
24
+ return parseInt(s, 16);
25
25
  }, a = e.length === 4 || e.length === 8;
26
26
  return {
27
27
  r: n(0),
@@ -30,29 +30,29 @@ function Ft(s) {
30
30
  a: a ? n(3) / 255 : 1
31
31
  };
32
32
  }
33
- function Ia(s) {
34
- return typeof s != "object" || s === null || !("hex" in s) ? null : s;
33
+ function Ga(o) {
34
+ return typeof o != "object" || o === null || !("hex" in o) ? null : o;
35
35
  }
36
- function $t(s) {
37
- if (s == null)
36
+ function Vt(o) {
37
+ if (o == null)
38
38
  return null;
39
- if (typeof s == "object")
40
- return Ae(s);
41
- const e = Ft(s);
39
+ if (typeof o == "object")
40
+ return Xe(o);
41
+ const e = jt(o);
42
42
  if (e !== null)
43
- return Ae(e);
43
+ return Xe(e);
44
44
  try {
45
- const t = it(s);
46
- return t === void 0 ? null : $t(t);
45
+ const t = rt(o);
46
+ return t === void 0 ? null : Vt(t);
47
47
  } catch {
48
48
  return null;
49
49
  }
50
50
  }
51
- function Ae(s) {
52
- const e = Le(s.r), t = Le(s.g), n = Le(s.b), a = Number.isFinite(s.a) ? Math.max(0, Math.min(1, s.a)) : 1, i = `#${ne(e)}${ne(t)}${ne(n)}`;
53
- return { r: e, g: t, b: n, a, hex: a === 1 ? i : `${i}${ne(Math.round(a * 255))}` };
51
+ function Xe(o) {
52
+ const e = qe(o.r), t = qe(o.g), n = qe(o.b), a = Number.isFinite(o.a) ? Math.max(0, Math.min(1, o.a)) : 1, i = `#${ie(e)}${ie(t)}${ie(n)}`;
53
+ return { r: e, g: t, b: n, a, hex: a === 1 ? i : `${i}${ie(Math.round(a * 255))}` };
54
54
  }
55
- const Gt = st.options, Ht = Je.shape.line.unwrap().shape.type.unwrap().options, Be = Je.shape.arrowHead.unwrap().shape.type.unwrap().unwrap().options, Wt = "An outline has a colour and no width. Babylon draws it with a highlight LAYER, and the stroke's blur size belongs to that layer rather than to a mesh, so every outline on screen is drawn at one width whatever a style asks for -- which is why the node style declares no outline width to ask with. The outline's COLOUR is per style; a width per style would need one highlight layer per width, at a full-screen pass each.", ie = 'A caption hangs from the cap at that end of the edge, so an end drawn with no arrow carries none: a tail caption needs `edge.arrowTail` set to something other than "none". The words are what switch a caption on, so a layer that writes only the caption\'s appearance and no words draws nothing, exactly as `node.labelStyle` draws nothing without `node.label`.', Ye = "A tooltip is drawn on hover and only on hover, so a graph at rest shows none: a layer that writes one changes nothing until a reader points at the node. The words are what switch it on, so a layer that writes only the tooltip's appearance and no words draws nothing, exactly as `node.labelStyle` draws nothing without `node.label`. Only a NODE has a tooltip; `edge.tooltip` was withdrawn in 2.0 because an edge cannot be hovered.", te = {
55
+ const qt = dt.options, At = lt.options, Je = ct.options, Bt = "An outline has a colour and no width. Babylon draws it with a highlight LAYER, and the stroke's blur size belongs to that layer rather than to a mesh, so every outline on screen is drawn at one width whatever a style asks for -- which is why the node style declares no outline width to ask with. The outline's COLOUR is per style; a width per style would need one highlight layer per width, at a full-screen pass each.", se = 'A caption hangs from the cap at that end of the edge, so an end drawn with no arrow carries none: a tail caption needs `edge.arrowTail` set to something other than "none". The words are what switch a caption on, so a layer that writes only the caption\'s appearance and no words draws nothing, exactly as `node.labelStyle` draws nothing without `node.label`.', Qe = "A tooltip is drawn on hover and only on hover, so a graph at rest shows none: a layer that writes one changes nothing until a reader points at the node. The words are what switch it on, so a layer that writes only the tooltip's appearance and no words draws nothing, exactly as `node.labelStyle` draws nothing without `node.label`. Only a NODE has a tooltip; `edge.tooltip` was withdrawn in 2.0 because an edge cannot be hovered.", ae = {
56
56
  "node.color": {
57
57
  channel: "node.color",
58
58
  target: "node",
@@ -75,7 +75,7 @@ const Gt = st.options, Ht = Je.shape.line.unwrap().shape.type.unwrap().options,
75
75
  target: "node",
76
76
  plainName: "Node Shape",
77
77
  accepts: "enum",
78
- values: Gt,
78
+ values: qt,
79
79
  stylePath: "shape.type",
80
80
  renderable: !0
81
81
  },
@@ -102,7 +102,7 @@ const Gt = st.options, Ht = Je.shape.line.unwrap().shape.type.unwrap().options,
102
102
  accepts: "text",
103
103
  stylePath: "tooltip.text",
104
104
  renderable: !0,
105
- caveat: Ye
105
+ caveat: Qe
106
106
  },
107
107
  "node.tooltipStyle": {
108
108
  channel: "node.tooltipStyle",
@@ -111,7 +111,7 @@ const Gt = st.options, Ht = Je.shape.line.unwrap().shape.type.unwrap().options,
111
111
  accepts: "labelStyle",
112
112
  stylePath: "tooltip",
113
113
  renderable: !0,
114
- caveat: Ye
114
+ caveat: Qe
115
115
  },
116
116
  "node.opacity": {
117
117
  channel: "node.opacity",
@@ -130,7 +130,7 @@ const Gt = st.options, Ht = Je.shape.line.unwrap().shape.type.unwrap().options,
130
130
  accepts: "color",
131
131
  stylePath: "effect.outline.color",
132
132
  renderable: !0,
133
- caveat: Wt
133
+ caveat: Bt
134
134
  },
135
135
  "node.glow": {
136
136
  channel: "node.glow",
@@ -206,7 +206,7 @@ const Gt = st.options, Ht = Je.shape.line.unwrap().shape.type.unwrap().options,
206
206
  target: "edge",
207
207
  plainName: "Edge Line Pattern",
208
208
  accepts: "enum",
209
- values: Ht,
209
+ values: At,
210
210
  stylePath: "line.type",
211
211
  renderable: !0
212
212
  },
@@ -234,7 +234,7 @@ const Gt = st.options, Ht = Je.shape.line.unwrap().shape.type.unwrap().options,
234
234
  target: "edge",
235
235
  plainName: "Arrow Head",
236
236
  accepts: "enum",
237
- values: Be,
237
+ values: Je,
238
238
  stylePath: "arrowHead.type",
239
239
  renderable: !0
240
240
  },
@@ -272,7 +272,7 @@ const Gt = st.options, Ht = Je.shape.line.unwrap().shape.type.unwrap().options,
272
272
  accepts: "text",
273
273
  stylePath: "arrowHead.text.text",
274
274
  renderable: !0,
275
- caveat: ie
275
+ caveat: se
276
276
  },
277
277
  "edge.arrowHeadTextStyle": {
278
278
  channel: "edge.arrowHeadTextStyle",
@@ -281,14 +281,14 @@ const Gt = st.options, Ht = Je.shape.line.unwrap().shape.type.unwrap().options,
281
281
  accepts: "labelStyle",
282
282
  stylePath: "arrowHead.text",
283
283
  renderable: !0,
284
- caveat: ie
284
+ caveat: se
285
285
  },
286
286
  "edge.arrowTail": {
287
287
  channel: "edge.arrowTail",
288
288
  target: "edge",
289
289
  plainName: "Arrow Tail",
290
290
  accepts: "enum",
291
- values: Be,
291
+ values: Je,
292
292
  stylePath: "arrowTail.type",
293
293
  renderable: !0
294
294
  },
@@ -326,7 +326,7 @@ const Gt = st.options, Ht = Je.shape.line.unwrap().shape.type.unwrap().options,
326
326
  accepts: "text",
327
327
  stylePath: "arrowTail.text.text",
328
328
  renderable: !0,
329
- caveat: ie
329
+ caveat: se
330
330
  },
331
331
  "edge.arrowTailTextStyle": {
332
332
  channel: "edge.arrowTailTextStyle",
@@ -335,7 +335,7 @@ const Gt = st.options, Ht = Je.shape.line.unwrap().shape.type.unwrap().options,
335
335
  accepts: "labelStyle",
336
336
  stylePath: "arrowTail.text",
337
337
  renderable: !0,
338
- caveat: ie
338
+ caveat: se
339
339
  },
340
340
  "edge.animationSpeed": {
341
341
  channel: "edge.animationSpeed",
@@ -362,22 +362,22 @@ const Gt = st.options, Ht = Je.shape.line.unwrap().shape.type.unwrap().options,
362
362
  stylePath: "label",
363
363
  renderable: !0
364
364
  }
365
- }, tt = Object.keys(te);
366
- tt.filter(
367
- (s) => te[s].accepts === "color"
365
+ }, it = Object.keys(ae);
366
+ it.filter(
367
+ (o) => ae[o].accepts === "color"
368
368
  );
369
- function Kt(s) {
370
- return typeof s == "string" && Object.hasOwn(te, s);
369
+ function Yt(o) {
370
+ return typeof o == "string" && Object.hasOwn(ae, o);
371
371
  }
372
- function Ma(s) {
373
- return Kt(s) ? te[s] : void 0;
372
+ function Ha(o) {
373
+ return Yt(o) ? ae[o] : void 0;
374
374
  }
375
- function Ca(s) {
376
- return tt.map((e) => te[e]).filter(
377
- (e) => e.target === s
375
+ function Wa(o) {
376
+ return it.map((e) => ae[e]).filter(
377
+ (e) => e.target === o
378
378
  );
379
379
  }
380
- const at = Object.freeze([
380
+ const st = Object.freeze([
381
381
  {
382
382
  id: "fitToGraph",
383
383
  plainName: "Fit to graph",
@@ -414,41 +414,41 @@ const at = Object.freeze([
414
414
  options: []
415
415
  }
416
416
  ]);
417
- function za(s) {
418
- return at.find((e) => e.id === s) ?? ot(s)?.descriptor;
417
+ function Ka(o) {
418
+ return st.find((e) => e.id === o) ?? ht(o)?.descriptor;
419
419
  }
420
- function Ta(s) {
421
- return [...at, ...rt()].filter(
422
- (e) => e.modes.includes(s)
420
+ function La(o) {
421
+ return [...st, ...ut()].filter(
422
+ (e) => e.modes.includes(o)
423
423
  );
424
424
  }
425
- function Ea(s) {
426
- return s;
425
+ function Ua(o) {
426
+ return o;
427
427
  }
428
- function Lt(s) {
428
+ function Zt(o) {
429
429
  const e = {};
430
- for (const [t, n] of Object.entries(s))
430
+ for (const [t, n] of Object.entries(o))
431
431
  e[t] = n.schema;
432
432
  return c.object(e);
433
433
  }
434
- function Ut(s, e) {
435
- return Lt(s).parse(e);
434
+ function Xt(o, e) {
435
+ return Zt(o).parse(e);
436
436
  }
437
- function T(s, e) {
438
- return `${String(s)}:${String(e)}`;
437
+ function T(o, e) {
438
+ return `${String(o)}:${String(e)}`;
439
439
  }
440
- function re(s, e, t, n) {
440
+ function ce(o, e, t, n) {
441
441
  const a = String(t);
442
442
  if (!n.some((i) => String(i) === a))
443
- throw new et({
443
+ throw new nt({
444
444
  code: "E_OPTION_RANGE",
445
445
  source: "run",
446
- message: `${s}: the ${e} option names node "${a}", which is not in the graph.`,
447
- details: { algorithm: s, option: e, value: t }
446
+ message: `${o}: the ${e} option names node "${a}", which is not in the graph.`,
447
+ details: { algorithm: o, option: e, value: t }
448
448
  });
449
449
  return a;
450
450
  }
451
- const jt = {
451
+ const Jt = {
452
452
  source: {
453
453
  schema: c.union([c.string(), c.number()]).nullable().default(null),
454
454
  meta: {
@@ -492,43 +492,43 @@ const jt = {
492
492
  const t = this.graph.getDataManager(), n = Array.from(t.nodes.keys());
493
493
  if (n.length === 0)
494
494
  return null;
495
- const a = this.legacyOptions?.source ?? this._schemaOptions.source ?? n[0], i = this.legacyOptions?.target ?? this._schemaOptions.target ?? n[n.length - 1], o = this.algorithmGraph("undirected");
495
+ const a = this.legacyOptions?.source ?? this._schemaOptions.source ?? n[0], i = this.legacyOptions?.target ?? this._schemaOptions.target ?? n[n.length - 1], s = this.algorithmGraph("undirected");
496
496
  e.report({ phase: "Relaxing edges", total: null });
497
- const r = ht(o, a), d = this.reconstructPath(r.predecessors, a, i), h = /* @__PURE__ */ new Map();
498
- d.forEach((f, O) => h.set(f, O));
499
- for (const f of r.distances.values())
497
+ const r = ft(s, a), l = this.reconstructPath(r.predecessors, a, i), h = /* @__PURE__ */ new Map();
498
+ l.forEach((g, x) => h.set(g, x));
499
+ for (const g of r.distances.values())
500
500
  ;
501
501
  const m = [];
502
- await N(e, "Marking the route", n, (f) => {
503
- const O = h.get(f), y = r.distances.get(f) ?? 1 / 0;
504
- m.push({ id: f, values: { onPath: O !== void 0, order: O, distance: y } });
502
+ await S(e, "Marking the route", n, (g) => {
503
+ const x = h.get(g), y = r.distances.get(g) ?? 1 / 0;
504
+ m.push({ id: g, values: { onPath: x !== void 0, order: x, distance: y } });
505
505
  });
506
- const l = this.getPathEdges(d), u = [];
507
- await N(e, "Marking the route", Array.from(t.edges.values()), (f) => {
508
- const O = T(f.srcId, f.dstId), y = T(f.dstId, f.srcId);
509
- u.push({ id: f.id, values: { onPath: l.has(O) || l.has(y) } });
506
+ const d = this.getPathEdges(l), p = [];
507
+ await S(e, "Marking the route", Array.from(t.edges.values()), (g) => {
508
+ const x = T(g.srcId, g.dstId), y = T(g.dstId, g.srcId);
509
+ p.push({ id: g.id, values: { onPath: d.has(x) || d.has(y) } });
510
510
  });
511
- const p = [`Route from ${String(a)} to ${String(i)}.`];
512
- return r.hasNegativeCycle && p.push("A loop that costs less every time round was found, so no distance past it is meaningful."), {
511
+ const u = [`Route from ${String(a)} to ${String(i)}.`];
512
+ return r.hasNegativeCycle && u.push("A loop that costs less every time round was found, so no distance past it is meaningful."), {
513
513
  shape: "path",
514
514
  fields: [
515
- ...Qe,
515
+ ...tt,
516
516
  { name: "distance", kind: "node", type: "number" },
517
517
  { name: "hasNegativeCycle", kind: "graph", type: "boolean" }
518
518
  ],
519
519
  nodes: m,
520
- edges: u,
520
+ edges: p,
521
521
  graph: {
522
- length: d.length,
523
- cost: d.length > 0 ? r.distances.get(i) ?? 0 : 0,
524
- hops: Math.max(d.length - 1, 0),
522
+ length: l.length,
523
+ cost: l.length > 0 ? r.distances.get(i) ?? 0 : 0,
524
+ hops: Math.max(l.length - 1, 0),
525
525
  hasNegativeCycle: r.hasNegativeCycle
526
526
  },
527
527
  caveats: M({
528
528
  method: "bellman-ford",
529
529
  direction: "undirected",
530
530
  weight: { attribute: "weight", meaning: "distance" },
531
- notes: p
531
+ notes: u
532
532
  })
533
533
  };
534
534
  }
@@ -558,7 +558,7 @@ const jt = {
558
558
  return t;
559
559
  }
560
560
  };
561
- W.namespace = "graphty", W.type = "bellman-ford", W.zodOptionsSchema = jt, W.optionsSchema = {
561
+ W.namespace = "graphty", W.type = "bellman-ford", W.zodOptionsSchema = Jt, W.optionsSchema = {
562
562
  source: {
563
563
  type: "nodeId",
564
564
  default: null,
@@ -574,12 +574,12 @@ W.namespace = "graphty", W.type = "bellman-ford", W.zodOptionsSchema = jt, W.opt
574
574
  required: !1
575
575
  }
576
576
  };
577
- let ce = W;
578
- S.register(ce);
579
- const Vt = 2048;
580
- function qt(s) {
577
+ let le = W;
578
+ v.register(le);
579
+ const Qt = 2048;
580
+ function _t(o) {
581
581
  return {
582
- runId: s,
582
+ runId: o,
583
583
  signal: new AbortController().signal,
584
584
  report: () => {
585
585
  },
@@ -588,14 +588,14 @@ function qt(s) {
588
588
  })
589
589
  };
590
590
  }
591
- async function F(s, e, t, n) {
592
- const a = s.length;
591
+ async function D(o, e, t, n) {
592
+ const a = o.length;
593
593
  let i = performance.now();
594
- for (let o = 0; o < a; o++)
595
- e.signal.throwIfAborted(), n(s[o], o), (o + 1) % Vt === 0 && o + 1 < a && (e.report({ phase: t, completed: o + 1, total: a }), performance.now() - i >= ct && (await e.yieldNow(), i = performance.now()));
594
+ for (let s = 0; s < a; s++)
595
+ e.signal.throwIfAborted(), n(o[s], s), (s + 1) % Qt === 0 && s + 1 < a && (e.report({ phase: t, completed: s + 1, total: a }), performance.now() - i >= pt && (await e.yieldNow(), i = performance.now()));
596
596
  e.report({ phase: t, completed: a, total: a });
597
597
  }
598
- class G extends S {
598
+ class G extends v {
599
599
  /** What the last run published, kept so a caller that has the algorithm can read the result. */
600
600
  #e;
601
601
  /**
@@ -615,7 +615,7 @@ class G extends S {
615
615
  * @returns A promise that settles once the result has been published.
616
616
  */
617
617
  async run() {
618
- await this.measureRun(qt(this.type));
618
+ await this.measureRun(_t(this.type));
619
619
  }
620
620
  /**
621
621
  * Measure the graph on behalf of a run, and hand the result back.
@@ -642,8 +642,8 @@ class G extends S {
642
642
  const t = this.graph.getDataManager(), n = Array.from(t.nodes.keys());
643
643
  if (n.length === 0)
644
644
  return;
645
- const a = Date.now(), i = await this.measure(e, n), o = lt(this.graph), r = dt({
646
- ...o === void 0 ? {} : { labelOf: o },
645
+ const a = Date.now(), i = await this.measure(e, n), s = mt(this.graph), r = gt({
646
+ ...s === void 0 ? {} : { labelOf: s },
647
647
  runId: e.runId,
648
648
  shape: "node-metric",
649
649
  fields: this.resultFields(),
@@ -659,16 +659,16 @@ class G extends S {
659
659
  return this.#e = r, r;
660
660
  }
661
661
  }
662
- const At = $({
662
+ const ea = $({
663
663
  plainName: "Bridging",
664
664
  technicalName: "betweenness"
665
- }), Ee = class Ee extends G {
665
+ }), Re = class Re extends G {
666
666
  /**
667
667
  * The fields a betweenness result publishes.
668
668
  * @returns The uniform node-metric fields.
669
669
  */
670
670
  resultFields() {
671
- return At;
671
+ return ea;
672
672
  }
673
673
  /**
674
674
  * Score every node by the shortest paths that run through it.
@@ -684,12 +684,12 @@ const At = $({
684
684
  total: t.length,
685
685
  message: "Brandes runs a breadth-first search from every node."
686
686
  });
687
- const a = ut(n);
687
+ const a = yt(n);
688
688
  e.signal.throwIfAborted();
689
689
  const i = [];
690
- return await F(t, e, "reading scores", (o) => {
691
- const r = a[String(o)];
692
- i.push({ id: o, values: r === void 0 ? {} : { value: r } });
690
+ return await D(t, e, "reading scores", (s) => {
691
+ const r = a[String(s)];
692
+ i.push({ id: s, values: r === void 0 ? {} : { value: r } });
693
693
  }), {
694
694
  nodes: i,
695
695
  // Raw counts. `options.normalized` is not set, so nothing rescales them.
@@ -709,10 +709,10 @@ const At = $({
709
709
  };
710
710
  }
711
711
  };
712
- Ee.namespace = "graphty", Ee.type = "betweenness";
713
- let le = Ee;
714
- S.register(le);
715
- const Bt = {
712
+ Re.namespace = "graphty", Re.type = "betweenness";
713
+ let de = Re;
714
+ v.register(de);
715
+ const ta = {
716
716
  source: {
717
717
  schema: c.union([c.string(), c.number()]).nullable().default(null),
718
718
  meta: {
@@ -763,19 +763,19 @@ const Bt = {
763
763
  const i = this.legacyOptions?.source ?? this._schemaOptions.source ?? a.ids.idOf(0);
764
764
  if (n !== void 0)
765
765
  return this.legacyWalk(e, t, i, n);
766
- const { snapshot: o, run: r } = this.accelerated("breadthFirstSearch", "undirected"), d = this.nodeIndex(o, "source", i);
766
+ const { snapshot: s, run: r } = this.accelerated("breadthFirstSearch", "undirected"), l = this.nodeIndex(s, "source", i);
767
767
  e.report({ phase: "Walking outwards", total: null });
768
- const { value: h, precision: m } = await r((p, f) => p.breadthFirstSearch(f, d)), l = /* @__PURE__ */ new Map();
769
- for (let p = 0; p < h.visitedCount; p++)
770
- l.set(h.order[p], p);
771
- const u = [];
772
- return await N(e, "Recording levels", t, (p) => {
773
- const f = o.ids.indexOf(p), O = f === R ? R : h.depth[f];
774
- O !== R && u.push({ id: p, values: { level: O, order: l.get(f) } });
768
+ const { value: h, precision: m } = await r((u, g) => u.breadthFirstSearch(g, l)), d = /* @__PURE__ */ new Map();
769
+ for (let u = 0; u < h.visitedCount; u++)
770
+ d.set(h.order[u], u);
771
+ const p = [];
772
+ return await S(e, "Recording levels", t, (u) => {
773
+ const g = s.ids.indexOf(u), x = g === F ? F : h.depth[g];
774
+ x !== F && p.push({ id: u, values: { level: x, order: d.get(g) } });
775
775
  }), {
776
776
  shape: "layered-grouping",
777
- fields: [...qe, { name: "order", kind: "node", type: "integer" }],
778
- nodes: u,
777
+ fields: [...Ze, { name: "order", kind: "node", type: "integer" }],
778
+ nodes: p,
779
779
  caveats: M({
780
780
  method: "bfs",
781
781
  direction: "undirected",
@@ -797,27 +797,27 @@ const Bt = {
797
797
  const i = this.algorithmGraph("undirected");
798
798
  if (!i.hasNode(n))
799
799
  return null;
800
- const o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
801
- let d = !1;
802
- e.report({ phase: "Walking outwards", total: null }), pt(i, n, {
800
+ const s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
801
+ let l = !1;
802
+ e.report({ phase: "Walking outwards", total: null }), bt(i, n, {
803
803
  targetNode: a,
804
- visitCallback: (l, u) => {
805
- o.set(l, u), r.set(l, r.size), l === a && (d = !0);
804
+ visitCallback: (d, p) => {
805
+ s.set(d, p), r.set(d, r.size), d === a && (l = !0);
806
806
  }
807
807
  });
808
808
  const h = [];
809
- return await N(e, "Recording levels", t, (l) => {
810
- const u = o.get(l);
811
- u !== void 0 && h.push({ id: l, values: { level: u, order: r.get(l) } });
809
+ return await S(e, "Recording levels", t, (d) => {
810
+ const p = s.get(d);
811
+ p !== void 0 && h.push({ id: d, values: { level: p, order: r.get(d) } });
812
812
  }), {
813
813
  shape: "layered-grouping",
814
814
  fields: [
815
- ...qe,
815
+ ...Ze,
816
816
  { name: "order", kind: "node", type: "integer" },
817
817
  { name: "targetFound", kind: "graph", type: "boolean" }
818
818
  ],
819
819
  nodes: h,
820
- graph: { targetFound: d },
820
+ graph: { targetFound: l },
821
821
  caveats: M({
822
822
  method: "bfs",
823
823
  direction: "undirected",
@@ -830,7 +830,7 @@ const Bt = {
830
830
  };
831
831
  }
832
832
  };
833
- K.namespace = "graphty", K.type = "bfs", K.zodOptionsSchema = Bt, K.optionsSchema = {
833
+ K.namespace = "graphty", K.type = "bfs", K.zodOptionsSchema = ta, K.optionsSchema = {
834
834
  source: {
835
835
  type: "nodeId",
836
836
  default: null,
@@ -847,9 +847,9 @@ K.namespace = "graphty", K.type = "bfs", K.zodOptionsSchema = Bt, K.optionsSchem
847
847
  advanced: !0
848
848
  }
849
849
  };
850
- let de = K;
851
- S.register(de);
852
- const De = class De extends z {
850
+ let he = K;
851
+ v.register(he);
852
+ const Fe = class Fe extends z {
853
853
  /**
854
854
  * Pair up the two sides of a two-sided graph so that as many nodes as possible get a partner.
855
855
  *
@@ -865,20 +865,20 @@ const De = class De extends z {
865
865
  if (t.length === 0)
866
866
  return null;
867
867
  const n = this.algorithmGraph("undirected"), a = [
868
- ...We("edge", { name: "bipartite", type: "boolean" }),
868
+ ...je("edge", { name: "bipartite", type: "boolean" }),
869
869
  { name: "side", kind: "node", type: "string" },
870
870
  { name: "matched", kind: "node", type: "boolean" }
871
871
  ];
872
872
  e.report({ phase: "Checking for two sides", total: null });
873
- const i = mt(n);
873
+ const i = wt(n);
874
874
  if (i === null) {
875
- const l = [];
876
- return await N(e, "Marking the pairing", t, (u) => {
877
- l.push({ id: u.id, values: { in: !1 } });
875
+ const d = [];
876
+ return await S(e, "Marking the pairing", t, (p) => {
877
+ d.push({ id: p.id, values: { in: !1 } });
878
878
  }), {
879
879
  shape: "edge-set",
880
880
  fields: a,
881
- edges: l,
881
+ edges: d,
882
882
  graph: { bipartite: !1 },
883
883
  caveats: M({
884
884
  method: "bipartite-matching",
@@ -889,49 +889,49 @@ const De = class De extends z {
889
889
  };
890
890
  }
891
891
  e.report({ phase: "Pairing nodes", total: null });
892
- const o = gt(n, {
892
+ const s = vt(n, {
893
893
  leftNodes: i.left,
894
894
  rightNodes: i.right
895
895
  }), r = /* @__PURE__ */ new Set();
896
- for (const [l, u] of o.matching)
897
- r.add(T(l, u)), r.add(T(u, l));
898
- const d = [];
899
- await N(e, "Marking the pairing", t, (l) => {
900
- d.push({ id: l.id, values: { in: r.has(T(l.srcId, l.dstId)) } });
896
+ for (const [d, p] of s.matching)
897
+ r.add(T(d, p)), r.add(T(p, d));
898
+ const l = [];
899
+ await S(e, "Marking the pairing", t, (d) => {
900
+ l.push({ id: d.id, values: { in: r.has(T(d.srcId, d.dstId)) } });
901
901
  });
902
- const h = new Set(o.matching.values()), m = [];
903
- return await N(e, "Marking sides", Array.from(i.left), (l) => {
904
- m.push({ id: l, values: { side: "left", matched: o.matching.has(l) } });
905
- }), await N(e, "Marking sides", Array.from(i.right), (l) => {
906
- m.push({ id: l, values: { side: "right", matched: h.has(l) } });
902
+ const h = new Set(s.matching.values()), m = [];
903
+ return await S(e, "Marking sides", Array.from(i.left), (d) => {
904
+ m.push({ id: d, values: { side: "left", matched: s.matching.has(d) } });
905
+ }), await S(e, "Marking sides", Array.from(i.right), (d) => {
906
+ m.push({ id: d, values: { side: "right", matched: h.has(d) } });
907
907
  }), {
908
908
  shape: "edge-set",
909
909
  fields: a,
910
910
  nodes: m,
911
- edges: d,
911
+ edges: l,
912
912
  graph: { bipartite: !0 },
913
913
  caveats: M({
914
914
  method: "bipartite-matching",
915
915
  direction: "undirected",
916
916
  weight: null,
917
- notes: [`${String(o.size)} of the two sides' nodes found a partner.`]
917
+ notes: [`${String(s.size)} of the two sides' nodes found a partner.`]
918
918
  })
919
919
  };
920
920
  }
921
921
  };
922
- De.namespace = "graphty", De.type = "bipartite-matching";
923
- let he = De;
924
- S.register(he);
925
- const Yt = $({
922
+ Fe.namespace = "graphty", Fe.type = "bipartite-matching";
923
+ let ue = Fe;
924
+ v.register(ue);
925
+ const aa = $({
926
926
  plainName: "Reach",
927
927
  technicalName: "closeness"
928
- }), Pe = class Pe extends G {
928
+ }), $e = class $e extends G {
929
929
  /**
930
930
  * The fields a closeness result publishes.
931
931
  * @returns The uniform node-metric fields.
932
932
  */
933
933
  resultFields() {
934
- return Yt;
934
+ return aa;
935
935
  }
936
936
  /**
937
937
  * Score every node by how short its paths to the rest of the graph are.
@@ -947,12 +947,12 @@ const Yt = $({
947
947
  total: t.length,
948
948
  message: "A breadth-first search runs from every node."
949
949
  });
950
- const a = ft(n);
950
+ const a = Nt(n);
951
951
  e.signal.throwIfAborted();
952
952
  const i = [];
953
- return await F(t, e, "reading scores", (o) => {
954
- const r = a[String(o)];
955
- i.push({ id: o, values: r === void 0 ? {} : { value: r } });
953
+ return await D(t, e, "reading scores", (s) => {
954
+ const r = a[String(s)];
955
+ i.push({ id: s, values: r === void 0 ? {} : { value: r } });
956
956
  }), {
957
957
  nodes: i,
958
958
  // The algorithm's own figure, published as it was computed.
@@ -972,10 +972,10 @@ const Yt = $({
972
972
  };
973
973
  }
974
974
  };
975
- Pe.namespace = "graphty", Pe.type = "closeness";
976
- let ue = Pe;
977
- S.register(ue);
978
- const Re = class Re extends z {
975
+ $e.namespace = "graphty", $e.type = "closeness";
976
+ let pe = $e;
977
+ v.register(pe);
978
+ const Ge = class Ge extends z {
979
979
  /**
980
980
  * Find the separate pieces of the graph.
981
981
  *
@@ -991,14 +991,14 @@ const Re = class Re extends z {
991
991
  return null;
992
992
  const { snapshot: n, run: a } = this.accelerated("connectedComponents", "undirected"), { ids: i } = n;
993
993
  e.report({ phase: "Finding pieces", total: null });
994
- const { value: o, precision: r } = await a((h, m) => h.connectedComponents(m)), d = [];
995
- return await N(e, "Grouping nodes", t, (h) => {
994
+ const { value: s, precision: r } = await a((h, m) => h.connectedComponents(m)), l = [];
995
+ return await S(e, "Grouping nodes", t, (h) => {
996
996
  const m = i.indexOf(h);
997
- d.push({ id: h, values: { group: o.labels[m] ?? 0 } });
997
+ l.push({ id: h, values: { group: s.labels[m] ?? 0 } });
998
998
  }), {
999
999
  shape: "community",
1000
- fields: _(!1),
1001
- nodes: d,
1000
+ fields: ee(!1),
1001
+ nodes: l,
1002
1002
  caveats: M({
1003
1003
  method: "connected-components",
1004
1004
  direction: "undirected",
@@ -1009,32 +1009,32 @@ const Re = class Re extends z {
1009
1009
  };
1010
1010
  }
1011
1011
  };
1012
- Re.namespace = "graphty", Re.type = "connected-components";
1013
- let pe = Re;
1014
- S.register(pe);
1015
- const Zt = [
1012
+ Ge.namespace = "graphty", Ge.type = "connected-components";
1013
+ let me = Ge;
1014
+ v.register(me);
1015
+ const na = [
1016
1016
  ...$({ plainName: "Connections", technicalName: "degree", type: "integer", unit: "links" }),
1017
- oe({
1017
+ re({
1018
1018
  name: "inDegree",
1019
1019
  plainName: "Incoming connections",
1020
1020
  technicalName: "inDegree",
1021
1021
  kind: "node",
1022
1022
  type: "integer"
1023
1023
  }),
1024
- oe({
1024
+ re({
1025
1025
  name: "outDegree",
1026
1026
  plainName: "Outgoing connections",
1027
1027
  technicalName: "outDegree",
1028
1028
  kind: "node",
1029
1029
  type: "integer"
1030
1030
  })
1031
- ], Fe = class Fe extends G {
1031
+ ], He = class He extends G {
1032
1032
  /**
1033
1033
  * The fields a degree result publishes.
1034
1034
  * @returns The uniform node-metric fields, plus `inDegree` and `outDegree`.
1035
1035
  */
1036
1036
  resultFields() {
1037
- return Zt;
1037
+ return na;
1038
1038
  }
1039
1039
  /**
1040
1040
  * Count every node's edges.
@@ -1044,9 +1044,9 @@ const Zt = [
1044
1044
  */
1045
1045
  async measure(e, t) {
1046
1046
  const n = this.algorithmGraph("directed"), a = [];
1047
- return await F(t, e, "counting connections", (i) => {
1048
- const o = n.inDegree(i), r = n.outDegree(i);
1049
- a.push({ id: i, values: { value: o + r, inDegree: o, outDegree: r } });
1047
+ return await D(t, e, "counting connections", (i) => {
1048
+ const s = n.inDegree(i), r = n.outDegree(i);
1049
+ a.push({ id: i, values: { value: s + r, inDegree: s, outDegree: r } });
1050
1050
  }), {
1051
1051
  nodes: a,
1052
1052
  // A count of edges, published as it was counted.
@@ -1062,10 +1062,10 @@ const Zt = [
1062
1062
  };
1063
1063
  }
1064
1064
  };
1065
- Fe.namespace = "graphty", Fe.type = "degree";
1066
- let me = Fe;
1067
- S.register(me);
1068
- const Xt = {
1065
+ He.namespace = "graphty", He.type = "degree";
1066
+ let ge = He;
1067
+ v.register(ge);
1068
+ const ia = {
1069
1069
  source: {
1070
1070
  schema: c.union([c.string(), c.number()]).nullable().default(null),
1071
1071
  meta: {
@@ -1125,25 +1125,25 @@ const Xt = {
1125
1125
  const t = this.graph.getDataManager(), n = Array.from(t.nodes.keys());
1126
1126
  if (n.length === 0)
1127
1127
  return null;
1128
- const a = this.legacyOptions?.source ?? this._schemaOptions.source ?? n[0], { targetNode: i, recursive: o, preOrder: r } = this._schemaOptions;
1128
+ const a = this.legacyOptions?.source ?? this._schemaOptions.source ?? n[0], { targetNode: i, recursive: s, preOrder: r } = this._schemaOptions;
1129
1129
  if (!t.nodes.has(a))
1130
1130
  return null;
1131
- const d = this.algorithmGraph("undirected");
1131
+ const l = this.algorithmGraph("undirected");
1132
1132
  e.report({ phase: "Walking deep", total: null });
1133
- const h = yt(d, a, {
1133
+ const h = kt(l, a, {
1134
1134
  targetNode: i ?? void 0,
1135
- recursive: o,
1135
+ recursive: s,
1136
1136
  preOrder: r
1137
1137
  }), m = /* @__PURE__ */ new Map();
1138
- h.order.forEach((u, p) => m.set(u, p));
1139
- const l = [];
1140
- return await N(e, "Recording the order", n, (u) => {
1141
- const p = m.get(u);
1142
- l.push({ id: u, values: { value: p, visited: h.visited.has(u) } });
1138
+ h.order.forEach((p, u) => m.set(p, u));
1139
+ const d = [];
1140
+ return await S(e, "Recording the order", n, (p) => {
1141
+ const u = m.get(p);
1142
+ d.push({ id: p, values: { value: u, visited: h.visited.has(p) } });
1143
1143
  }), {
1144
1144
  shape: "node-metric",
1145
- fields: [...je("node", "integer"), { name: "visited", kind: "node", type: "boolean" }],
1146
- nodes: l,
1145
+ fields: [...Be("node", "integer"), { name: "visited", kind: "node", type: "boolean" }],
1146
+ nodes: d,
1147
1147
  caveats: M({
1148
1148
  method: "dfs",
1149
1149
  direction: "undirected",
@@ -1153,7 +1153,7 @@ const Xt = {
1153
1153
  };
1154
1154
  }
1155
1155
  };
1156
- L.namespace = "graphty", L.type = "dfs", L.zodOptionsSchema = Xt, L.optionsSchema = {
1156
+ L.namespace = "graphty", L.type = "dfs", L.zodOptionsSchema = ia, L.optionsSchema = {
1157
1157
  source: {
1158
1158
  type: "nodeId",
1159
1159
  default: null,
@@ -1184,9 +1184,9 @@ L.namespace = "graphty", L.type = "dfs", L.zodOptionsSchema = Xt, L.optionsSchem
1184
1184
  advanced: !0
1185
1185
  }
1186
1186
  };
1187
- let ge = L;
1188
- S.register(ge);
1189
- const Jt = {
1187
+ let fe = L;
1188
+ v.register(fe);
1189
+ const sa = {
1190
1190
  source: {
1191
1191
  schema: c.union([c.string(), c.number()]).nullable().default(null),
1192
1192
  meta: {
@@ -1238,50 +1238,50 @@ const Jt = {
1238
1238
  const t = this.graph.getDataManager(), n = Array.from(t.nodes.keys());
1239
1239
  if (n.length === 0)
1240
1240
  return null;
1241
- const { snapshot: a, edgeRemap: i, run: o } = this.accelerated("sssp", "undirected");
1241
+ const { snapshot: a, edgeRemap: i, run: s } = this.accelerated("sssp", "undirected");
1242
1242
  if (a.nodeCount === 0)
1243
1243
  return null;
1244
- const { ids: r } = a, d = this.legacyOptions?.source ?? this._schemaOptions.source ?? r.idOf(0), h = this.legacyOptions?.target ?? this._schemaOptions.target ?? r.idOf(a.nodeCount - 1), m = this.nodeIndex(a, "source", d), l = this.nodeIndex(a, "target", h);
1244
+ const { ids: r } = a, l = this.legacyOptions?.source ?? this._schemaOptions.source ?? r.idOf(0), h = this.legacyOptions?.target ?? this._schemaOptions.target ?? r.idOf(a.nodeCount - 1), m = this.nodeIndex(a, "source", l), d = this.nodeIndex(a, "target", h);
1245
1245
  e.report({ phase: "Searching for the route", total: null });
1246
- const { value: u, precision: p } = await o((w, v) => w.sssp(v, m)), f = u.pathTo(l), O = new Set(u.pathEdges(l)), y = /* @__PURE__ */ new Map();
1247
- f.forEach((w, v) => y.set(w, v));
1248
- const k = [];
1249
- await N(e, "Marking the route", n, (w) => {
1250
- const v = r.indexOf(w), b = v === R ? void 0 : y.get(v);
1251
- k.push({
1246
+ const { value: p, precision: u } = await s((w, N) => w.sssp(N, m)), g = p.pathTo(d), x = new Set(p.pathEdges(d)), y = /* @__PURE__ */ new Map();
1247
+ g.forEach((w, N) => y.set(w, N));
1248
+ const O = [];
1249
+ await S(e, "Marking the route", n, (w) => {
1250
+ const N = r.indexOf(w), b = N === F ? void 0 : y.get(N);
1251
+ O.push({
1252
1252
  id: w,
1253
1253
  values: {
1254
1254
  onPath: b !== void 0,
1255
1255
  order: b,
1256
- distance: v === R ? 1 / 0 : u.dist[v]
1256
+ distance: N === F ? 1 / 0 : p.dist[N]
1257
1257
  }
1258
1258
  });
1259
1259
  });
1260
1260
  const I = [];
1261
- return await N(e, "Marking the route", Array.from(t.edges.values()), (w) => {
1262
- const v = i === null ? w.index : i[w.index] ?? R;
1263
- I.push({ id: w.id, values: { onPath: O.has(v) } });
1261
+ return await S(e, "Marking the route", Array.from(t.edges.values()), (w) => {
1262
+ const N = i === null ? w.index : i[w.index] ?? F;
1263
+ I.push({ id: w.id, values: { onPath: x.has(N) } });
1264
1264
  }), {
1265
1265
  shape: "path",
1266
- fields: [...Qe, { name: "distance", kind: "node", type: "number" }],
1267
- nodes: k,
1266
+ fields: [...tt, { name: "distance", kind: "node", type: "number" }],
1267
+ nodes: O,
1268
1268
  edges: I,
1269
1269
  graph: {
1270
- length: f.length,
1271
- cost: f.length === 0 ? 0 : u.dist[l],
1272
- hops: Math.max(f.length - 1, 0)
1270
+ length: g.length,
1271
+ cost: g.length === 0 ? 0 : p.dist[d],
1272
+ hops: Math.max(g.length - 1, 0)
1273
1273
  },
1274
1274
  caveats: M({
1275
1275
  method: "dijkstra",
1276
1276
  direction: "undirected",
1277
1277
  weight: { attribute: "weight", meaning: "distance" },
1278
- precision: p,
1279
- notes: f.length === 0 ? [`No route runs from ${String(d)} to ${String(h)}.`] : [`Route from ${String(d)} to ${String(h)}.`]
1278
+ precision: u,
1279
+ notes: g.length === 0 ? [`No route runs from ${String(l)} to ${String(h)}.`] : [`Route from ${String(l)} to ${String(h)}.`]
1280
1280
  })
1281
1281
  };
1282
1282
  }
1283
1283
  };
1284
- U.namespace = "graphty", U.type = "dijkstra", U.zodOptionsSchema = Jt, U.optionsSchema = {
1284
+ U.namespace = "graphty", U.type = "dijkstra", U.zodOptionsSchema = sa, U.optionsSchema = {
1285
1285
  source: {
1286
1286
  type: "nodeId",
1287
1287
  default: null,
@@ -1304,9 +1304,9 @@ U.namespace = "graphty", U.type = "dijkstra", U.zodOptionsSchema = Jt, U.options
1304
1304
  advanced: !0
1305
1305
  }
1306
1306
  };
1307
- let fe = U;
1308
- S.register(fe);
1309
- const Qt = {
1307
+ let ye = U;
1308
+ v.register(ye);
1309
+ const oa = {
1310
1310
  maxIterations: {
1311
1311
  schema: c.number().int().min(1).max(1e4).default(1e3),
1312
1312
  meta: {
@@ -1347,16 +1347,16 @@ const Qt = {
1347
1347
  advanced: !0
1348
1348
  }
1349
1349
  }
1350
- }, _t = $({
1350
+ }, ra = $({
1351
1351
  plainName: "Influence by association",
1352
1352
  technicalName: "eigenvector score"
1353
- }), P = class P extends G {
1353
+ }), R = class R extends G {
1354
1354
  /**
1355
1355
  * The fields an eigenvector result publishes.
1356
1356
  * @returns The uniform node-metric fields.
1357
1357
  */
1358
1358
  resultFields() {
1359
- return _t;
1359
+ return ra;
1360
1360
  }
1361
1361
  /**
1362
1362
  * Score every node by the influence of its neighbours.
@@ -1365,49 +1365,49 @@ const Qt = {
1365
1365
  * @returns One score per node, scaled as the options asked for.
1366
1366
  */
1367
1367
  async measure(e, t) {
1368
- const { maxIterations: n, tolerance: a, normalized: i, mode: o, endpoints: r } = this.schemaOptions, d = this._schemaOptions.startVector ?? void 0, h = this.algorithmGraph("undirected");
1368
+ const { maxIterations: n, tolerance: a, normalized: i, mode: s, endpoints: r } = this.schemaOptions, l = this._schemaOptions.startVector ?? void 0, h = s !== "total" && this.graph.getDataManager().getSnapshot().directed, m = this.algorithmGraph(h ? "directed" : "undirected");
1369
1369
  e.report({
1370
1370
  phase: "iterating",
1371
1371
  completed: 0,
1372
1372
  total: t.length,
1373
1373
  message: `Power iteration, up to ${String(n)} passes.`
1374
1374
  });
1375
- let m;
1375
+ let d;
1376
1376
  try {
1377
- m = bt(h, {
1377
+ d = St(m, {
1378
1378
  normalized: i,
1379
1379
  maxIterations: n,
1380
1380
  tolerance: a,
1381
- mode: o,
1381
+ mode: s,
1382
1382
  endpoints: r,
1383
- startVector: d
1383
+ startVector: l
1384
1384
  });
1385
1385
  } catch (u) {
1386
- if (!(u instanceof wt))
1386
+ if (!(u instanceof Ot))
1387
1387
  throw u;
1388
- const p = `${P.namespace}:${P.type}`;
1389
- throw new et({
1388
+ const g = `${R.namespace}:${R.type}`;
1389
+ throw new nt({
1390
1390
  code: "E_NOT_CONVERGED",
1391
1391
  message: `Eigenvector centrality did not converge in ${String(n)} iterations (tolerance ${String(a)}). Raise the maxIterations param (up to 10000), or loosen tolerance, and run it again.`,
1392
1392
  source: "run",
1393
1393
  target: { kind: "run", id: e.runId },
1394
- details: { algorithm: p, maxIterations: n, tolerance: a },
1394
+ details: { algorithm: g, maxIterations: n, tolerance: a },
1395
1395
  cause: u
1396
1396
  });
1397
1397
  }
1398
1398
  e.signal.throwIfAborted();
1399
- const l = [];
1400
- return await F(t, e, "reading scores", (u) => {
1401
- const p = m[String(u)];
1402
- l.push({ id: u, values: p === void 0 ? {} : { value: p } });
1399
+ const p = [];
1400
+ return await D(t, e, "reading scores", (u) => {
1401
+ const g = d[String(u)];
1402
+ p.push({ id: u, values: g === void 0 ? {} : { value: g } });
1403
1403
  }), {
1404
- nodes: l,
1404
+ nodes: p,
1405
1405
  // With `normalized`, the algorithm rescales its eigenvector so the lowest score is 0
1406
1406
  // and the highest is 1. Without it the raw unit-length eigenvector is published.
1407
1407
  normalization: i ? "min-max" : "none",
1408
1408
  caveats: {
1409
1409
  exact: !0,
1410
- direction: "undirected",
1410
+ direction: h ? "directed" : "undirected",
1411
1411
  weight: null,
1412
1412
  precision: "f64",
1413
1413
  method: "power-iteration",
@@ -1416,13 +1416,16 @@ const Qt = {
1416
1416
  converged: !0,
1417
1417
  notes: [
1418
1418
  `Power iteration reached a tolerance of ${String(a)} within ${String(n)} passes.`,
1419
+ ...h ? [
1420
+ s === "in" ? "A node is scored by the nodes whose edges point at it." : "A node is scored by the nodes its edges point at."
1421
+ ] : [],
1419
1422
  "Edge weights are not read."
1420
1423
  ]
1421
1424
  }
1422
1425
  };
1423
1426
  }
1424
1427
  };
1425
- P.namespace = "graphty", P.type = "eigenvector", P.zodOptionsSchema = Qt, P.optionsSchema = {
1428
+ R.namespace = "graphty", R.type = "eigenvector", R.zodOptionsSchema = oa, R.optionsSchema = {
1426
1429
  maxIterations: {
1427
1430
  type: "integer",
1428
1431
  default: 1e3,
@@ -1469,9 +1472,9 @@ P.namespace = "graphty", P.type = "eigenvector", P.zodOptionsSchema = Qt, P.opti
1469
1472
  }
1470
1473
  // Note: startVector is a Map type - programmatic only, not in schema
1471
1474
  };
1472
- let ye = P;
1473
- S.register(ye);
1474
- const $e = class $e extends z {
1475
+ let be = R;
1476
+ v.register(be);
1477
+ const We = class We extends z {
1475
1478
  /**
1476
1479
  * Measure the distance between every pair of nodes, and give each node the distance to the
1477
1480
  * node furthest from it.
@@ -1495,36 +1498,36 @@ const $e = class $e extends z {
1495
1498
  return null;
1496
1499
  const n = this.algorithmGraph("undirected");
1497
1500
  e.report({ phase: "Measuring every pair", total: null });
1498
- const a = vt(n), i = /* @__PURE__ */ new Map();
1499
- await N(e, "Measuring reach", t, (h) => {
1501
+ const a = xt(n), i = /* @__PURE__ */ new Map();
1502
+ await S(e, "Measuring reach", t, (h) => {
1500
1503
  const m = a.distances.get(h);
1501
1504
  if (m === void 0) {
1502
1505
  i.set(h, 1 / 0);
1503
1506
  return;
1504
1507
  }
1505
- let l = 0;
1506
- for (const u of m.values())
1507
- isFinite(u) && u > l && (l = u);
1508
- i.set(h, l);
1508
+ let d = 0;
1509
+ for (const p of m.values())
1510
+ isFinite(p) && p > d && (d = p);
1511
+ i.set(h, d);
1509
1512
  });
1510
- let o = 0, r = 1 / 0;
1513
+ let s = 0, r = 1 / 0;
1511
1514
  for (const h of i.values())
1512
- isFinite(h) && (o = Math.max(o, h), r = Math.min(r, h));
1515
+ isFinite(h) && (s = Math.max(s, h), r = Math.min(r, h));
1513
1516
  r === 1 / 0 && (r = 0);
1514
- const d = [];
1515
- return await N(e, "Publishing distances", t, (h) => {
1517
+ const l = [];
1518
+ return await S(e, "Publishing distances", t, (h) => {
1516
1519
  const m = i.get(h) ?? 1 / 0;
1517
- isFinite(m) && d.push({ id: h, values: { value: m } });
1520
+ isFinite(m) && l.push({ id: h, values: { value: m } });
1518
1521
  }), {
1519
1522
  shape: "node-metric",
1520
1523
  fields: [
1521
- ...je("node"),
1524
+ ...Be("node"),
1522
1525
  { name: "diameter", kind: "graph", type: "number" },
1523
1526
  { name: "radius", kind: "graph", type: "number" },
1524
1527
  { name: "hasNegativeCycle", kind: "graph", type: "boolean" }
1525
1528
  ],
1526
- nodes: d,
1527
- graph: { diameter: o, radius: r, hasNegativeCycle: a.hasNegativeCycle },
1529
+ nodes: l,
1530
+ graph: { diameter: s, radius: r, hasNegativeCycle: a.hasNegativeCycle },
1528
1531
  caveats: M({
1529
1532
  method: "floyd-warshall",
1530
1533
  direction: "undirected",
@@ -1536,10 +1539,10 @@ const $e = class $e extends z {
1536
1539
  };
1537
1540
  }
1538
1541
  };
1539
- $e.namespace = "graphty", $e.type = "floyd-warshall";
1540
- let be = $e;
1541
- S.register(be);
1542
- const ea = {
1542
+ We.namespace = "graphty", We.type = "floyd-warshall";
1543
+ let we = We;
1544
+ v.register(we);
1545
+ const ca = {
1543
1546
  maxCommunities: {
1544
1547
  schema: c.number().int().min(0).max(100).default(0),
1545
1548
  meta: {
@@ -1577,29 +1580,29 @@ const ea = {
1577
1580
  const t = Array.from(this.graph.getDataManager().nodes.keys());
1578
1581
  if (t.length === 0)
1579
1582
  return null;
1580
- const { maxCommunities: n, minCommunitySize: a, maxIterations: i } = this.schemaOptions, o = this.algorithmGraph("undirected");
1583
+ const { maxCommunities: n, minCommunitySize: a, maxIterations: i } = this.schemaOptions, s = this.algorithmGraph("undirected");
1581
1584
  e.report({ phase: "Cutting bridges", total: null });
1582
- const r = Nt(o, {
1585
+ const r = It(s, {
1583
1586
  maxCommunities: n > 0 ? n : void 0,
1584
1587
  minCommunitySize: a,
1585
1588
  maxIterations: i
1586
- }), d = n > 0 ? r.filter((p) => p.communities.length <= n) : r, m = (d.length > 0 ? d : r.slice(0, 1)).reduce(
1587
- (p, f) => p === void 0 || f.modularity > p.modularity ? f : p,
1589
+ }), l = n > 0 ? r.filter((u) => u.communities.length <= n) : r, m = (l.length > 0 ? l : r.slice(0, 1)).reduce(
1590
+ (u, g) => u === void 0 || g.modularity > u.modularity ? g : u,
1588
1591
  void 0
1589
- ), l = /* @__PURE__ */ new Map();
1592
+ ), d = /* @__PURE__ */ new Map();
1590
1593
  if (m !== void 0)
1591
- for (let p = 0; p < m.communities.length; p++)
1592
- for (const f of m.communities[p])
1593
- l.set(f, p);
1594
+ for (let u = 0; u < m.communities.length; u++)
1595
+ for (const g of m.communities[u])
1596
+ d.set(g, u);
1594
1597
  else
1595
- t.forEach((p, f) => l.set(p, f));
1596
- const u = [];
1597
- return await N(e, "Grouping nodes", t, (p) => {
1598
- u.push({ id: p, values: { group: l.get(p) ?? 0 } });
1598
+ t.forEach((u, g) => d.set(u, g));
1599
+ const p = [];
1600
+ return await S(e, "Grouping nodes", t, (u) => {
1601
+ p.push({ id: u, values: { group: d.get(u) ?? 0 } });
1599
1602
  }), {
1600
1603
  shape: "community",
1601
- fields: _(!0),
1602
- nodes: u,
1604
+ fields: ee(!0),
1605
+ nodes: p,
1603
1606
  graph: { modularity: m?.modularity ?? 0 },
1604
1607
  caveats: M({
1605
1608
  method: "girvan-newman",
@@ -1610,7 +1613,7 @@ const ea = {
1610
1613
  };
1611
1614
  }
1612
1615
  };
1613
- j.namespace = "graphty", j.type = "girvan-newman", j.zodOptionsSchema = ea, j.optionsSchema = {
1616
+ j.namespace = "graphty", j.type = "girvan-newman", j.zodOptionsSchema = ca, j.optionsSchema = {
1614
1617
  maxCommunities: {
1615
1618
  type: "integer",
1616
1619
  default: 0,
@@ -1638,9 +1641,9 @@ j.namespace = "graphty", j.type = "girvan-newman", j.zodOptionsSchema = ea, j.op
1638
1641
  advanced: !0
1639
1642
  }
1640
1643
  };
1641
- let we = j;
1642
- S.register(we);
1643
- const ta = {
1644
+ let ve = j;
1645
+ v.register(ve);
1646
+ const la = {
1644
1647
  maxIterations: {
1645
1648
  schema: c.number().int().min(1).max(1e3).default(100),
1646
1649
  meta: {
@@ -1681,10 +1684,10 @@ const ta = {
1681
1684
  advanced: !0
1682
1685
  }
1683
1686
  }
1684
- }, aa = [
1687
+ }, da = [
1685
1688
  ...$({ plainName: "Hub and authority", technicalName: "combined HITS score" }),
1686
- oe({ name: "hub", plainName: "Hub", technicalName: "hub score", kind: "node", type: "number" }),
1687
- oe({
1689
+ re({ name: "hub", plainName: "Hub", technicalName: "hub score", kind: "node", type: "number" }),
1690
+ re({
1688
1691
  name: "authority",
1689
1692
  plainName: "Authority",
1690
1693
  technicalName: "authority score",
@@ -1697,7 +1700,7 @@ const ta = {
1697
1700
  * @returns The uniform node-metric fields, plus `hub` and `authority`.
1698
1701
  */
1699
1702
  resultFields() {
1700
- return aa;
1703
+ return da;
1701
1704
  }
1702
1705
  /**
1703
1706
  * Score every node as a hub and as an authority.
@@ -1706,29 +1709,29 @@ const ta = {
1706
1709
  * @returns The combined score per node, with the two halves beside it.
1707
1710
  */
1708
1711
  async measure(e, t) {
1709
- const { maxIterations: n, tolerance: a, normalized: i, mode: o, endpoints: r } = this.schemaOptions, d = this.algorithmGraph("directed");
1712
+ const { maxIterations: n, tolerance: a, normalized: i, mode: s, endpoints: r } = this.schemaOptions, l = this.algorithmGraph("directed");
1710
1713
  e.report({
1711
1714
  phase: "iterating",
1712
1715
  completed: 0,
1713
1716
  total: t.length,
1714
1717
  message: `Hub and authority scores refine each other, up to ${String(n)} passes.`
1715
1718
  });
1716
- const h = kt(d, {
1719
+ const h = Mt(l, {
1717
1720
  maxIterations: n,
1718
1721
  tolerance: a,
1719
1722
  normalized: i,
1720
- mode: o,
1723
+ mode: s,
1721
1724
  endpoints: r
1722
1725
  });
1723
1726
  e.signal.throwIfAborted();
1724
1727
  const m = [];
1725
- return await F(t, e, "reading scores", (l) => {
1726
- const u = h.hubs[String(l)], p = h.authorities[String(l)];
1727
- if (u === void 0 || p === void 0) {
1728
- m.push({ id: l, values: {} });
1728
+ return await D(t, e, "reading scores", (d) => {
1729
+ const p = h.hubs[String(d)], u = h.authorities[String(d)];
1730
+ if (p === void 0 || u === void 0) {
1731
+ m.push({ id: d, values: {} });
1729
1732
  return;
1730
1733
  }
1731
- m.push({ id: l, values: { value: (u + p) / 2, hub: u, authority: p } });
1734
+ m.push({ id: d, values: { value: (p + u) / 2, hub: p, authority: u } });
1732
1735
  }), {
1733
1736
  nodes: m,
1734
1737
  // The combined score is the average of two vectors the algorithm scaled, which leaves
@@ -1753,7 +1756,7 @@ const ta = {
1753
1756
  };
1754
1757
  }
1755
1758
  };
1756
- V.namespace = "graphty", V.type = "hits", V.zodOptionsSchema = ta, V.optionsSchema = {
1759
+ V.namespace = "graphty", V.type = "hits", V.zodOptionsSchema = la, V.optionsSchema = {
1757
1760
  maxIterations: {
1758
1761
  type: "integer",
1759
1762
  default: 100,
@@ -1799,9 +1802,9 @@ V.namespace = "graphty", V.type = "hits", V.zodOptionsSchema = ta, V.optionsSche
1799
1802
  advanced: !0
1800
1803
  }
1801
1804
  };
1802
- let ve = V;
1803
- S.register(ve);
1804
- const na = {
1805
+ let Ne = V;
1806
+ v.register(Ne);
1807
+ const ha = {
1805
1808
  alpha: {
1806
1809
  schema: c.number().min(0.01).max(0.5).default(0.1),
1807
1810
  meta: {
@@ -1859,7 +1862,7 @@ const na = {
1859
1862
  advanced: !0
1860
1863
  }
1861
1864
  }
1862
- }, ia = $({
1865
+ }, ua = $({
1863
1866
  plainName: "Influence at a distance",
1864
1867
  technicalName: "Katz score"
1865
1868
  }), q = class q extends G {
@@ -1868,7 +1871,7 @@ const na = {
1868
1871
  * @returns The uniform node-metric fields.
1869
1872
  */
1870
1873
  resultFields() {
1871
- return ia;
1874
+ return ua;
1872
1875
  }
1873
1876
  /**
1874
1877
  * Score every node by the paths that reach it.
@@ -1877,29 +1880,29 @@ const na = {
1877
1880
  * @returns One score per node, scaled as the options asked for.
1878
1881
  */
1879
1882
  async measure(e, t) {
1880
- const { alpha: n, beta: a, maxIterations: i, tolerance: o, normalized: r, mode: d, endpoints: h } = this.schemaOptions, m = this.algorithmGraph("undirected");
1883
+ const { alpha: n, beta: a, maxIterations: i, tolerance: s, normalized: r, mode: l, endpoints: h } = this.schemaOptions, m = this.algorithmGraph("undirected");
1881
1884
  e.report({
1882
1885
  phase: "iterating",
1883
1886
  completed: 0,
1884
1887
  total: t.length,
1885
1888
  message: `Attenuated path sums, up to ${String(i)} passes.`
1886
1889
  });
1887
- const l = St(m, {
1890
+ const d = Ct(m, {
1888
1891
  normalized: r,
1889
1892
  alpha: n,
1890
1893
  beta: a,
1891
1894
  maxIterations: i,
1892
- tolerance: o,
1893
- mode: d,
1895
+ tolerance: s,
1896
+ mode: l,
1894
1897
  endpoints: h
1895
1898
  });
1896
1899
  e.signal.throwIfAborted();
1897
- const u = [];
1898
- return await F(t, e, "reading scores", (p) => {
1899
- const f = l[String(p)];
1900
- u.push({ id: p, values: f === void 0 ? {} : { value: f } });
1900
+ const p = [];
1901
+ return await D(t, e, "reading scores", (u) => {
1902
+ const g = d[String(u)];
1903
+ p.push({ id: u, values: g === void 0 ? {} : { value: g } });
1901
1904
  }), {
1902
- nodes: u,
1905
+ nodes: p,
1903
1906
  // With `normalized`, the algorithm rescales so the lowest score is 0 and the highest
1904
1907
  // is 1. Without it the raw attenuated sums are published.
1905
1908
  normalization: r ? "min-max" : "none",
@@ -1913,7 +1916,7 @@ const na = {
1913
1916
  // either at its tolerance or at its iteration cap and reports neither.
1914
1917
  notes: [
1915
1918
  `Every node starts with a base influence of ${String(a)}, and a path of length k contributes ${String(n)} to the power k.`,
1916
- `Iteration stops at a tolerance of ${String(o)} or after ${String(i)} passes, whichever comes first.`,
1919
+ `Iteration stops at a tolerance of ${String(s)} or after ${String(i)} passes, whichever comes first.`,
1917
1920
  "Whether it reached the tolerance is not reported by the implementation, so this run cannot say whether it converged.",
1918
1921
  "Edge weights are not read."
1919
1922
  ]
@@ -1921,7 +1924,7 @@ const na = {
1921
1924
  };
1922
1925
  }
1923
1926
  };
1924
- q.namespace = "graphty", q.type = "katz", q.zodOptionsSchema = na, q.optionsSchema = {
1927
+ q.namespace = "graphty", q.type = "katz", q.zodOptionsSchema = ha, q.optionsSchema = {
1925
1928
  alpha: {
1926
1929
  type: "number",
1927
1930
  default: 0.1,
@@ -1986,9 +1989,54 @@ q.namespace = "graphty", q.type = "katz", q.zodOptionsSchema = na, q.optionsSche
1986
1989
  advanced: !0
1987
1990
  }
1988
1991
  };
1989
- let Ne = q;
1990
- S.register(Ne);
1991
- const Ge = class Ge extends z {
1992
+ let ke = q;
1993
+ v.register(ke);
1994
+ const pa = $({
1995
+ plainName: "Core depth",
1996
+ technicalName: "core number",
1997
+ type: "integer"
1998
+ }), Ke = class Ke extends G {
1999
+ /**
2000
+ * The fields a k-core result publishes.
2001
+ * @returns The uniform node-metric fields.
2002
+ */
2003
+ resultFields() {
2004
+ return pa;
2005
+ }
2006
+ /**
2007
+ * Give every node its core number.
2008
+ * @param context - Where progress goes and where cancellation arrives.
2009
+ * @param nodeIds - The nodes to measure.
2010
+ * @returns One core number per node.
2011
+ */
2012
+ async measure(e, t) {
2013
+ const n = this.algorithmGraph("undirected");
2014
+ e.report({ phase: "peeling cores", total: null });
2015
+ const { coreness: a } = zt(n);
2016
+ e.signal.throwIfAborted();
2017
+ const i = [];
2018
+ return await D(t, e, "reading core numbers", (s) => {
2019
+ const r = a.get(String(s));
2020
+ i.push({ id: s, values: r === void 0 ? {} : { value: r } });
2021
+ }), {
2022
+ nodes: i,
2023
+ // A count of neighbours, published as it was counted.
2024
+ normalization: "none",
2025
+ caveats: {
2026
+ exact: !0,
2027
+ direction: "undirected",
2028
+ weight: null,
2029
+ precision: "f64",
2030
+ method: "k-core",
2031
+ notes: ["Counted over the graph read as undirected; edge weights are not read."]
2032
+ }
2033
+ };
2034
+ }
2035
+ };
2036
+ Ke.namespace = "graphty", Ke.type = "k-core";
2037
+ let Se = Ke;
2038
+ v.register(Se);
2039
+ const Le = class Le extends z {
1992
2040
  /**
1993
2041
  * Find the cheapest set of edges that still joins every node.
1994
2042
  *
@@ -2004,29 +2052,29 @@ const Ge = class Ge extends z {
2004
2052
  return null;
2005
2053
  const { edgeRemap: n, run: a } = this.accelerated("minimumSpanningTree", "undirected");
2006
2054
  e.report({ phase: "Choosing edges", total: null });
2007
- const { value: i, precision: o } = await a((h, m) => h.minimumSpanningTree(m)), r = new Set(i.edges), d = [];
2008
- return await N(e, "Marking the network", t, (h) => {
2009
- const m = n === null ? h.index : n[h.index] ?? R;
2010
- d.push({ id: h.id, values: { in: r.has(m) } });
2055
+ const { value: i, precision: s } = await a((h, m) => h.minimumSpanningTree(m)), r = new Set(i.edges), l = [];
2056
+ return await S(e, "Marking the network", t, (h) => {
2057
+ const m = n === null ? h.index : n[h.index] ?? F;
2058
+ l.push({ id: h.id, values: { in: r.has(m) } });
2011
2059
  }), {
2012
2060
  shape: "edge-set",
2013
- fields: We("edge", { name: "totalWeight", type: "number" }),
2014
- edges: d,
2061
+ fields: je("edge", { name: "totalWeight", type: "number" }),
2062
+ edges: l,
2015
2063
  graph: { totalWeight: i.totalWeight },
2016
2064
  caveats: M({
2017
2065
  method: "kruskal",
2018
2066
  direction: "undirected",
2019
2067
  weight: { attribute: "weight", meaning: "distance" },
2020
- precision: o,
2068
+ precision: s,
2021
2069
  notes: [`The tree joins the graph with ${String(i.edges.length)} edges.`]
2022
2070
  })
2023
2071
  };
2024
2072
  }
2025
2073
  };
2026
- Ge.namespace = "graphty", Ge.type = "kruskal";
2027
- let ke = Ge;
2028
- S.register(ke);
2029
- const sa = {
2074
+ Le.namespace = "graphty", Le.type = "kruskal";
2075
+ let Oe = Le;
2076
+ v.register(Oe);
2077
+ const ma = {
2030
2078
  maxIterations: {
2031
2079
  schema: c.number().int().min(1).max(500).default(100),
2032
2080
  meta: {
@@ -2059,29 +2107,29 @@ const sa = {
2059
2107
  return null;
2060
2108
  const { maxIterations: n, randomSeed: a } = this.schemaOptions, i = this.algorithmGraph("undirected");
2061
2109
  e.report({ phase: "Spreading labels", total: null });
2062
- const o = Ot(i, {
2110
+ const s = Tt(i, {
2063
2111
  maxIterations: n,
2064
2112
  randomSeed: a
2065
2113
  }), r = [];
2066
- return await N(e, "Grouping nodes", t, (d) => {
2067
- r.push({ id: d, values: { group: o.communities.get(String(d)) ?? 0 } });
2114
+ return await S(e, "Grouping nodes", t, (l) => {
2115
+ r.push({ id: l, values: { group: s.communities.get(String(l)) ?? 0 } });
2068
2116
  }), {
2069
2117
  shape: "community",
2070
- fields: _(!1),
2118
+ fields: ee(!1),
2071
2119
  nodes: r,
2072
2120
  caveats: M({
2073
2121
  method: "label-propagation",
2074
2122
  direction: "undirected",
2075
2123
  weight: { attribute: "weight", meaning: "strength" },
2076
- converged: o.converged,
2077
- iterations: o.iterations,
2124
+ converged: s.converged,
2125
+ iterations: s.iterations,
2078
2126
  seed: a,
2079
2127
  notes: ["Label propagation does not score its own partition, so it reports no modularity."]
2080
2128
  })
2081
2129
  };
2082
2130
  }
2083
2131
  };
2084
- A.namespace = "graphty", A.type = "label-propagation", A.zodOptionsSchema = sa, A.optionsSchema = {
2132
+ A.namespace = "graphty", A.type = "label-propagation", A.zodOptionsSchema = ma, A.optionsSchema = {
2085
2133
  maxIterations: {
2086
2134
  type: "integer",
2087
2135
  default: 100,
@@ -2100,9 +2148,9 @@ A.namespace = "graphty", A.type = "label-propagation", A.zodOptionsSchema = sa,
2100
2148
  advanced: !0
2101
2149
  }
2102
2150
  };
2103
- let Se = A;
2104
- S.register(Se);
2105
- const oa = {
2151
+ let xe = A;
2152
+ v.register(xe);
2153
+ const ga = {
2106
2154
  resolution: {
2107
2155
  schema: c.number().min(0.1).max(5).default(1),
2108
2156
  meta: {
@@ -2149,32 +2197,32 @@ const oa = {
2149
2197
  const t = Array.from(this.graph.getDataManager().nodes.keys());
2150
2198
  if (t.length === 0)
2151
2199
  return null;
2152
- const { resolution: n, randomSeed: a, maxIterations: i, threshold: o } = this.schemaOptions, r = this.algorithmGraph("undirected");
2200
+ const { resolution: n, randomSeed: a, maxIterations: i, threshold: s } = this.schemaOptions, r = this.algorithmGraph("undirected");
2153
2201
  e.report({ phase: "Refining communities", total: null });
2154
- const d = xt(r, {
2202
+ const l = Et(r, {
2155
2203
  resolution: n,
2156
2204
  randomSeed: a,
2157
2205
  maxIterations: i,
2158
- threshold: o
2206
+ threshold: s
2159
2207
  }), h = [];
2160
- return await N(e, "Grouping nodes", t, (m) => {
2161
- h.push({ id: m, values: { group: d.communities.get(String(m)) ?? 0 } });
2208
+ return await S(e, "Grouping nodes", t, (m) => {
2209
+ h.push({ id: m, values: { group: l.communities.get(String(m)) ?? 0 } });
2162
2210
  }), {
2163
2211
  shape: "community",
2164
- fields: _(!0),
2212
+ fields: ee(!0),
2165
2213
  nodes: h,
2166
- graph: { modularity: d.modularity },
2214
+ graph: { modularity: l.modularity },
2167
2215
  caveats: M({
2168
2216
  method: "leiden",
2169
2217
  direction: "undirected",
2170
2218
  weight: { attribute: "weight", meaning: "strength" },
2171
- iterations: d.iterations,
2219
+ iterations: l.iterations,
2172
2220
  notes: [`Resolution ${String(n)}.`]
2173
2221
  })
2174
2222
  };
2175
2223
  }
2176
2224
  };
2177
- B.namespace = "graphty", B.type = "leiden", B.zodOptionsSchema = oa, B.optionsSchema = {
2225
+ B.namespace = "graphty", B.type = "leiden", B.zodOptionsSchema = ga, B.optionsSchema = {
2178
2226
  resolution: {
2179
2227
  type: "number",
2180
2228
  default: 1,
@@ -2212,9 +2260,79 @@ B.namespace = "graphty", B.type = "leiden", B.zodOptionsSchema = oa, B.optionsSc
2212
2260
  advanced: !0
2213
2261
  }
2214
2262
  };
2215
- let Oe = B;
2216
- S.register(Oe);
2217
- const ra = {
2263
+ let Ie = B;
2264
+ v.register(Ie);
2265
+ const fa = {
2266
+ "adamic-adar": Pt,
2267
+ "common-neighbors": Dt
2268
+ }, ya = {
2269
+ method: {
2270
+ schema: c.enum(["adamic-adar", "common-neighbors"]).default("adamic-adar"),
2271
+ meta: {
2272
+ label: "Method",
2273
+ description: "Common neighbours counts the neighbours two nodes share. Adamic-Adar counts them too, but a shared neighbour with few connections counts for more than one with many."
2274
+ }
2275
+ },
2276
+ topK: {
2277
+ schema: c.number().int().min(1).max(1e3).default(10),
2278
+ meta: {
2279
+ label: "Pairs",
2280
+ description: "How many of the best-scoring pairs to keep."
2281
+ }
2282
+ }
2283
+ }, Y = class Y extends z {
2284
+ /**
2285
+ * Score every unconnected pair of nodes and keep the best.
2286
+ * @param context - What the element gave the run.
2287
+ * @returns The scored pairs, best first, or null when the graph has no nodes.
2288
+ */
2289
+ compute(e) {
2290
+ if (this.graph.getDataManager().nodes.size === 0)
2291
+ return Promise.resolve(null);
2292
+ const { method: t, topK: n } = this.schemaOptions, a = this.algorithmGraph("undirected");
2293
+ e.report({ phase: "Scoring pairs", total: null });
2294
+ const i = /* @__PURE__ */ new Set(), s = fa[t](a).filter(({ source: r, target: l }) => {
2295
+ const h = [String(r), String(l)].sort().join("\0");
2296
+ return i.has(h) ? !1 : (i.add(h), !0);
2297
+ }).slice(0, n);
2298
+ return e.signal.throwIfAborted(), Promise.resolve({
2299
+ shape: "pair-list",
2300
+ fields: [{ name: "pairs", kind: "graph", type: "table" }],
2301
+ graph: { pairs: s },
2302
+ caveats: M({
2303
+ method: t,
2304
+ direction: "undirected",
2305
+ weight: null,
2306
+ notes: [
2307
+ "Only pairs that are not already joined, and that share at least one neighbour, are scored."
2308
+ ]
2309
+ })
2310
+ });
2311
+ }
2312
+ };
2313
+ Y.namespace = "graphty", Y.type = "link-prediction", Y.zodOptionsSchema = ya, Y.optionsSchema = {
2314
+ method: {
2315
+ type: "select",
2316
+ default: "adamic-adar",
2317
+ label: "Method",
2318
+ description: "Common neighbours counts the neighbours two nodes share. Adamic-Adar counts them too, but a shared neighbour with few connections counts for more than one with many.",
2319
+ options: [
2320
+ { value: "adamic-adar", label: "Adamic-Adar" },
2321
+ { value: "common-neighbors", label: "Common neighbours" }
2322
+ ]
2323
+ },
2324
+ topK: {
2325
+ type: "integer",
2326
+ default: 10,
2327
+ label: "Pairs",
2328
+ description: "How many of the best-scoring pairs to keep.",
2329
+ min: 1,
2330
+ max: 1e3
2331
+ }
2332
+ };
2333
+ let Me = Y;
2334
+ v.register(Me);
2335
+ const ba = {
2218
2336
  resolution: {
2219
2337
  schema: c.number().min(0.1).max(5).default(1),
2220
2338
  meta: {
@@ -2247,7 +2365,7 @@ const ra = {
2247
2365
  advanced: !0
2248
2366
  }
2249
2367
  }
2250
- }, Y = class Y extends z {
2368
+ }, Z = class Z extends z {
2251
2369
  /**
2252
2370
  * Group the nodes into communities by optimising modularity.
2253
2371
  *
@@ -2261,25 +2379,25 @@ const ra = {
2261
2379
  const t = Array.from(this.graph.getDataManager().nodes.keys());
2262
2380
  if (t.length === 0)
2263
2381
  return null;
2264
- const { resolution: n, maxIterations: a, tolerance: i, useOptimized: o } = this.schemaOptions, r = this.algorithmGraph("undirected");
2382
+ const { resolution: n, maxIterations: a, tolerance: i, useOptimized: s } = this.schemaOptions, r = this.algorithmGraph("undirected");
2265
2383
  e.report({ phase: "Optimizing modularity", total: null });
2266
- const d = It(r, {
2384
+ const l = Rt(r, {
2267
2385
  resolution: n,
2268
2386
  maxIterations: a,
2269
2387
  tolerance: i,
2270
- useOptimized: o
2388
+ useOptimized: s
2271
2389
  }), h = /* @__PURE__ */ new Map();
2272
- for (let l = 0; l < d.communities.length; l++)
2273
- for (const u of d.communities[l])
2274
- h.set(u, l);
2390
+ for (let d = 0; d < l.communities.length; d++)
2391
+ for (const p of l.communities[d])
2392
+ h.set(p, d);
2275
2393
  const m = [];
2276
- return await N(e, "Grouping nodes", t, (l) => {
2277
- m.push({ id: l, values: { group: h.get(l) ?? 0 } });
2394
+ return await S(e, "Grouping nodes", t, (d) => {
2395
+ m.push({ id: d, values: { group: h.get(d) ?? 0 } });
2278
2396
  }), {
2279
2397
  shape: "community",
2280
- fields: _(!0),
2398
+ fields: ee(!0),
2281
2399
  nodes: m,
2282
- graph: { modularity: d.modularity },
2400
+ graph: { modularity: l.modularity },
2283
2401
  caveats: M({
2284
2402
  method: "louvain",
2285
2403
  direction: "undirected",
@@ -2289,7 +2407,7 @@ const ra = {
2289
2407
  };
2290
2408
  }
2291
2409
  };
2292
- Y.namespace = "graphty", Y.type = "louvain", Y.zodOptionsSchema = ra, Y.optionsSchema = {
2410
+ Z.namespace = "graphty", Z.type = "louvain", Z.zodOptionsSchema = ba, Z.optionsSchema = {
2293
2411
  resolution: {
2294
2412
  type: "number",
2295
2413
  default: 1,
@@ -2325,9 +2443,9 @@ Y.namespace = "graphty", Y.type = "louvain", Y.zodOptionsSchema = ra, Y.optionsS
2325
2443
  advanced: !0
2326
2444
  }
2327
2445
  };
2328
- let xe = Y;
2329
- S.register(xe);
2330
- const ca = {
2446
+ let Ce = Z;
2447
+ v.register(Ce);
2448
+ const wa = {
2331
2449
  source: {
2332
2450
  schema: c.union([c.string(), c.number()]).nullable().default(null),
2333
2451
  meta: {
@@ -2342,7 +2460,7 @@ const ca = {
2342
2460
  description: "Sink node for flow network (uses last node if not set)"
2343
2461
  }
2344
2462
  }
2345
- }, Z = class Z extends z {
2463
+ }, X = class X extends z {
2346
2464
  constructor() {
2347
2465
  super(...arguments), this.legacyOptions = null;
2348
2466
  }
@@ -2371,57 +2489,57 @@ const ca = {
2371
2489
  const t = this.graph.getDataManager(), n = Array.from(t.edges.values()), a = Array.from(t.nodes.keys());
2372
2490
  if (n.length === 0 || a.length === 0)
2373
2491
  return null;
2374
- const i = this.legacyOptions?.source ?? this._schemaOptions.source, o = this.legacyOptions?.sink ?? this._schemaOptions.sink, r = i === null ? String(a[0]) : re("max-flow", "source", i, a), d = o === null ? String(a[a.length - 1]) : re("max-flow", "sink", o, a), h = new _e({ directed: !0 });
2492
+ const i = this.legacyOptions?.source ?? this._schemaOptions.source, s = this.legacyOptions?.sink ?? this._schemaOptions.sink, r = i === null ? String(a[0]) : ce("max-flow", "source", i, a), l = s === null ? String(a[a.length - 1]) : ce("max-flow", "sink", s, a), h = new at({ directed: !0 });
2375
2493
  for (const y of a)
2376
2494
  h.addNode(String(y));
2377
2495
  const m = /* @__PURE__ */ new Map();
2378
2496
  for (const y of n) {
2379
- const k = String(y.srcId), I = String(y.dstId), w = y.data, v = y, b = w?.capacity ?? w?.value ?? v.value ?? 1, C = typeof b == "number" ? b : 1;
2380
- h.addEdge(k, I, C), m.set(T(k, I), C);
2497
+ const O = String(y.srcId), I = String(y.dstId), w = y.data, N = y, b = w?.capacity ?? w?.value ?? N.value ?? 1, C = typeof b == "number" ? b : 1;
2498
+ h.addEdge(O, I, C), m.set(T(O, I), C);
2381
2499
  }
2382
2500
  e.report({ phase: "Pushing flow", total: null });
2383
- const l = Mt(h, r, d), u = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
2384
- for (const [y, k] of l.flowGraph)
2385
- for (const [I, w] of k)
2386
- p.set(y, (p.get(y) ?? 0) + w), u.set(I, (u.get(I) ?? 0) + w);
2387
- const f = [];
2388
- await N(e, "Measuring edges", n, (y) => {
2389
- const k = String(y.srcId), I = String(y.dstId), w = l.flowGraph.get(k)?.get(I) ?? 0, v = m.get(T(k, I)) ?? 1, b = v > 0 ? Math.abs(w) / v : 0;
2390
- f.push({ id: y.id, values: { value: w, capacity: v, utilization: b } });
2501
+ const d = Ft(h, r, l), p = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
2502
+ for (const [y, O] of d.flowGraph)
2503
+ for (const [I, w] of O)
2504
+ u.set(y, (u.get(y) ?? 0) + w), p.set(I, (p.get(I) ?? 0) + w);
2505
+ const g = [];
2506
+ await S(e, "Measuring edges", n, (y) => {
2507
+ const O = String(y.srcId), I = String(y.dstId), w = d.flowGraph.get(O)?.get(I) ?? 0, N = m.get(T(O, I)) ?? 1, b = N > 0 ? Math.abs(w) / N : 0;
2508
+ g.push({ id: y.id, values: { value: w, capacity: N, utilization: b } });
2391
2509
  });
2392
- const O = [];
2393
- return await N(e, "Measuring nodes", a, (y) => {
2394
- const k = String(y), I = u.get(k) ?? 0, w = p.get(k) ?? 0, v = { netFlow: I - w };
2395
- k === r ? v.role = "source" : k === d && (v.role = "sink"), O.push({ id: y, values: v });
2510
+ const x = [];
2511
+ return await S(e, "Measuring nodes", a, (y) => {
2512
+ const O = String(y), I = p.get(O) ?? 0, w = u.get(O) ?? 0, N = { netFlow: I - w };
2513
+ O === r ? N.role = "source" : O === l && (N.role = "sink"), x.push({ id: y, values: N });
2396
2514
  }), {
2397
2515
  shape: "edge-metric",
2398
2516
  fields: [
2399
- ...je("edge"),
2517
+ ...Be("edge"),
2400
2518
  { name: "capacity", kind: "edge", type: "number" },
2401
2519
  { name: "utilization", kind: "edge", type: "number" },
2402
2520
  { name: "netFlow", kind: "node", type: "number" },
2403
2521
  { name: "role", kind: "node", type: "string" },
2404
2522
  { name: "maxFlow", kind: "graph", type: "number" }
2405
2523
  ],
2406
- nodes: O,
2407
- edges: f,
2408
- graph: { maxFlow: l.maxFlow },
2524
+ nodes: x,
2525
+ edges: g,
2526
+ graph: { maxFlow: d.maxFlow },
2409
2527
  caveats: M({
2410
2528
  method: "ford-fulkerson",
2411
2529
  direction: "directed",
2412
2530
  weight: { attribute: "capacity", meaning: "strength" },
2413
2531
  notes: [
2414
- `Flow from ${r} to ${d}.`,
2415
- ...i === null || o === null ? [
2532
+ `Flow from ${r} to ${l}.`,
2533
+ ...i === null || s === null ? [
2416
2534
  "The source or sink was chosen automatically (the first and last node); set the source and sink options to measure between the nodes you mean."
2417
2535
  ] : [],
2418
- ...l.maxFlow === 0 ? [`There is no directed path from ${r} to ${d}, so no flow can run.`] : []
2536
+ ...d.maxFlow === 0 ? [`There is no directed path from ${r} to ${l}, so no flow can run.`] : []
2419
2537
  ]
2420
2538
  })
2421
2539
  };
2422
2540
  }
2423
2541
  };
2424
- Z.namespace = "graphty", Z.type = "max-flow", Z.zodOptionsSchema = ca, Z.optionsSchema = {
2542
+ X.namespace = "graphty", X.type = "max-flow", X.zodOptionsSchema = wa, X.optionsSchema = {
2425
2543
  source: {
2426
2544
  type: "nodeId",
2427
2545
  default: null,
@@ -2437,9 +2555,9 @@ Z.namespace = "graphty", Z.type = "max-flow", Z.zodOptionsSchema = ca, Z.options
2437
2555
  required: !1
2438
2556
  }
2439
2557
  };
2440
- let Ie = Z;
2441
- S.register(Ie);
2442
- const la = {
2558
+ let ze = X;
2559
+ v.register(ze);
2560
+ const va = {
2443
2561
  source: {
2444
2562
  schema: c.union([c.string(), c.number()]).nullable().default(null),
2445
2563
  meta: {
@@ -2477,7 +2595,7 @@ const la = {
2477
2595
  advanced: !0
2478
2596
  }
2479
2597
  }
2480
- }, X = class X extends z {
2598
+ }, J = class J extends z {
2481
2599
  constructor() {
2482
2600
  super(...arguments), this.legacyOptions = null;
2483
2601
  }
@@ -2512,58 +2630,58 @@ const la = {
2512
2630
  const t = this.graph.getDataManager(), n = Array.from(t.edges.values()), a = Array.from(t.nodes.keys());
2513
2631
  if (n.length === 0 || a.length === 0)
2514
2632
  return null;
2515
- const i = /* @__PURE__ */ new Map(), o = new _e({ directed: !1 });
2633
+ const i = /* @__PURE__ */ new Map(), s = new at({ directed: !1 });
2516
2634
  for (const b of a)
2517
- i.set(String(b), /* @__PURE__ */ new Map()), o.addNode(String(b));
2635
+ i.set(String(b), /* @__PURE__ */ new Map()), s.addNode(String(b));
2518
2636
  for (const b of n) {
2519
- const C = String(b.srcId), D = String(b.dstId), H = b.data, ae = b, Ve = H?.value ?? ae.value ?? 1, Ke = typeof Ve == "number" ? Ve : 1;
2520
- i.get(C)?.set(D, Ke), i.get(D)?.set(C, Ke), o.addEdge(C, D, Ke);
2637
+ const C = String(b.srcId), P = String(b.dstId), H = b.data, ne = b, Ye = H?.value ?? ne.value ?? 1, Ve = typeof Ye == "number" ? Ye : 1;
2638
+ i.get(C)?.set(P, Ve), i.get(P)?.set(C, Ve), s.addEdge(C, P, Ve);
2521
2639
  }
2522
- const r = this.legacyOptions?.useGlobalMinCut ?? this._schemaOptions.useGlobalMinCut, d = this.legacyOptions?.source ?? this._schemaOptions.source, h = this.legacyOptions?.sink ?? this._schemaOptions.sink, { useKarger: m, kargerIterations: l } = this._schemaOptions;
2523
- let u, p, f, O, y, k;
2524
- if (e.report({ phase: "Finding the cut", total: null }), r || d === null && h === null)
2525
- m ? (y = "karger", { partition1: u, partition2: p, cutEdges: f, cutValue: O } = Ct(i, l)) : (y = "stoer-wagner", { partition1: u, partition2: p, cutEdges: f, cutValue: O } = zt(i));
2640
+ const r = this.legacyOptions?.useGlobalMinCut ?? this._schemaOptions.useGlobalMinCut, l = this.legacyOptions?.source ?? this._schemaOptions.source, h = this.legacyOptions?.sink ?? this._schemaOptions.sink, { useKarger: m, kargerIterations: d } = this._schemaOptions;
2641
+ let p, u, g, x, y, O;
2642
+ if (e.report({ phase: "Finding the cut", total: null }), r || l === null && h === null)
2643
+ m ? (y = "karger", { partition1: p, partition2: u, cutEdges: g, cutValue: x } = $t(i, d)) : (y = "stoer-wagner", { partition1: p, partition2: u, cutEdges: g, cutValue: x } = Gt(i));
2526
2644
  else {
2527
2645
  y = "min-st-cut";
2528
- const b = d === null ? String(a[0]) : re("min-cut", "source", d, a), C = h === null ? String(a[a.length - 1]) : re("min-cut", "sink", h, a);
2529
- (d === null || h === null) && (k = `Only one end was set, so the other was chosen automatically (cut between ${b} and ${C}); set both source and sink to cut between the nodes you mean.`), { partition1: u, partition2: p, cutEdges: f, cutValue: O } = Tt(o, b, C);
2646
+ const b = l === null ? String(a[0]) : ce("min-cut", "source", l, a), C = h === null ? String(a[a.length - 1]) : ce("min-cut", "sink", h, a);
2647
+ (l === null || h === null) && (O = `Only one end was set, so the other was chosen automatically (cut between ${b} and ${C}); set both source and sink to cut between the nodes you mean.`), { partition1: p, partition2: u, cutEdges: g, cutValue: x } = Ht(s, b, C);
2530
2648
  }
2531
2649
  const I = /* @__PURE__ */ new Map();
2532
- for (const b of f)
2650
+ for (const b of g)
2533
2651
  I.set(T(b.from, b.to), b.weight), I.set(T(b.to, b.from), b.weight);
2534
2652
  const w = [];
2535
- await N(e, "Marking the cut", n, (b) => {
2653
+ await S(e, "Marking the cut", n, (b) => {
2536
2654
  const C = I.get(T(b.srcId, b.dstId));
2537
2655
  w.push({ id: b.id, values: { in: C !== void 0 } });
2538
2656
  });
2539
- const v = [];
2540
- return await N(e, "Marking the sides", a, (b) => {
2541
- const C = u.has(String(b));
2542
- v.push({ id: b, values: { side: C ? "1" : "2" } });
2657
+ const N = [];
2658
+ return await S(e, "Marking the sides", a, (b) => {
2659
+ const C = p.has(String(b));
2660
+ N.push({ id: b, values: { side: C ? "1" : "2" } });
2543
2661
  }), {
2544
2662
  shape: "edge-set",
2545
2663
  fields: [
2546
- ...We("edge", { name: "cutValue", type: "number" }),
2664
+ ...je("edge", { name: "cutValue", type: "number" }),
2547
2665
  { name: "side", kind: "node", type: "string" }
2548
2666
  ],
2549
- nodes: v,
2667
+ nodes: N,
2550
2668
  edges: w,
2551
- graph: { cutValue: O },
2669
+ graph: { cutValue: x },
2552
2670
  caveats: M({
2553
2671
  method: y,
2554
2672
  direction: "undirected",
2555
2673
  weight: { attribute: "weight", meaning: "strength" },
2556
2674
  exact: y !== "karger",
2557
- iterations: y === "karger" ? l : void 0,
2675
+ iterations: y === "karger" ? d : void 0,
2558
2676
  notes: [
2559
- y === "karger" ? "Karger's method is randomised: it finds the cheapest cut with high probability, not certainty." : `The cut separates ${String(u.size)} nodes from ${String(p.size)}.`,
2560
- ...k === void 0 ? [] : [k]
2677
+ y === "karger" ? "Karger's method is randomised: it finds the cheapest cut with high probability, not certainty." : `The cut separates ${String(p.size)} nodes from ${String(u.size)}.`,
2678
+ ...O === void 0 ? [] : [O]
2561
2679
  ]
2562
2680
  })
2563
2681
  };
2564
2682
  }
2565
2683
  };
2566
- X.namespace = "graphty", X.type = "min-cut", X.zodOptionsSchema = la, X.optionsSchema = {
2684
+ J.namespace = "graphty", J.type = "min-cut", J.zodOptionsSchema = va, J.optionsSchema = {
2567
2685
  source: {
2568
2686
  type: "nodeId",
2569
2687
  default: null,
@@ -2602,9 +2720,9 @@ X.namespace = "graphty", X.type = "min-cut", X.zodOptionsSchema = la, X.optionsS
2602
2720
  advanced: !0
2603
2721
  }
2604
2722
  };
2605
- let Me = X;
2606
- S.register(Me);
2607
- const Ze = {
2723
+ let Te = J;
2724
+ v.register(Te);
2725
+ const _e = {
2608
2726
  dampingFactor: {
2609
2727
  schema: c.number().min(0).max(1).default(0.85),
2610
2728
  meta: {
@@ -2645,21 +2763,21 @@ const Ze = {
2645
2763
  advanced: !0
2646
2764
  }
2647
2765
  }
2648
- }, da = $({
2766
+ }, Na = $({
2649
2767
  plainName: "Influence",
2650
2768
  technicalName: "PageRank score"
2651
- }), ha = 100;
2652
- function ua(s) {
2653
- return s.hasPersonalization ? "a personalization vector was given, and only the reference implementation takes one" : s.hasInitialRanks ? "initial ranks were given, and only the reference implementation takes them" : s.directed ? null : "the graph is undirected, and rank flows along out-edges";
2769
+ }), ka = 100;
2770
+ function Sa(o) {
2771
+ return o.hasPersonalization ? "a personalization vector was given, and only the reference implementation takes one" : o.hasInitialRanks ? "initial ranks were given, and only the reference implementation takes them" : o.directed ? null : "the graph is undirected, and rank flows along out-edges";
2654
2772
  }
2655
- const J = class J extends G {
2773
+ const Q = class Q extends G {
2656
2774
  /**
2657
2775
  * Creates a new PageRank algorithm instance
2658
2776
  * @param g - The graph to run the algorithm on
2659
2777
  * @param options - Optional configuration options
2660
2778
  */
2661
2779
  constructor(e, t) {
2662
- super(e, t), this.zodOptions = Ut(Ze, t ?? {}), this.programmaticOptions = {
2780
+ super(e, t), this.zodOptions = Xt(_e, t ?? {}), this.programmaticOptions = {
2663
2781
  initialRanks: t?.initialRanks ?? null,
2664
2782
  personalization: t?.personalization ?? null
2665
2783
  };
@@ -2669,7 +2787,7 @@ const J = class J extends G {
2669
2787
  * @returns The uniform node-metric fields.
2670
2788
  */
2671
2789
  resultFields() {
2672
- return da;
2790
+ return Na;
2673
2791
  }
2674
2792
  /**
2675
2793
  * Rank every node by the influence flowing into it.
@@ -2678,40 +2796,40 @@ const J = class J extends G {
2678
2796
  * @returns One raw rank per node, unscaled.
2679
2797
  */
2680
2798
  async measure(e, t) {
2681
- const { dampingFactor: n, maxIterations: a, tolerance: i, weight: o, useDelta: r } = this.zodOptions, d = this.programmaticOptions.initialRanks ?? void 0, h = this.programmaticOptions.personalization ?? void 0, m = ua({
2799
+ const { dampingFactor: n, maxIterations: a, tolerance: i, weight: s, useDelta: r } = this.zodOptions, l = this.programmaticOptions.initialRanks ?? void 0, h = this.programmaticOptions.personalization ?? void 0, m = Sa({
2682
2800
  directed: this.graph.getDataManager().getSnapshot().directed,
2683
- hasInitialRanks: d !== void 0,
2801
+ hasInitialRanks: l !== void 0,
2684
2802
  hasPersonalization: h !== void 0
2685
2803
  });
2686
2804
  if (m === null) {
2687
- const { snapshot: y, run: k } = this.accelerated("pageRank", "directed");
2805
+ const { snapshot: y, run: O } = this.accelerated("pageRank", "directed");
2688
2806
  e.report({
2689
2807
  phase: "iterating",
2690
2808
  completed: 0,
2691
2809
  total: t.length,
2692
2810
  message: `Power iteration, up to ${String(a)} passes.`
2693
2811
  });
2694
- const { value: I, precision: w } = await k(
2695
- (D, H) => D.pageRank(H, {
2812
+ const { value: I, precision: w } = await O(
2813
+ (P, H) => P.pageRank(H, {
2696
2814
  dampingFactor: n,
2697
2815
  maxIterations: a,
2698
2816
  tolerance: i,
2699
2817
  // ONE weight column, so naming an attribute is the same request as asking for
2700
2818
  // a weighted run: the snapshot carries the weight the element resolved.
2701
- weighted: o !== null
2819
+ weighted: s !== null
2702
2820
  })
2703
2821
  );
2704
2822
  e.signal.throwIfAborted();
2705
- const { ids: v } = y, b = [];
2706
- await F(t, e, "reading ranks", (D) => {
2707
- const H = v.indexOf(D), ae = H === R ? void 0 : I.scores[H];
2708
- b.push({ id: D, values: ae === void 0 ? {} : { value: ae } });
2823
+ const { ids: N } = y, b = [];
2824
+ await D(t, e, "reading ranks", (P) => {
2825
+ const H = N.indexOf(P), ne = H === F ? void 0 : I.scores[H];
2826
+ b.push({ id: P, values: ne === void 0 ? {} : { value: ne } });
2709
2827
  });
2710
2828
  const C = [
2711
2829
  `A reader follows a link with probability ${String(n)} and jumps to a random node otherwise.`,
2712
2830
  "The ranks sum to 1 across the graph."
2713
2831
  ];
2714
- return o === null && C.push("Edge weights are not read."), r && C.push(
2832
+ return s === null && C.push("Edge weights are not read."), r && C.push(
2715
2833
  "Power iteration ran: the delta optimisation is the CPU reference implementation's own and has no index-based counterpart, so it was not taken."
2716
2834
  ), {
2717
2835
  nodes: b,
@@ -2719,7 +2837,7 @@ const J = class J extends G {
2719
2837
  caveats: {
2720
2838
  exact: !0,
2721
2839
  direction: "directed",
2722
- weight: o === null ? null : { attribute: o, meaning: "strength" },
2840
+ weight: s === null ? null : { attribute: s, meaning: "strength" },
2723
2841
  precision: w,
2724
2842
  method: "power-iteration",
2725
2843
  converged: I.converged,
@@ -2728,54 +2846,51 @@ const J = class J extends G {
2728
2846
  }
2729
2847
  };
2730
2848
  }
2731
- const l = this.algorithmGraph("directed"), u = r && l.nodeCount > ha;
2849
+ const d = this.algorithmGraph("directed"), p = r && d.nodeCount > ka;
2732
2850
  e.report({
2733
2851
  phase: "iterating",
2734
2852
  completed: 0,
2735
2853
  total: t.length,
2736
2854
  message: `Power iteration, up to ${String(a)} passes.`
2737
2855
  });
2738
- const p = Et(l, {
2856
+ const u = Wt(d, {
2739
2857
  dampingFactor: n,
2740
2858
  maxIterations: a,
2741
2859
  tolerance: i,
2742
- weight: o ?? void 0,
2860
+ weight: s ?? void 0,
2743
2861
  useDelta: r,
2744
- initialRanks: d,
2862
+ initialRanks: l,
2745
2863
  personalization: h
2746
2864
  });
2747
2865
  e.signal.throwIfAborted();
2748
- const f = [];
2749
- await F(t, e, "reading ranks", (y) => {
2750
- const k = p.ranks[String(y)];
2751
- f.push({ id: y, values: k === void 0 ? {} : { value: k } });
2866
+ const g = [];
2867
+ await D(t, e, "reading ranks", (y) => {
2868
+ const O = u.ranks[String(y)];
2869
+ g.push({ id: y, values: O === void 0 ? {} : { value: O } });
2752
2870
  });
2753
- const O = [
2871
+ const x = [
2754
2872
  `A reader follows a link with probability ${String(n)} and jumps to a random node otherwise.`,
2755
2873
  "The ranks sum to 1 across the graph.",
2756
2874
  `Computed on the CPU reference implementation: ${m}.`
2757
2875
  ];
2758
- return u && O.push(
2759
- "The delta method ran, and it reports neither how many passes it took nor whether it converged, so this run cannot say."
2760
- ), o === null && O.push("Edge weights are not read."), {
2761
- nodes: f,
2876
+ return s === null && x.push("Edge weights are not read."), {
2877
+ nodes: g,
2762
2878
  // Raw ranks, published as they were computed.
2763
2879
  normalization: "none",
2764
2880
  caveats: {
2765
2881
  exact: !0,
2766
2882
  direction: "directed",
2767
- weight: o === null ? null : { attribute: o, meaning: "strength" },
2883
+ weight: s === null ? null : { attribute: s, meaning: "strength" },
2768
2884
  precision: "f64",
2769
- method: u ? "delta-pagerank" : "power-iteration",
2770
- // Present only when the method that ran measured them. Absent is the honest
2771
- // answer where it did not; a hard-coded `true` was the defect this replaces.
2772
- ...u ? {} : { converged: p.converged, iterations: p.iterations },
2773
- notes: O
2885
+ method: p ? "delta-pagerank" : "power-iteration",
2886
+ converged: u.converged,
2887
+ iterations: u.iterations,
2888
+ notes: x
2774
2889
  }
2775
2890
  };
2776
2891
  }
2777
2892
  };
2778
- J.namespace = "graphty", J.type = "pagerank", J.zodOptionsSchema = Ze, J.optionsSchema = {
2893
+ Q.namespace = "graphty", Q.type = "pagerank", Q.zodOptionsSchema = _e, Q.optionsSchema = {
2779
2894
  dampingFactor: {
2780
2895
  type: "number",
2781
2896
  default: 0.85,
@@ -2819,9 +2934,9 @@ J.namespace = "graphty", J.type = "pagerank", J.zodOptionsSchema = Ze, J.options
2819
2934
  }
2820
2935
  // Note: initialRanks and personalization are Map types - programmatic only, not in schema
2821
2936
  };
2822
- let Ce = J;
2823
- S.register(Ce);
2824
- const pa = {
2937
+ let Ee = Q;
2938
+ v.register(Ee);
2939
+ const Oa = {
2825
2940
  startNode: {
2826
2941
  schema: c.union([c.string(), c.number()]).nullable().default(null),
2827
2942
  meta: {
@@ -2829,7 +2944,7 @@ const pa = {
2829
2944
  description: "Starting node for MST growth (uses first node if not set)"
2830
2945
  }
2831
2946
  }
2832
- }, Q = class Q extends z {
2947
+ }, _ = class _ extends z {
2833
2948
  constructor() {
2834
2949
  super(...arguments), this.legacyOptions = null;
2835
2950
  }
@@ -2858,15 +2973,15 @@ const pa = {
2858
2973
  return null;
2859
2974
  const n = this.legacyOptions?.startNode ?? this._schemaOptions.startNode ?? void 0, a = this.algorithmGraph("undirected");
2860
2975
  e.report({ phase: "Choosing edges", total: null });
2861
- const i = Dt(a, n), o = /* @__PURE__ */ new Set();
2862
- for (const d of i.edges)
2863
- o.add(T(d.source, d.target)), o.add(T(d.target, d.source));
2976
+ const i = Kt(a, n), s = /* @__PURE__ */ new Set();
2977
+ for (const l of i.edges)
2978
+ s.add(T(l.source, l.target)), s.add(T(l.target, l.source));
2864
2979
  const r = [];
2865
- return await N(e, "Marking the network", t, (d) => {
2866
- r.push({ id: d.id, values: { in: o.has(T(d.srcId, d.dstId)) } });
2980
+ return await S(e, "Marking the network", t, (l) => {
2981
+ r.push({ id: l.id, values: { in: s.has(T(l.srcId, l.dstId)) } });
2867
2982
  }), {
2868
2983
  shape: "edge-set",
2869
- fields: We("edge", { name: "totalWeight", type: "number" }),
2984
+ fields: je("edge", { name: "totalWeight", type: "number" }),
2870
2985
  edges: r,
2871
2986
  graph: { totalWeight: i.totalWeight },
2872
2987
  caveats: M({
@@ -2878,7 +2993,7 @@ const pa = {
2878
2993
  };
2879
2994
  }
2880
2995
  };
2881
- Q.namespace = "graphty", Q.type = "prim", Q.zodOptionsSchema = pa, Q.optionsSchema = {
2996
+ _.namespace = "graphty", _.type = "prim", _.zodOptionsSchema = Oa, _.optionsSchema = {
2882
2997
  startNode: {
2883
2998
  type: "nodeId",
2884
2999
  default: null,
@@ -2887,9 +3002,9 @@ Q.namespace = "graphty", Q.type = "prim", Q.zodOptionsSchema = pa, Q.optionsSche
2887
3002
  required: !1
2888
3003
  }
2889
3004
  };
2890
- let ze = Q;
2891
- S.register(ze);
2892
- const He = class He extends z {
3005
+ let De = _;
3006
+ v.register(De);
3007
+ const Ue = class Ue extends z {
2893
3008
  /**
2894
3009
  * Find the pieces of the graph that a directed path can cross both ways.
2895
3010
  *
@@ -2905,17 +3020,17 @@ const He = class He extends z {
2905
3020
  return null;
2906
3021
  const n = this.algorithmGraph("directed");
2907
3022
  e.report({ phase: "Finding pieces", total: null });
2908
- const a = Pt(n), i = /* @__PURE__ */ new Map();
3023
+ const a = Lt(n), i = /* @__PURE__ */ new Map();
2909
3024
  for (let r = 0; r < a.length; r++)
2910
- for (const d of a[r])
2911
- i.set(d, r);
2912
- const o = [];
2913
- return await N(e, "Grouping nodes", t, (r) => {
2914
- o.push({ id: r, values: { group: i.get(r) ?? 0 } });
3025
+ for (const l of a[r])
3026
+ i.set(l, r);
3027
+ const s = [];
3028
+ return await S(e, "Grouping nodes", t, (r) => {
3029
+ s.push({ id: r, values: { group: i.get(r) ?? 0 } });
2915
3030
  }), {
2916
3031
  shape: "community",
2917
- fields: _(!1),
2918
- nodes: o,
3032
+ fields: ee(!1),
3033
+ nodes: s,
2919
3034
  caveats: M({
2920
3035
  method: "strongly-connected-components",
2921
3036
  direction: "directed",
@@ -2925,38 +3040,38 @@ const He = class He extends z {
2925
3040
  };
2926
3041
  }
2927
3042
  };
2928
- He.namespace = "graphty", He.type = "scc";
2929
- let Te = He;
2930
- S.register(Te);
2931
- const ma = "results.$";
2932
- function g(s) {
2933
- return { ...s, path: `${ma}.${s.name}` };
3043
+ Ue.namespace = "graphty", Ue.type = "scc";
3044
+ let Pe = Ue;
3045
+ v.register(Pe);
3046
+ const xa = "results.$";
3047
+ function f(o) {
3048
+ return { ...o, path: `${xa}.${o.name}` };
2934
3049
  }
2935
- function E(s, e) {
3050
+ function E(o, e) {
2936
3051
  return [
2937
- g({
3052
+ f({
2938
3053
  name: "value",
2939
3054
  plainName: e.plainName,
2940
3055
  technicalName: e.technicalName,
2941
- kind: s,
3056
+ kind: o,
2942
3057
  type: e.type ?? "number",
2943
3058
  ...e.unit === void 0 ? {} : { unit: e.unit }
2944
3059
  }),
2945
- g({ name: "rank", plainName: "Rank", technicalName: "rank", kind: s, type: "integer" }),
2946
- g({ name: "percentile", plainName: "Percentile", technicalName: "percentile", kind: s, type: "number" }),
2947
- g({ name: "min", plainName: "Lowest", technicalName: "min", kind: "graph", type: "number" }),
2948
- g({ name: "max", plainName: "Highest", technicalName: "max", kind: "graph", type: "number" }),
2949
- g({ name: "median", plainName: "Middle", technicalName: "median", kind: "graph", type: "number" }),
2950
- g({ name: "mean", plainName: "Average", technicalName: "mean", kind: "graph", type: "number" }),
2951
- g({ name: "measured", plainName: "Measured", technicalName: "measured", kind: "graph", type: "integer" }),
2952
- g({
3060
+ f({ name: "rank", plainName: "Rank", technicalName: "rank", kind: o, type: "integer" }),
3061
+ f({ name: "percentile", plainName: "Percentile", technicalName: "percentile", kind: o, type: "number" }),
3062
+ f({ name: "min", plainName: "Lowest", technicalName: "min", kind: "graph", type: "number" }),
3063
+ f({ name: "max", plainName: "Highest", technicalName: "max", kind: "graph", type: "number" }),
3064
+ f({ name: "median", plainName: "Middle", technicalName: "median", kind: "graph", type: "number" }),
3065
+ f({ name: "mean", plainName: "Average", technicalName: "mean", kind: "graph", type: "number" }),
3066
+ f({ name: "measured", plainName: "Measured", technicalName: "measured", kind: "graph", type: "integer" }),
3067
+ f({
2953
3068
  name: "normalization",
2954
3069
  plainName: "Normalization",
2955
3070
  technicalName: "normalization",
2956
3071
  kind: "graph",
2957
3072
  type: "string"
2958
3073
  }),
2959
- g({
3074
+ f({
2960
3075
  name: "tiedAtMin",
2961
3076
  plainName: "Tied at the lowest value",
2962
3077
  technicalName: "tiedAtMin",
@@ -2965,33 +3080,33 @@ function E(s, e) {
2965
3080
  })
2966
3081
  ];
2967
3082
  }
2968
- function ee(s, e) {
3083
+ function te(o, e) {
2969
3084
  const t = [
2970
- g({ name: "group", plainName: s, technicalName: "group", kind: "node", type: "integer" }),
2971
- g({
3085
+ f({ name: "group", plainName: o, technicalName: "group", kind: "node", type: "integer" }),
3086
+ f({
2972
3087
  name: "groupSize",
2973
- plainName: `${s} size`,
3088
+ plainName: `${o} size`,
2974
3089
  technicalName: "groupSize",
2975
3090
  kind: "node",
2976
3091
  type: "integer"
2977
3092
  }),
2978
- g({
3093
+ f({
2979
3094
  name: "groupCount",
2980
- plainName: `${s} count`,
3095
+ plainName: `${o} count`,
2981
3096
  technicalName: "groupCount",
2982
3097
  kind: "graph",
2983
3098
  type: "integer"
2984
3099
  }),
2985
- g({
3100
+ f({
2986
3101
  name: "sizes",
2987
- plainName: `${s} sizes`,
3102
+ plainName: `${o} sizes`,
2988
3103
  technicalName: "sizes",
2989
3104
  kind: "graph",
2990
3105
  type: "table"
2991
3106
  })
2992
3107
  ];
2993
3108
  return e && t.push(
2994
- g({
3109
+ f({
2995
3110
  name: "modularity",
2996
3111
  plainName: "Community strength",
2997
3112
  technicalName: "modularity",
@@ -3000,24 +3115,24 @@ function ee(s, e) {
3000
3115
  })
3001
3116
  ), t;
3002
3117
  }
3003
- function se(s, e, t) {
3118
+ function oe(o, e, t) {
3004
3119
  return [
3005
- g({ name: "in", plainName: e, technicalName: "in", kind: s, type: "boolean" }),
3006
- g({ name: "count", plainName: "Count", technicalName: "count", kind: "graph", type: "integer" }),
3007
- g({ ...t, kind: "graph" })
3120
+ f({ name: "in", plainName: e, technicalName: "in", kind: o, type: "boolean" }),
3121
+ f({ name: "count", plainName: "Count", technicalName: "count", kind: "graph", type: "integer" }),
3122
+ f({ ...t, kind: "graph" })
3008
3123
  ];
3009
3124
  }
3010
- function x(s) {
3011
- return Ue(s.getZodOptionsSchema());
3125
+ function k(o) {
3126
+ return Ae(o.getZodOptionsSchema());
3012
3127
  }
3013
- function Xe(...s) {
3128
+ function et(...o) {
3014
3129
  const e = [], t = /* @__PURE__ */ new Set();
3015
- for (const n of s)
3130
+ for (const n of o)
3016
3131
  for (const a of n)
3017
3132
  t.has(a.name) || (t.add(a.name), e.push(a));
3018
3133
  return e;
3019
3134
  }
3020
- const ga = {
3135
+ const Ia = {
3021
3136
  method: {
3022
3137
  schema: c.enum(["dijkstra", "bellman-ford"]).nullable().default(null),
3023
3138
  meta: {
@@ -3027,7 +3142,7 @@ const ga = {
3027
3142
  group: "engine"
3028
3143
  }
3029
3144
  }
3030
- }, fa = {
3145
+ }, Ma = {
3031
3146
  strength: {
3032
3147
  schema: c.enum(["weak", "strong"]).default("weak"),
3033
3148
  meta: {
@@ -3035,7 +3150,7 @@ const ga = {
3035
3150
  description: "Weak follows an edge in either direction. Strong needs a directed path each way, and only differs from weak on a directed graph."
3036
3151
  }
3037
3152
  }
3038
- }, nt = [
3153
+ }, ot = [
3039
3154
  {
3040
3155
  key: "degree",
3041
3156
  plainName: "Connections",
@@ -3045,14 +3160,14 @@ const ga = {
3045
3160
  shape: "node-metric",
3046
3161
  fields: [
3047
3162
  ...E("node", { plainName: "Connections", technicalName: "degree", type: "integer", unit: "links" }),
3048
- g({
3163
+ f({
3049
3164
  name: "inDegree",
3050
3165
  plainName: "Incoming connections",
3051
3166
  technicalName: "inDegree",
3052
3167
  kind: "node",
3053
3168
  type: "integer"
3054
3169
  }),
3055
- g({
3170
+ f({
3056
3171
  name: "outDegree",
3057
3172
  plainName: "Outgoing connections",
3058
3173
  technicalName: "outDegree",
@@ -3060,7 +3175,7 @@ const ga = {
3060
3175
  type: "integer"
3061
3176
  })
3062
3177
  ],
3063
- options: x(me),
3178
+ options: k(ge),
3064
3179
  costClass: "instant",
3065
3180
  complexity: "O(n + m)",
3066
3181
  legacyKeys: [{ key: "degree" }]
@@ -3073,7 +3188,7 @@ const ga = {
3073
3188
  category: "centrality",
3074
3189
  shape: "node-metric",
3075
3190
  fields: E("node", { plainName: "Bridging", technicalName: "betweenness" }),
3076
- options: x(le),
3191
+ options: k(de),
3077
3192
  costClass: "heavy",
3078
3193
  complexity: "O(n * m)",
3079
3194
  legacyKeys: [{ key: "betweenness" }]
@@ -3086,7 +3201,7 @@ const ga = {
3086
3201
  category: "centrality",
3087
3202
  shape: "node-metric",
3088
3203
  fields: E("node", { plainName: "Reach", technicalName: "closeness" }),
3089
- options: x(ue),
3204
+ options: k(pe),
3090
3205
  costClass: "heavy",
3091
3206
  complexity: "O(n * m)",
3092
3207
  legacyKeys: [{ key: "closeness" }]
@@ -3099,7 +3214,7 @@ const ga = {
3099
3214
  category: "centrality",
3100
3215
  shape: "node-metric",
3101
3216
  fields: E("node", { plainName: "Influence", technicalName: "PageRank score" }),
3102
- options: x(Ce),
3217
+ options: k(Ee),
3103
3218
  costClass: "iterative",
3104
3219
  complexity: "O(k(n + m))",
3105
3220
  legacyKeys: [{ key: "pagerank" }]
@@ -3112,7 +3227,7 @@ const ga = {
3112
3227
  category: "centrality",
3113
3228
  shape: "node-metric",
3114
3229
  fields: E("node", { plainName: "Influence by association", technicalName: "eigenvector score" }),
3115
- options: x(ye),
3230
+ options: k(be),
3116
3231
  costClass: "iterative",
3117
3232
  complexity: "O(k(n + m))",
3118
3233
  legacyKeys: [{ key: "eigenvector" }]
@@ -3125,7 +3240,7 @@ const ga = {
3125
3240
  category: "centrality",
3126
3241
  shape: "node-metric",
3127
3242
  fields: E("node", { plainName: "Influence at a distance", technicalName: "Katz score" }),
3128
- options: x(Ne),
3243
+ options: k(ke),
3129
3244
  costClass: "iterative",
3130
3245
  complexity: "O(k(n + m))",
3131
3246
  legacyKeys: [{ key: "katz" }]
@@ -3139,8 +3254,8 @@ const ga = {
3139
3254
  shape: "node-metric",
3140
3255
  fields: [
3141
3256
  ...E("node", { plainName: "Hub and authority", technicalName: "combined HITS score" }),
3142
- g({ name: "hub", plainName: "Hub", technicalName: "hub score", kind: "node", type: "number" }),
3143
- g({
3257
+ f({ name: "hub", plainName: "Hub", technicalName: "hub score", kind: "node", type: "number" }),
3258
+ f({
3144
3259
  name: "authority",
3145
3260
  plainName: "Authority",
3146
3261
  technicalName: "authority score",
@@ -3148,7 +3263,7 @@ const ga = {
3148
3263
  type: "number"
3149
3264
  })
3150
3265
  ],
3151
- options: x(ve),
3266
+ options: k(Ne),
3152
3267
  costClass: "iterative",
3153
3268
  complexity: "O(k(n + m))",
3154
3269
  legacyKeys: [{ key: "hits" }]
@@ -3160,8 +3275,8 @@ const ga = {
3160
3275
  description: "Groups nodes into communities by repeatedly merging the groups whose merger tightens the partition the most.",
3161
3276
  category: "community",
3162
3277
  shape: "community",
3163
- fields: ee("Community", !0),
3164
- options: x(xe),
3278
+ fields: te("Community", !0),
3279
+ options: k(Ce),
3165
3280
  costClass: "iterative",
3166
3281
  complexity: "O(k(n + m))",
3167
3282
  legacyKeys: [{ key: "louvain" }]
@@ -3173,8 +3288,8 @@ const ga = {
3173
3288
  description: "Groups nodes into communities the way Louvain does, with a refinement pass that rules out groups held together by a single node.",
3174
3289
  category: "community",
3175
3290
  shape: "community",
3176
- fields: ee("Community", !0),
3177
- options: x(Oe),
3291
+ fields: te("Community", !0),
3292
+ options: k(Ie),
3178
3293
  costClass: "iterative",
3179
3294
  complexity: "O(k(n + m))",
3180
3295
  legacyKeys: [{ key: "leiden" }]
@@ -3186,8 +3301,8 @@ const ga = {
3186
3301
  description: "Groups nodes into communities by letting every node repeatedly take whichever label most of its neighbours carry.",
3187
3302
  category: "community",
3188
3303
  shape: "community",
3189
- fields: ee("Community", !1),
3190
- options: x(Se),
3304
+ fields: te("Community", !1),
3305
+ options: k(xe),
3191
3306
  costClass: "iterative",
3192
3307
  complexity: "O(k(n + m))",
3193
3308
  legacyKeys: [{ key: "label-propagation" }]
@@ -3199,8 +3314,8 @@ const ga = {
3199
3314
  description: "Groups nodes into communities by repeatedly cutting the edge that the most shortest paths run through, until the graph falls apart.",
3200
3315
  category: "community",
3201
3316
  shape: "community",
3202
- fields: ee("Community", !0),
3203
- options: x(we),
3317
+ fields: te("Community", !0),
3318
+ options: k(ve),
3204
3319
  costClass: "heavy",
3205
3320
  complexity: "O(n * m^2)",
3206
3321
  legacyKeys: [{ key: "girvan-newman" }]
@@ -3212,11 +3327,11 @@ const ga = {
3212
3327
  description: "Finds the separate pieces of the graph: two nodes belong to the same piece when a path joins them.",
3213
3328
  category: "structure",
3214
3329
  shape: "community",
3215
- fields: ee("Piece", !1),
3216
- options: Xe(
3217
- x(pe),
3218
- x(Te),
3219
- Ue(fa)
3330
+ fields: te("Piece", !1),
3331
+ options: et(
3332
+ k(me),
3333
+ k(Pe),
3334
+ Ae(Ma)
3220
3335
  ),
3221
3336
  costClass: "instant",
3222
3337
  complexity: "O(n + m)",
@@ -3230,14 +3345,14 @@ const ga = {
3230
3345
  category: "path",
3231
3346
  shape: "path",
3232
3347
  fields: [
3233
- g({ name: "onPath", plainName: "On the route", technicalName: "onPath", kind: "node", type: "boolean" }),
3234
- g({ name: "order", plainName: "Position on the route", technicalName: "order", kind: "node", type: "integer" }),
3235
- g({ name: "distance", plainName: "Distance from the source", technicalName: "distance", kind: "node", type: "number" }),
3236
- g({ name: "onPath", plainName: "On the route", technicalName: "onPath", kind: "edge", type: "boolean" }),
3237
- g({ name: "length", plainName: "Nodes on the route", technicalName: "length", kind: "graph", type: "integer" }),
3238
- g({ name: "cost", plainName: "Total cost", technicalName: "cost", kind: "graph", type: "number" }),
3239
- g({ name: "hops", plainName: "Edges on the route", technicalName: "hops", kind: "graph", type: "integer" }),
3240
- g({
3348
+ f({ name: "onPath", plainName: "On the route", technicalName: "onPath", kind: "node", type: "boolean" }),
3349
+ f({ name: "order", plainName: "Position on the route", technicalName: "order", kind: "node", type: "integer" }),
3350
+ f({ name: "distance", plainName: "Distance from the source", technicalName: "distance", kind: "node", type: "number" }),
3351
+ f({ name: "onPath", plainName: "On the route", technicalName: "onPath", kind: "edge", type: "boolean" }),
3352
+ f({ name: "length", plainName: "Nodes on the route", technicalName: "length", kind: "graph", type: "integer" }),
3353
+ f({ name: "cost", plainName: "Total cost", technicalName: "cost", kind: "graph", type: "number" }),
3354
+ f({ name: "hops", plainName: "Edges on the route", technicalName: "hops", kind: "graph", type: "integer" }),
3355
+ f({
3241
3356
  name: "hasNegativeCycle",
3242
3357
  plainName: "Has a loop that costs less every time round",
3243
3358
  technicalName: "hasNegativeCycle",
@@ -3245,10 +3360,10 @@ const ga = {
3245
3360
  type: "boolean"
3246
3361
  })
3247
3362
  ],
3248
- options: Xe(
3249
- x(fe),
3250
- x(ce),
3251
- Ue(ga)
3363
+ options: et(
3364
+ k(ye),
3365
+ k(le),
3366
+ Ae(Ia)
3252
3367
  ),
3253
3368
  costClass: "instant",
3254
3369
  complexity: "O((n + m) log n) with dijkstra, O(n * m) with bellman-ford",
@@ -3274,9 +3389,9 @@ const ga = {
3274
3389
  shape: "node-metric",
3275
3390
  fields: [
3276
3391
  ...E("node", { plainName: "Distance to the furthest node", technicalName: "eccentricity" }),
3277
- g({ name: "diameter", plainName: "Widest distance", technicalName: "diameter", kind: "graph", type: "number" }),
3278
- g({ name: "radius", plainName: "Narrowest distance", technicalName: "radius", kind: "graph", type: "number" }),
3279
- g({
3392
+ f({ name: "diameter", plainName: "Widest distance", technicalName: "diameter", kind: "graph", type: "number" }),
3393
+ f({ name: "radius", plainName: "Narrowest distance", technicalName: "radius", kind: "graph", type: "number" }),
3394
+ f({
3280
3395
  name: "hasNegativeCycle",
3281
3396
  plainName: "Has a loop that costs less every time round",
3282
3397
  technicalName: "hasNegativeCycle",
@@ -3284,7 +3399,7 @@ const ga = {
3284
3399
  type: "boolean"
3285
3400
  })
3286
3401
  ],
3287
- options: x(be),
3402
+ options: k(we),
3288
3403
  costClass: "cubic",
3289
3404
  complexity: "O(n^3)",
3290
3405
  legacyKeys: [{ key: "floyd-warshall" }]
@@ -3297,14 +3412,14 @@ const ga = {
3297
3412
  category: "path",
3298
3413
  shape: "layered-grouping",
3299
3414
  fields: [
3300
- g({ name: "level", plainName: "Steps away", technicalName: "level", kind: "node", type: "integer" }),
3301
- g({ name: "levelSize", plainName: "Nodes this many steps away", technicalName: "levelSize", kind: "node", type: "integer" }),
3302
- g({ name: "order", plainName: "Visit order", technicalName: "order", kind: "node", type: "integer" }),
3303
- g({ name: "levelCount", plainName: "Levels", technicalName: "levelCount", kind: "graph", type: "integer" }),
3304
- g({ name: "sizes", plainName: "Level sizes", technicalName: "sizes", kind: "graph", type: "table" }),
3305
- g({ name: "targetFound", plainName: "Target reached", technicalName: "targetFound", kind: "graph", type: "boolean" })
3415
+ f({ name: "level", plainName: "Steps away", technicalName: "level", kind: "node", type: "integer" }),
3416
+ f({ name: "levelSize", plainName: "Nodes this many steps away", technicalName: "levelSize", kind: "node", type: "integer" }),
3417
+ f({ name: "order", plainName: "Visit order", technicalName: "order", kind: "node", type: "integer" }),
3418
+ f({ name: "levelCount", plainName: "Levels", technicalName: "levelCount", kind: "graph", type: "integer" }),
3419
+ f({ name: "sizes", plainName: "Level sizes", technicalName: "sizes", kind: "graph", type: "table" }),
3420
+ f({ name: "targetFound", plainName: "Target reached", technicalName: "targetFound", kind: "graph", type: "boolean" })
3306
3421
  ],
3307
- options: x(de),
3422
+ options: k(he),
3308
3423
  costClass: "instant",
3309
3424
  complexity: "O(n + m)",
3310
3425
  legacyKeys: [{ key: "bfs" }]
@@ -3318,9 +3433,9 @@ const ga = {
3318
3433
  shape: "node-metric",
3319
3434
  fields: [
3320
3435
  ...E("node", { plainName: "Exploration order", technicalName: "discovery time", type: "integer" }),
3321
- g({ name: "visited", plainName: "Reached", technicalName: "visited", kind: "node", type: "boolean" })
3436
+ f({ name: "visited", plainName: "Reached", technicalName: "visited", kind: "node", type: "boolean" })
3322
3437
  ],
3323
- options: x(ge),
3438
+ options: k(fe),
3324
3439
  costClass: "instant",
3325
3440
  complexity: "O(n + m)",
3326
3441
  legacyKeys: [{ key: "dfs" }]
@@ -3332,13 +3447,13 @@ const ga = {
3332
3447
  description: "Finds the cheapest set of edges that still joins every node, by taking the cheapest edge that does not close a loop.",
3333
3448
  category: "structure",
3334
3449
  shape: "edge-set",
3335
- fields: se("edge", "In the network", {
3450
+ fields: oe("edge", "In the network", {
3336
3451
  name: "totalWeight",
3337
3452
  plainName: "Total cost",
3338
3453
  technicalName: "totalWeight",
3339
3454
  type: "number"
3340
3455
  }),
3341
- options: x(ke),
3456
+ options: k(Oe),
3342
3457
  costClass: "instant",
3343
3458
  complexity: "O(m log m)",
3344
3459
  requires: { directed: !1 },
@@ -3351,13 +3466,13 @@ const ga = {
3351
3466
  description: "Finds the cheapest set of edges that still joins every node, by growing outwards from one starting node.",
3352
3467
  category: "structure",
3353
3468
  shape: "edge-set",
3354
- fields: se("edge", "In the network", {
3469
+ fields: oe("edge", "In the network", {
3355
3470
  name: "totalWeight",
3356
3471
  plainName: "Total cost",
3357
3472
  technicalName: "totalWeight",
3358
3473
  type: "number"
3359
3474
  }),
3360
- options: x(ze),
3475
+ options: k(De),
3361
3476
  costClass: "instant",
3362
3477
  complexity: "O(m log n)",
3363
3478
  requires: { directed: !1 },
@@ -3371,16 +3486,16 @@ const ga = {
3371
3486
  category: "structure",
3372
3487
  shape: "edge-set",
3373
3488
  fields: [
3374
- ...se("edge", "In the pairing", {
3489
+ ...oe("edge", "In the pairing", {
3375
3490
  name: "bipartite",
3376
3491
  plainName: "Has two sides",
3377
3492
  technicalName: "bipartite",
3378
3493
  type: "boolean"
3379
3494
  }),
3380
- g({ name: "side", plainName: "Side", technicalName: "side", kind: "node", type: "string" }),
3381
- g({ name: "matched", plainName: "Paired", technicalName: "matched", kind: "node", type: "boolean" })
3495
+ f({ name: "side", plainName: "Side", technicalName: "side", kind: "node", type: "string" }),
3496
+ f({ name: "matched", plainName: "Paired", technicalName: "matched", kind: "node", type: "boolean" })
3382
3497
  ],
3383
- options: x(he),
3498
+ options: k(ue),
3384
3499
  costClass: "heavy",
3385
3500
  complexity: "O(n * m)",
3386
3501
  requires: { directed: !1 },
@@ -3395,13 +3510,13 @@ const ga = {
3395
3510
  shape: "edge-metric",
3396
3511
  fields: [
3397
3512
  ...E("edge", { plainName: "Flow", technicalName: "flow" }),
3398
- g({ name: "capacity", plainName: "Capacity", technicalName: "capacity", kind: "edge", type: "number" }),
3399
- g({ name: "utilization", plainName: "Share of capacity used", technicalName: "utilization", kind: "edge", type: "number" }),
3400
- g({ name: "netFlow", plainName: "Net flow", technicalName: "netFlow", kind: "node", type: "number" }),
3401
- g({ name: "role", plainName: "Source or sink", technicalName: "role", kind: "node", type: "string" }),
3402
- g({ name: "maxFlow", plainName: "Most that can flow", technicalName: "maxFlow", kind: "graph", type: "number" })
3513
+ f({ name: "capacity", plainName: "Capacity", technicalName: "capacity", kind: "edge", type: "number" }),
3514
+ f({ name: "utilization", plainName: "Share of capacity used", technicalName: "utilization", kind: "edge", type: "number" }),
3515
+ f({ name: "netFlow", plainName: "Net flow", technicalName: "netFlow", kind: "node", type: "number" }),
3516
+ f({ name: "role", plainName: "Source or sink", technicalName: "role", kind: "node", type: "string" }),
3517
+ f({ name: "maxFlow", plainName: "Most that can flow", technicalName: "maxFlow", kind: "graph", type: "number" })
3403
3518
  ],
3404
- options: x(Ie),
3519
+ options: k(ze),
3405
3520
  costClass: "heavy",
3406
3521
  complexity: "O(n * m^2)",
3407
3522
  legacyKeys: [{ key: "max-flow" }]
@@ -3414,69 +3529,99 @@ const ga = {
3414
3529
  category: "flow",
3415
3530
  shape: "edge-set",
3416
3531
  fields: [
3417
- ...se("edge", "In the cut", {
3532
+ ...oe("edge", "In the cut", {
3418
3533
  name: "cutValue",
3419
3534
  plainName: "Cost of the cut",
3420
3535
  technicalName: "cutValue",
3421
3536
  type: "number"
3422
3537
  }),
3423
- g({ name: "side", plainName: "Side", technicalName: "side", kind: "node", type: "string" })
3538
+ f({ name: "side", plainName: "Side", technicalName: "side", kind: "node", type: "string" })
3424
3539
  ],
3425
- options: x(Me),
3540
+ options: k(Te),
3426
3541
  costClass: "heavy",
3427
3542
  complexity: "O(n * m^2) between two nodes, O(n * m + n^2 log n) across the whole graph, O(k * n^2) with Karger",
3428
3543
  legacyKeys: [{ key: "min-cut" }]
3544
+ },
3545
+ {
3546
+ key: "k-core",
3547
+ plainName: "Core depth",
3548
+ technicalName: "K-core decomposition",
3549
+ description: "Peels the graph layer by layer and gives each node the depth of the most tightly knit core it belongs to: a node of depth k has at least k neighbours inside that core.",
3550
+ category: "structure",
3551
+ shape: "node-metric",
3552
+ fields: E("node", { plainName: "Core depth", technicalName: "core number", type: "integer" }),
3553
+ options: k(Se),
3554
+ costClass: "instant",
3555
+ complexity: "O(n + m)",
3556
+ legacyKeys: [{ key: "k-core" }]
3557
+ },
3558
+ {
3559
+ key: "link-prediction",
3560
+ plainName: "Likely new links",
3561
+ technicalName: "Link prediction",
3562
+ description: "Scores the pairs of nodes that are not yet joined by the neighbours they share, and lists the pairs most likely to be joined next.",
3563
+ category: "prediction",
3564
+ shape: "pair-list",
3565
+ fields: [
3566
+ f({ name: "pairs", plainName: "Likely new links", technicalName: "pairs", kind: "graph", type: "table" })
3567
+ ],
3568
+ options: k(Me),
3569
+ costClass: "heavy",
3570
+ complexity: "O(n^2 * d)",
3571
+ legacyKeys: [{ key: "link-prediction" }]
3429
3572
  }
3430
3573
  ];
3431
- function Da(s) {
3432
- return nt.find((e) => e.key === s);
3574
+ function ja(o) {
3575
+ return ot.find((e) => e.key === o);
3433
3576
  }
3434
- function Pa(s) {
3435
- for (const e of nt)
3577
+ function Va(o) {
3578
+ for (const e of ot)
3436
3579
  for (const t of e.legacyKeys)
3437
- if (t.key === s)
3580
+ if (t.key === o)
3438
3581
  return { descriptor: e, params: t.params ?? {} };
3439
3582
  }
3440
3583
  export {
3441
- Me as A,
3442
- nt as B,
3443
- at as C,
3444
- me as D,
3445
- ye as E,
3446
- be as F,
3447
- we as G,
3448
- ve as H,
3449
- Lt as I,
3450
- Ne as K,
3451
- xe as L,
3452
- Ie as M,
3453
- Wt as N,
3454
- Ce as P,
3455
- Te as S,
3456
- tt as a,
3457
- te as b,
3458
- Da as c,
3459
- Pa as d,
3460
- za as e,
3461
- Ta as f,
3462
- Ma as g,
3463
- Ca as h,
3464
- Oa as i,
3465
- xa as j,
3466
- Ea as k,
3467
- Kt as l,
3468
- Ia as m,
3469
- fe as n,
3470
- le as o,
3471
- ue as p,
3472
- Oe as q,
3473
- Se as r,
3474
- ce as s,
3475
- $t as t,
3476
- de as u,
3477
- ge as v,
3478
- pe as w,
3479
- ke as x,
3480
- ze as y,
3481
- he as z
3584
+ Te as A,
3585
+ ot as B,
3586
+ st as C,
3587
+ ge as D,
3588
+ be as E,
3589
+ we as F,
3590
+ ve as G,
3591
+ Ne as H,
3592
+ Se as I,
3593
+ Me as J,
3594
+ ke as K,
3595
+ Ce as L,
3596
+ ze as M,
3597
+ Bt as N,
3598
+ Zt as O,
3599
+ Ee as P,
3600
+ Pe as S,
3601
+ it as a,
3602
+ ae as b,
3603
+ ja as c,
3604
+ Va as d,
3605
+ Ka as e,
3606
+ La as f,
3607
+ Ha as g,
3608
+ Wa as h,
3609
+ Fa as i,
3610
+ $a as j,
3611
+ Ua as k,
3612
+ Yt as l,
3613
+ Ga as m,
3614
+ ye as n,
3615
+ de as o,
3616
+ pe as p,
3617
+ Ie as q,
3618
+ xe as r,
3619
+ le as s,
3620
+ Vt as t,
3621
+ he as u,
3622
+ fe as v,
3623
+ me as w,
3624
+ Oe as x,
3625
+ De as y,
3626
+ ue as z
3482
3627
  };