@graphty/graphty-element 2.5.2 → 2.6.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 (135) hide show
  1. package/dist/ai.js +3 -3
  2. package/dist/catalog.d.ts +16 -0
  3. package/dist/catalog.js +34 -32
  4. package/dist/chunks/{AiManager-CrbvKdEK.js → AiManager-4iQpsJW1.js} +4 -4
  5. package/dist/chunks/{DataSource-qU-nLhXN.js → DataSource-BL2UzPff.js} +2 -2
  6. package/dist/chunks/GraphSession-BhuHSXIo.js +12819 -0
  7. package/dist/chunks/{GraphtyLogger-DOTwCiMR.js → GraphtyLogger-B_O67a6c.js} +1 -1
  8. package/dist/chunks/{VoiceInputAdapter-D4NrRL_1.js → VoiceInputAdapter-Cc6mHXTI.js} +1 -1
  9. package/dist/chunks/{XRPivotCameraController-Uqa47vmo.js → XRPivotCameraController-BLa89LXn.js} +2 -2
  10. package/dist/chunks/{algorithms-D-ab-Auu.js → algorithms-BJ6DQMOe.js} +931 -781
  11. package/dist/chunks/{capability-check-Vw3IcqiE.js → capability-check-Am2zliFj.js} +1 -1
  12. package/dist/chunks/{detect-B4Qrw976.js → detect-fyuVnlCT.js} +1 -1
  13. package/dist/chunks/{format-detection-r2IfNFXO.js → format-detection-BHwrAVzW.js} +1 -1
  14. package/dist/chunks/{index-J9MgLio9.js → index-BkBLbvui.js} +2691 -2434
  15. package/dist/chunks/optionsFromZod-CKMYSwTz.js +3636 -0
  16. package/dist/chunks/{paletteRegistry-Kt-6CeoN.js → paletteRegistry-BCFSwJGK.js} +224 -189
  17. package/dist/chunks/parse-BMTqt4SS.js +3658 -0
  18. package/dist/chunks/{types-C_c53VgR.js → types-DFchv4Ny.js} +4 -1
  19. package/dist/custom-elements.json +1 -1
  20. package/dist/extend.d.ts +10 -8
  21. package/dist/extend.js +6 -6
  22. package/dist/graphty-catalog.json +75 -38
  23. package/dist/graphty.bundle.js +55368 -48970
  24. package/dist/graphty.js +19 -19
  25. package/dist/index.d.ts +1 -1
  26. package/dist/logging.js +2 -2
  27. package/dist/schema.d.ts +15 -1
  28. package/dist/schema.js +1 -1
  29. package/dist/session.d.ts +30 -7
  30. package/dist/session.js +40 -37
  31. package/dist/src/Graph.d.ts +35 -7
  32. package/dist/src/acceleration/types.d.ts +79 -43
  33. package/dist/src/algorithms/Algorithm.d.ts +52 -4
  34. package/dist/src/algorithms/BFSAlgorithm.d.ts +3 -0
  35. package/dist/src/algorithms/BellmanFordAlgorithm.d.ts +3 -0
  36. package/dist/src/algorithms/BetweennessCentralityAlgorithm.d.ts +3 -0
  37. package/dist/src/algorithms/BipartiteMatchingAlgorithm.d.ts +3 -0
  38. package/dist/src/algorithms/ClosenessCentralityAlgorithm.d.ts +3 -0
  39. package/dist/src/algorithms/ConnectedComponentsAlgorithm.d.ts +4 -1
  40. package/dist/src/algorithms/DFSAlgorithm.d.ts +3 -0
  41. package/dist/src/algorithms/DegreeAlgorithm.d.ts +3 -0
  42. package/dist/src/algorithms/DijkstraAlgorithm.d.ts +6 -0
  43. package/dist/src/algorithms/EigenvectorCentralityAlgorithm.d.ts +2 -0
  44. package/dist/src/algorithms/FloydWarshallAlgorithm.d.ts +3 -0
  45. package/dist/src/algorithms/GirvanNewmanAlgorithm.d.ts +3 -0
  46. package/dist/src/algorithms/HITSAlgorithm.d.ts +3 -0
  47. package/dist/src/algorithms/KCoreAlgorithm.d.ts +3 -0
  48. package/dist/src/algorithms/KatzCentralityAlgorithm.d.ts +3 -0
  49. package/dist/src/algorithms/KruskalAlgorithm.d.ts +4 -1
  50. package/dist/src/algorithms/LabelPropagationAlgorithm.d.ts +3 -0
  51. package/dist/src/algorithms/LeidenAlgorithm.d.ts +3 -0
  52. package/dist/src/algorithms/LinkPredictionAlgorithm.d.ts +4 -1
  53. package/dist/src/algorithms/LouvainAlgorithm.d.ts +3 -0
  54. package/dist/src/algorithms/MaxFlowAlgorithm.d.ts +3 -0
  55. package/dist/src/algorithms/MinCutAlgorithm.d.ts +3 -0
  56. package/dist/src/algorithms/PageRankAlgorithm.d.ts +3 -0
  57. package/dist/src/algorithms/PrimAlgorithm.d.ts +3 -0
  58. package/dist/src/algorithms/StronglyConnectedComponentsAlgorithm.d.ts +3 -0
  59. package/dist/src/algorithms/input/ScopedInput.d.ts +185 -0
  60. package/dist/src/algorithms/input/derivedInputs.d.ts +199 -0
  61. package/dist/src/algorithms/input/maskBack.d.ts +37 -0
  62. package/dist/src/algorithms/metrics/MetricAlgorithm.d.ts +3 -3
  63. package/dist/src/algorithms/results/DeclaredAlgorithm.d.ts +4 -3
  64. package/dist/src/algorithms/results/types.d.ts +28 -6
  65. package/dist/src/algorithms/utils/communityUtils.d.ts +0 -48
  66. package/dist/src/algorithms/utils/graphUtils.d.ts +2 -68
  67. package/dist/src/algorithms/utils/snapshotGraph.d.ts +3 -1
  68. package/dist/src/catalog/algorithms.d.ts +3 -0
  69. package/dist/src/catalog/layouts.d.ts +2 -0
  70. package/dist/src/catalog/sets/canonical.d.ts +68 -0
  71. package/dist/src/catalog/sets/hash.d.ts +126 -0
  72. package/dist/src/catalog/sets/parse.d.ts +115 -0
  73. package/dist/src/catalog/types.d.ts +329 -8
  74. package/dist/src/data/GraphStore.d.ts +73 -1
  75. package/dist/src/data/edgeIdentity.d.ts +202 -1
  76. package/dist/src/data/ingest.d.ts +3 -1
  77. package/dist/src/data/report.d.ts +20 -0
  78. package/dist/src/graphty-element.d.ts +42 -6
  79. package/dist/src/layout/D3GraphLayoutEngine.d.ts +11 -0
  80. package/dist/src/layout/LayoutEngine.d.ts +56 -0
  81. package/dist/src/layout/NGraphLayoutEngine.d.ts +10 -0
  82. package/dist/src/layout/SimulationLayoutEngine.d.ts +11 -0
  83. package/dist/src/managers/AlgorithmManager.d.ts +8 -0
  84. package/dist/src/managers/DataManager.d.ts +11 -0
  85. package/dist/src/managers/LayoutManager.d.ts +126 -2
  86. package/dist/src/managers/StatsManager.d.ts +1 -0
  87. package/dist/src/session/GraphSession.d.ts +48 -0
  88. package/dist/src/session/attributes.d.ts +121 -1
  89. package/dist/src/session/cost/estimate.d.ts +20 -0
  90. package/dist/src/session/cost/index.d.ts +1 -1
  91. package/dist/src/session/planning.d.ts +32 -2
  92. package/dist/src/session/query.d.ts +7 -0
  93. package/dist/src/session/results/ResultsApi.d.ts +14 -1
  94. package/dist/src/session/runs/Run.d.ts +65 -4
  95. package/dist/src/session/runs/RunsApi.d.ts +58 -2
  96. package/dist/src/session/runs/runId.d.ts +55 -6
  97. package/dist/src/session/runs/types.d.ts +36 -8
  98. package/dist/src/session/scope/ElementMask.d.ts +14 -1
  99. package/dist/src/session/scope/ScopeApi.d.ts +160 -31
  100. package/dist/src/session/scope/index.d.ts +1 -1
  101. package/dist/src/session/selection/SelectionApi.d.ts +15 -10
  102. package/dist/src/session/selection/index.d.ts +1 -1
  103. package/dist/src/session/selection/targets.d.ts +6 -7
  104. package/dist/src/session/sets/SetsApi.d.ts +110 -0
  105. package/dist/src/session/sets/algebra.d.ts +124 -0
  106. package/dist/src/session/sets/cache.d.ts +197 -0
  107. package/dist/src/session/sets/captures.d.ts +83 -0
  108. package/dist/src/session/sets/dependencies.d.ts +167 -0
  109. package/dist/src/session/sets/layers.d.ts +101 -0
  110. package/dist/src/session/sets/notify.d.ts +122 -0
  111. package/dist/src/session/sets/offers.d.ts +103 -0
  112. package/dist/src/session/sets/path.d.ts +37 -0
  113. package/dist/src/session/sets/prepare.d.ts +209 -0
  114. package/dist/src/session/sets/resolve.d.ts +311 -0
  115. package/dist/src/session/sets/signature.d.ts +77 -0
  116. package/dist/src/session/sets/status.d.ts +98 -0
  117. package/dist/src/session/sets/store.d.ts +196 -0
  118. package/dist/src/session/sets/types.d.ts +386 -0
  119. package/dist/src/session/styles/Layer.d.ts +9 -2
  120. package/dist/src/session/styles/StylesApi.d.ts +5 -2
  121. package/dist/src/session/styles/explain.d.ts +5 -2
  122. package/dist/src/session/styles/predicate.d.ts +41 -2
  123. package/dist/src/session/styles/repaint.d.ts +19 -0
  124. package/dist/src/session/styles/selector.d.ts +16 -5
  125. package/dist/src/session/types.d.ts +18 -0
  126. package/dist/src/session/visibility/VisibilityApi.d.ts +47 -3
  127. package/dist/src/session/visibility/filter.d.ts +86 -51
  128. package/dist/src/session/visibility/index.d.ts +1 -1
  129. package/dist/src/testing/fakeAccelerator.d.ts +5 -0
  130. package/dist/src/utils/queue-migration.d.ts +17 -0
  131. package/package.json +15 -9
  132. package/dist/chunks/GraphSession-DuAhRgCd.js +0 -8622
  133. package/dist/chunks/optionsFromZod-B9RncoTX.js +0 -2578
  134. package/dist/chunks/scales-CJCRwi2J.js +0 -3220
  135. package/dist/src/algorithms/utils/index.d.ts +0 -6
@@ -1,27 +1,27 @@
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-B9RncoTX.js";
1
+ import { c as ut } from "./common-DWNKjpH_.js";
2
+ import { E as pt, a as mt, N as gt } from "./NodeStyle-CtmA7dXi.js";
3
+ import { J as ft, k as yt, a as E, K as R, h as S, M as ie, P as rt, f as C, A as v, Y as bt, N as wt, Q as vt, S as Nt, n as U, L as et, s as Ze, e as oe, m as Be, i as Ae, o as Qe } from "./optionsFromZod-CKMYSwTz.js";
4
4
  import { z as c } from "zod/v4";
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 "./pluginRegistry-Bs8bEkz9.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;
5
+ import { bellmanFord as kt, betweennessCentrality as St, breadthFirstSearch as Ot, bipartitePartition as xt, maximumBipartiteMatching as It, closenessCentrality as Ct, depthFirstSearch as Tt, eigenvectorCentrality as zt, ConvergenceError as Et, floydWarshall as Mt, girvanNewman as Dt, hits as Pt, katzCentrality as Rt, kCoreDecomposition as $t, labelPropagation as Ft, leiden as Gt, commonNeighborsPrediction as Ht, adamicAdarPrediction as Wt, louvain as Kt, Graph as _e, fordFulkerson as Lt, kargerMinCut as Ut, stoerWagner as jt, minSTCut as Vt, pageRank as qt, connectedComponents as Bt, primMST as tt, stronglyConnectedComponents as Yt } from "@graphty/algorithms";
6
+ import { G as ct } from "./pluginRegistry-Bs8bEkz9.js";
7
+ import { INVALID_INDEX as L } from "@graphty/graph-format";
8
+ var Va = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
9
+ function qa(s) {
10
+ return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
11
11
  }
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;
12
+ const Zt = /^#?(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;
13
+ function Xe(s) {
14
+ return Number.isFinite(s) ? Math.max(0, Math.min(255, Math.round(s))) : 0;
15
15
  }
16
- function ie(o) {
17
- return o.toString(16).padStart(2, "0");
16
+ function je(s) {
17
+ return s.toString(16).padStart(2, "0");
18
18
  }
19
- function jt(o) {
20
- if (!Ut.test(o))
19
+ function Jt(s) {
20
+ if (!Zt.test(s))
21
21
  return null;
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);
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);
25
25
  }, a = e.length === 4 || e.length === 8;
26
26
  return {
27
27
  r: n(0),
@@ -30,29 +30,29 @@ function jt(o) {
30
30
  a: a ? n(3) / 255 : 1
31
31
  };
32
32
  }
33
- function Ga(o) {
34
- return typeof o != "object" || o === null || !("hex" in o) ? null : o;
33
+ function Ba(s) {
34
+ return typeof s != "object" || s === null || !("hex" in s) ? null : s;
35
35
  }
36
- function Vt(o) {
37
- if (o == null)
36
+ function Xt(s) {
37
+ if (s == null)
38
38
  return null;
39
- if (typeof o == "object")
40
- return Xe(o);
41
- const e = jt(o);
39
+ if (typeof s == "object")
40
+ return at(s);
41
+ const e = Jt(s);
42
42
  if (e !== null)
43
- return Xe(e);
43
+ return at(e);
44
44
  try {
45
- const t = rt(o);
46
- return t === void 0 ? null : Vt(t);
45
+ const t = ut(s);
46
+ return t === void 0 ? null : Xt(t);
47
47
  } catch {
48
48
  return null;
49
49
  }
50
50
  }
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))}` };
51
+ function at(s) {
52
+ const e = Xe(s.r), t = Xe(s.g), n = Xe(s.b), a = Number.isFinite(s.a) ? Math.max(0, Math.min(1, s.a)) : 1, i = `#${je(e)}${je(t)}${je(n)}`;
53
+ return { r: e, g: t, b: n, a, hex: a === 1 ? i : `${i}${je(Math.round(a * 255))}` };
54
54
  }
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 = {
55
+ const Qt = gt.options, At = mt.options, nt = pt.options, _t = "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.", Ve = '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`.', it = "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.", Ue = {
56
56
  "node.color": {
57
57
  channel: "node.color",
58
58
  target: "node",
@@ -75,7 +75,7 @@ const qt = dt.options, At = lt.options, Je = ct.options, Bt = "An outline has a
75
75
  target: "node",
76
76
  plainName: "Node Shape",
77
77
  accepts: "enum",
78
- values: qt,
78
+ values: Qt,
79
79
  stylePath: "shape.type",
80
80
  renderable: !0
81
81
  },
@@ -102,7 +102,7 @@ const qt = dt.options, At = lt.options, Je = ct.options, Bt = "An outline has a
102
102
  accepts: "text",
103
103
  stylePath: "tooltip.text",
104
104
  renderable: !0,
105
- caveat: Qe
105
+ caveat: it
106
106
  },
107
107
  "node.tooltipStyle": {
108
108
  channel: "node.tooltipStyle",
@@ -111,7 +111,7 @@ const qt = dt.options, At = lt.options, Je = ct.options, Bt = "An outline has a
111
111
  accepts: "labelStyle",
112
112
  stylePath: "tooltip",
113
113
  renderable: !0,
114
- caveat: Qe
114
+ caveat: it
115
115
  },
116
116
  "node.opacity": {
117
117
  channel: "node.opacity",
@@ -130,7 +130,7 @@ const qt = dt.options, At = lt.options, Je = ct.options, Bt = "An outline has a
130
130
  accepts: "color",
131
131
  stylePath: "effect.outline.color",
132
132
  renderable: !0,
133
- caveat: Bt
133
+ caveat: _t
134
134
  },
135
135
  "node.glow": {
136
136
  channel: "node.glow",
@@ -234,7 +234,7 @@ const qt = dt.options, At = lt.options, Je = ct.options, Bt = "An outline has a
234
234
  target: "edge",
235
235
  plainName: "Arrow Head",
236
236
  accepts: "enum",
237
- values: Je,
237
+ values: nt,
238
238
  stylePath: "arrowHead.type",
239
239
  renderable: !0
240
240
  },
@@ -272,7 +272,7 @@ const qt = dt.options, At = lt.options, Je = ct.options, Bt = "An outline has a
272
272
  accepts: "text",
273
273
  stylePath: "arrowHead.text.text",
274
274
  renderable: !0,
275
- caveat: se
275
+ caveat: Ve
276
276
  },
277
277
  "edge.arrowHeadTextStyle": {
278
278
  channel: "edge.arrowHeadTextStyle",
@@ -281,14 +281,14 @@ const qt = dt.options, At = lt.options, Je = ct.options, Bt = "An outline has a
281
281
  accepts: "labelStyle",
282
282
  stylePath: "arrowHead.text",
283
283
  renderable: !0,
284
- caveat: se
284
+ caveat: Ve
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: Je,
291
+ values: nt,
292
292
  stylePath: "arrowTail.type",
293
293
  renderable: !0
294
294
  },
@@ -326,7 +326,7 @@ const qt = dt.options, At = lt.options, Je = ct.options, Bt = "An outline has a
326
326
  accepts: "text",
327
327
  stylePath: "arrowTail.text.text",
328
328
  renderable: !0,
329
- caveat: se
329
+ caveat: Ve
330
330
  },
331
331
  "edge.arrowTailTextStyle": {
332
332
  channel: "edge.arrowTailTextStyle",
@@ -335,7 +335,7 @@ const qt = dt.options, At = lt.options, Je = ct.options, Bt = "An outline has a
335
335
  accepts: "labelStyle",
336
336
  stylePath: "arrowTail.text",
337
337
  renderable: !0,
338
- caveat: se
338
+ caveat: Ve
339
339
  },
340
340
  "edge.animationSpeed": {
341
341
  channel: "edge.animationSpeed",
@@ -362,22 +362,22 @@ const qt = dt.options, At = lt.options, Je = ct.options, Bt = "An outline has a
362
362
  stylePath: "label",
363
363
  renderable: !0
364
364
  }
365
- }, it = Object.keys(ae);
366
- it.filter(
367
- (o) => ae[o].accepts === "color"
365
+ }, dt = Object.keys(Ue);
366
+ dt.filter(
367
+ (s) => Ue[s].accepts === "color"
368
368
  );
369
- function Yt(o) {
370
- return typeof o == "string" && Object.hasOwn(ae, o);
369
+ function ea(s) {
370
+ return typeof s == "string" && Object.hasOwn(Ue, s);
371
371
  }
372
- function Ha(o) {
373
- return Yt(o) ? ae[o] : void 0;
372
+ function Ya(s) {
373
+ return ea(s) ? Ue[s] : void 0;
374
374
  }
375
- function Wa(o) {
376
- return it.map((e) => ae[e]).filter(
377
- (e) => e.target === o
375
+ function Za(s) {
376
+ return dt.map((e) => Ue[e]).filter(
377
+ (e) => e.target === s
378
378
  );
379
379
  }
380
- const st = Object.freeze([
380
+ const lt = Object.freeze([
381
381
  {
382
382
  id: "fitToGraph",
383
383
  plainName: "Fit to graph",
@@ -414,41 +414,41 @@ const st = Object.freeze([
414
414
  options: []
415
415
  }
416
416
  ]);
417
- function Ka(o) {
418
- return st.find((e) => e.id === o) ?? ht(o)?.descriptor;
417
+ function Ja(s) {
418
+ return lt.find((e) => e.id === s) ?? ft(s)?.descriptor;
419
419
  }
420
- function La(o) {
421
- return [...st, ...ut()].filter(
422
- (e) => e.modes.includes(o)
420
+ function Xa(s) {
421
+ return [...lt, ...yt()].filter(
422
+ (e) => e.modes.includes(s)
423
423
  );
424
424
  }
425
- function Ua(o) {
426
- return o;
425
+ function Qa(s) {
426
+ return s;
427
427
  }
428
- function Zt(o) {
428
+ function ta(s) {
429
429
  const e = {};
430
- for (const [t, n] of Object.entries(o))
430
+ for (const [t, n] of Object.entries(s))
431
431
  e[t] = n.schema;
432
432
  return c.object(e);
433
433
  }
434
- function Xt(o, e) {
435
- return Zt(o).parse(e);
434
+ function aa(s, e) {
435
+ return ta(s).parse(e);
436
436
  }
437
- function T(o, e) {
438
- return `${String(o)}:${String(e)}`;
437
+ function P(s, e) {
438
+ return `${String(s)}:${String(e)}`;
439
439
  }
440
- function ce(o, e, t, n) {
440
+ function Ye(s, e, t, n) {
441
441
  const a = String(t);
442
442
  if (!n.some((i) => String(i) === a))
443
- throw new nt({
443
+ throw new ct({
444
444
  code: "E_OPTION_RANGE",
445
445
  source: "run",
446
- message: `${o}: the ${e} option names node "${a}", which is not in the graph.`,
447
- details: { algorithm: o, option: e, value: t }
446
+ message: `${s}: the ${e} option names node "${a}", which is not in the graph.`,
447
+ details: { algorithm: s, option: e, value: t }
448
448
  });
449
449
  return a;
450
450
  }
451
- const Jt = {
451
+ const na = {
452
452
  source: {
453
453
  schema: c.union([c.string(), c.number()]).nullable().default(null),
454
454
  meta: {
@@ -463,7 +463,7 @@ const Jt = {
463
463
  description: "Destination node for shortest path (uses last node if not set)"
464
464
  }
465
465
  }
466
- }, W = class W extends z {
466
+ }, V = class V extends E {
467
467
  constructor() {
468
468
  super(...arguments), this.legacyOptions = null;
469
469
  }
@@ -489,46 +489,46 @@ const Jt = {
489
489
  * @returns The route, or null when there are no nodes to search.
490
490
  */
491
491
  async compute(e) {
492
- const t = this.graph.getDataManager(), n = Array.from(t.nodes.keys());
492
+ const t = this.input("undirected"), n = R(t);
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], s = 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], o = this.algorithmGraph("undirected");
496
496
  e.report({ phase: "Relaxing edges", total: null });
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())
497
+ const r = kt(o, a), d = this.reconstructPath(r.predecessors, a, i), h = /* @__PURE__ */ new Map();
498
+ d.forEach((f, M) => h.set(f, M));
499
+ for (const f of r.distances.values())
500
500
  ;
501
- const m = [];
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 } });
501
+ const u = [];
502
+ await S(e, "Marking the route", n, (f) => {
503
+ const M = h.get(f), b = r.distances.get(f) ?? 1 / 0;
504
+ u.push({ id: f, values: { onPath: M !== void 0, order: M, distance: b } });
505
505
  });
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) } });
506
+ const l = this.getPathEdges(d), p = [];
507
+ await S(e, "Marking the route", ie(t), (f) => {
508
+ const M = P(f.source, f.target), b = P(f.target, f.source);
509
+ p.push({ id: f.id, values: { onPath: l.has(M) || l.has(b) } });
510
510
  });
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."), {
511
+ const m = [`Route from ${String(a)} to ${String(i)}.`];
512
+ return r.hasNegativeCycle && m.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
- ...tt,
515
+ ...rt,
516
516
  { name: "distance", kind: "node", type: "number" },
517
517
  { name: "hasNegativeCycle", kind: "graph", type: "boolean" }
518
518
  ],
519
- nodes: m,
519
+ nodes: u,
520
520
  edges: p,
521
521
  graph: {
522
- length: l.length,
523
- cost: l.length > 0 ? r.distances.get(i) ?? 0 : 0,
524
- hops: Math.max(l.length - 1, 0),
522
+ length: d.length,
523
+ cost: d.length > 0 ? r.distances.get(i) ?? 0 : 0,
524
+ hops: Math.max(d.length - 1, 0),
525
525
  hasNegativeCycle: r.hasNegativeCycle
526
526
  },
527
- caveats: M({
527
+ caveats: C({
528
528
  method: "bellman-ford",
529
529
  direction: "undirected",
530
530
  weight: { attribute: "weight", meaning: "distance" },
531
- notes: u
531
+ notes: m
532
532
  })
533
533
  };
534
534
  }
@@ -554,11 +554,11 @@ const Jt = {
554
554
  getPathEdges(e) {
555
555
  const t = /* @__PURE__ */ new Set();
556
556
  for (let n = 0; n < e.length - 1; n++)
557
- t.add(T(e[n], e[n + 1]));
557
+ t.add(P(e[n], e[n + 1]));
558
558
  return t;
559
559
  }
560
560
  };
561
- W.namespace = "graphty", W.type = "bellman-ford", W.zodOptionsSchema = Jt, W.optionsSchema = {
561
+ V.namespace = "graphty", V.type = "bellman-ford", V.scopeInput = "subgraph", V.zodOptionsSchema = na, V.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 le = W;
578
- v.register(le);
579
- const Qt = 2048;
580
- function _t(o) {
577
+ let ye = V;
578
+ v.register(ye);
579
+ const ia = 2048;
580
+ function sa(s) {
581
581
  return {
582
- runId: o,
582
+ runId: s,
583
583
  signal: new AbortController().signal,
584
584
  report: () => {
585
585
  },
@@ -588,14 +588,14 @@ function _t(o) {
588
588
  })
589
589
  };
590
590
  }
591
- async function D(o, e, t, n) {
592
- const a = o.length;
591
+ async function W(s, e, t, n) {
592
+ const a = s.length;
593
593
  let 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()));
594
+ for (let o = 0; o < a; o++)
595
+ e.signal.throwIfAborted(), n(s[o], o), (o + 1) % ia === 0 && o + 1 < a && (e.report({ phase: t, completed: o + 1, total: a }), performance.now() - i >= bt && (await e.yieldNow(), i = performance.now()));
596
596
  e.report({ phase: t, completed: a, total: a });
597
597
  }
598
- class G extends v {
598
+ class j 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 v {
615
615
  * @returns A promise that settles once the result has been published.
616
616
  */
617
617
  async run() {
618
- await this.measureRun(_t(this.type));
618
+ await this.measureRun(sa(this.type));
619
619
  }
620
620
  /**
621
621
  * Measure the graph on behalf of a run, and hand the result back.
@@ -639,36 +639,38 @@ class G extends v {
639
639
  * `DOMException` named `AbortError`.
640
640
  */
641
641
  async measureRun(e) {
642
- const t = this.graph.getDataManager(), n = Array.from(t.nodes.keys());
642
+ const t = this.input("declared"), n = R(t);
643
643
  if (n.length === 0)
644
644
  return;
645
- const a = Date.now(), i = await this.measure(e, n), s = mt(this.graph), r = gt({
646
- ...s === void 0 ? {} : { labelOf: s },
647
- runId: e.runId,
648
- shape: "node-metric",
649
- fields: this.resultFields(),
650
- measured: { nodes: n.length, edges: t.edges.size },
651
- // The only graph-level field a metric publishes itself. Everything else the shape
652
- // promises -- the range, the average, how many elements were measured, how many sit at
653
- // the bottom -- is computed from the column the measurement produced.
654
- graph: { normalization: i.normalization },
655
- nodes: i.nodes,
656
- caveats: i.caveats,
657
- durationMs: Date.now() - a
658
- });
645
+ const a = Date.now(), i = await this.measure(e, n), o = wt(this.graph), r = vt(
646
+ Nt(this, {
647
+ ...o === void 0 ? {} : { labelOf: o },
648
+ runId: e.runId,
649
+ shape: "node-metric",
650
+ fields: this.resultFields(),
651
+ measured: { nodes: t.nodeCount, edges: t.edgeCount },
652
+ // The only graph-level field a metric publishes itself. Everything else the shape
653
+ // promises -- the range, the average, how many elements were measured, how many sit at
654
+ // the bottom -- is computed from the column the measurement produced.
655
+ graph: { normalization: i.normalization },
656
+ nodes: i.nodes,
657
+ caveats: i.caveats,
658
+ durationMs: Date.now() - a
659
+ })
660
+ );
659
661
  return this.#e = r, r;
660
662
  }
661
663
  }
662
- const ea = $({
664
+ const oa = U({
663
665
  plainName: "Bridging",
664
666
  technicalName: "betweenness"
665
- }), Re = class Re extends G {
667
+ }), ce = class ce extends j {
666
668
  /**
667
669
  * The fields a betweenness result publishes.
668
670
  * @returns The uniform node-metric fields.
669
671
  */
670
672
  resultFields() {
671
- return ea;
673
+ return oa;
672
674
  }
673
675
  /**
674
676
  * Score every node by the shortest paths that run through it.
@@ -684,12 +686,12 @@ const ea = $({
684
686
  total: t.length,
685
687
  message: "Brandes runs a breadth-first search from every node."
686
688
  });
687
- const a = yt(n);
689
+ const a = St(n);
688
690
  e.signal.throwIfAborted();
689
691
  const i = [];
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 } });
692
+ return await W(t, e, "reading scores", (o) => {
693
+ const r = a[String(o)];
694
+ i.push({ id: o, values: r === void 0 ? {} : { value: r } });
693
695
  }), {
694
696
  nodes: i,
695
697
  // Raw counts. `options.normalized` is not set, so nothing rescales them.
@@ -709,10 +711,10 @@ const ea = $({
709
711
  };
710
712
  }
711
713
  };
712
- Re.namespace = "graphty", Re.type = "betweenness";
713
- let de = Re;
714
- v.register(de);
715
- const ta = {
714
+ ce.namespace = "graphty", ce.type = "betweenness", ce.scopeInput = "subgraph";
715
+ let be = ce;
716
+ v.register(be);
717
+ const ra = {
716
718
  source: {
717
719
  schema: c.union([c.string(), c.number()]).nullable().default(null),
718
720
  meta: {
@@ -728,7 +730,7 @@ const ta = {
728
730
  advanced: !0
729
731
  }
730
732
  }
731
- }, K = class K extends z {
733
+ }, q = class q extends E {
732
734
  constructor() {
733
735
  super(...arguments), this.legacyOptions = null;
734
736
  }
@@ -754,34 +756,31 @@ const ta = {
754
756
  * @returns The layered result, or null when there is nothing to walk.
755
757
  */
756
758
  async compute(e) {
757
- const t = Array.from(this.graph.getDataManager().nodes.keys());
759
+ const t = R(this.input("undirected"));
758
760
  if (t.length === 0)
759
761
  return null;
760
- const n = this._schemaOptions.targetNode ?? void 0, a = this.graph.getDataManager().getSnapshot();
761
- if (a.nodeCount === 0)
762
- return null;
763
- const i = this.legacyOptions?.source ?? this._schemaOptions.source ?? a.ids.idOf(0);
762
+ const n = this._schemaOptions.targetNode ?? void 0, a = this.legacyOptions?.source ?? this._schemaOptions.source ?? t[0];
764
763
  if (n !== void 0)
765
- return this.legacyWalk(e, t, i, n);
766
- const { snapshot: s, run: r } = this.accelerated("breadthFirstSearch", "undirected"), l = this.nodeIndex(s, "source", i);
764
+ return this.legacyWalk(e, t, a, n);
765
+ const { snapshot: i, run: o } = this.accelerated("breadthFirstSearch", "undirected"), r = this.nodeIndex(i, "source", a);
767
766
  e.report({ phase: "Walking outwards", total: null });
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) } });
767
+ const { value: d, precision: h } = await o((p, m) => p.breadthFirstSearch(m, r)), u = /* @__PURE__ */ new Map();
768
+ for (let p = 0; p < d.visitedCount; p++)
769
+ u.set(d.order[p], p);
770
+ const l = [];
771
+ return await S(e, "Recording levels", t, (p) => {
772
+ const m = i.ids.indexOf(p), f = m === L ? L : d.depth[m];
773
+ f !== L && l.push({ id: p, values: { level: f, order: u.get(m) } });
775
774
  }), {
776
775
  shape: "layered-grouping",
777
- fields: [...Ze, { name: "order", kind: "node", type: "integer" }],
778
- nodes: p,
779
- caveats: M({
776
+ fields: [...et, { name: "order", kind: "node", type: "integer" }],
777
+ nodes: l,
778
+ caveats: C({
780
779
  method: "bfs",
781
780
  direction: "undirected",
782
781
  weight: null,
783
- precision: m,
784
- notes: [`Walked outwards from ${String(i)}, which is level 0.`]
782
+ precision: h,
783
+ notes: [`Walked outwards from ${String(a)}, which is level 0.`]
785
784
  })
786
785
  };
787
786
  }
@@ -797,28 +796,28 @@ const ta = {
797
796
  const i = this.algorithmGraph("undirected");
798
797
  if (!i.hasNode(n))
799
798
  return null;
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, {
799
+ const o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
800
+ let d = !1;
801
+ e.report({ phase: "Walking outwards", total: null }), Ot(i, n, {
803
802
  targetNode: a,
804
- visitCallback: (d, p) => {
805
- s.set(d, p), r.set(d, r.size), d === a && (l = !0);
803
+ visitCallback: (l, p) => {
804
+ o.set(l, p), r.set(l, r.size), l === a && (d = !0);
806
805
  }
807
806
  });
808
807
  const h = [];
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) } });
808
+ return await S(e, "Recording levels", t, (l) => {
809
+ const p = o.get(l);
810
+ p !== void 0 && h.push({ id: l, values: { level: p, order: r.get(l) } });
812
811
  }), {
813
812
  shape: "layered-grouping",
814
813
  fields: [
815
- ...Ze,
814
+ ...et,
816
815
  { name: "order", kind: "node", type: "integer" },
817
816
  { name: "targetFound", kind: "graph", type: "boolean" }
818
817
  ],
819
818
  nodes: h,
820
- graph: { targetFound: l },
821
- caveats: M({
819
+ graph: { targetFound: d },
820
+ caveats: C({
822
821
  method: "bfs",
823
822
  direction: "undirected",
824
823
  weight: null,
@@ -830,7 +829,7 @@ const ta = {
830
829
  };
831
830
  }
832
831
  };
833
- K.namespace = "graphty", K.type = "bfs", K.zodOptionsSchema = ta, K.optionsSchema = {
832
+ q.namespace = "graphty", q.type = "bfs", q.scopeInput = "subgraph", q.zodOptionsSchema = ra, q.optionsSchema = {
834
833
  source: {
835
834
  type: "nodeId",
836
835
  default: null,
@@ -847,9 +846,9 @@ K.namespace = "graphty", K.type = "bfs", K.zodOptionsSchema = ta, K.optionsSchem
847
846
  advanced: !0
848
847
  }
849
848
  };
850
- let he = K;
851
- v.register(he);
852
- const Fe = class Fe extends z {
849
+ let we = q;
850
+ v.register(we);
851
+ const de = class de extends E {
853
852
  /**
854
853
  * Pair up the two sides of a two-sided graph so that as many nodes as possible get a partner.
855
854
  *
@@ -861,26 +860,26 @@ const Fe = class Fe extends z {
861
860
  * @returns The edge set, or null when there are no edges to pair.
862
861
  */
863
862
  async compute(e) {
864
- const t = Array.from(this.graph.getDataManager().edges.values());
863
+ const t = ie(this.input("undirected"));
865
864
  if (t.length === 0)
866
865
  return null;
867
866
  const n = this.algorithmGraph("undirected"), a = [
868
- ...je("edge", { name: "bipartite", type: "boolean" }),
867
+ ...Ze("edge", { name: "bipartite", type: "boolean" }),
869
868
  { name: "side", kind: "node", type: "string" },
870
869
  { name: "matched", kind: "node", type: "boolean" }
871
870
  ];
872
871
  e.report({ phase: "Checking for two sides", total: null });
873
- const i = wt(n);
872
+ const i = xt(n);
874
873
  if (i === null) {
875
- const d = [];
874
+ const l = [];
876
875
  return await S(e, "Marking the pairing", t, (p) => {
877
- d.push({ id: p.id, values: { in: !1 } });
876
+ l.push({ id: p.id, values: { in: !1 } });
878
877
  }), {
879
878
  shape: "edge-set",
880
879
  fields: a,
881
- edges: d,
880
+ edges: l,
882
881
  graph: { bipartite: !1 },
883
- caveats: M({
882
+ caveats: C({
884
883
  method: "bipartite-matching",
885
884
  direction: "undirected",
886
885
  weight: null,
@@ -889,49 +888,49 @@ const Fe = class Fe extends z {
889
888
  };
890
889
  }
891
890
  e.report({ phase: "Pairing nodes", total: null });
892
- const s = vt(n, {
891
+ const o = It(n, {
893
892
  leftNodes: i.left,
894
893
  rightNodes: i.right
895
894
  }), r = /* @__PURE__ */ new Set();
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)) } });
895
+ for (const [l, p] of o.matching)
896
+ r.add(P(l, p)), r.add(P(p, l));
897
+ const d = [];
898
+ await S(e, "Marking the pairing", t, (l) => {
899
+ d.push({ id: l.id, values: { in: r.has(P(l.source, l.target)) } });
901
900
  });
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) } });
901
+ const h = new Set(o.matching.values()), u = [];
902
+ return await S(e, "Marking sides", Array.from(i.left), (l) => {
903
+ u.push({ id: l, values: { side: "left", matched: o.matching.has(l) } });
904
+ }), await S(e, "Marking sides", Array.from(i.right), (l) => {
905
+ u.push({ id: l, values: { side: "right", matched: h.has(l) } });
907
906
  }), {
908
907
  shape: "edge-set",
909
908
  fields: a,
910
- nodes: m,
911
- edges: l,
909
+ nodes: u,
910
+ edges: d,
912
911
  graph: { bipartite: !0 },
913
- caveats: M({
912
+ caveats: C({
914
913
  method: "bipartite-matching",
915
914
  direction: "undirected",
916
915
  weight: null,
917
- notes: [`${String(s.size)} of the two sides' nodes found a partner.`]
916
+ notes: [`${String(o.size)} of the two sides' nodes found a partner.`]
918
917
  })
919
918
  };
920
919
  }
921
920
  };
922
- Fe.namespace = "graphty", Fe.type = "bipartite-matching";
923
- let ue = Fe;
924
- v.register(ue);
925
- const aa = $({
921
+ de.namespace = "graphty", de.type = "bipartite-matching", de.scopeInput = "subgraph";
922
+ let ve = de;
923
+ v.register(ve);
924
+ const ca = U({
926
925
  plainName: "Reach",
927
926
  technicalName: "closeness"
928
- }), $e = class $e extends G {
927
+ }), le = class le extends j {
929
928
  /**
930
929
  * The fields a closeness result publishes.
931
930
  * @returns The uniform node-metric fields.
932
931
  */
933
932
  resultFields() {
934
- return aa;
933
+ return ca;
935
934
  }
936
935
  /**
937
936
  * Score every node by how short its paths to the rest of the graph are.
@@ -947,12 +946,12 @@ const aa = $({
947
946
  total: t.length,
948
947
  message: "A breadth-first search runs from every node."
949
948
  });
950
- const a = Nt(n);
949
+ const a = Ct(n);
951
950
  e.signal.throwIfAborted();
952
951
  const i = [];
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 } });
952
+ return await W(t, e, "reading scores", (o) => {
953
+ const r = a[String(o)];
954
+ i.push({ id: o, values: r === void 0 ? {} : { value: r } });
956
955
  }), {
957
956
  nodes: i,
958
957
  // The algorithm's own figure, published as it was computed.
@@ -972,10 +971,10 @@ const aa = $({
972
971
  };
973
972
  }
974
973
  };
975
- $e.namespace = "graphty", $e.type = "closeness";
976
- let pe = $e;
977
- v.register(pe);
978
- const Ge = class Ge extends z {
974
+ le.namespace = "graphty", le.type = "closeness", le.scopeInput = "subgraph";
975
+ let Ne = le;
976
+ v.register(Ne);
977
+ const he = class he extends E {
979
978
  /**
980
979
  * Find the separate pieces of the graph.
981
980
  *
@@ -986,20 +985,20 @@ const Ge = class Ge extends z {
986
985
  * @returns The community result, or null when there are no nodes to group.
987
986
  */
988
987
  async compute(e) {
989
- const t = Array.from(this.graph.getDataManager().nodes.keys());
988
+ const t = R(this.input("undirected"));
990
989
  if (t.length === 0)
991
990
  return null;
992
991
  const { snapshot: n, run: a } = this.accelerated("connectedComponents", "undirected"), { ids: i } = n;
993
992
  e.report({ phase: "Finding pieces", total: null });
994
- const { value: s, precision: r } = await a((h, m) => h.connectedComponents(m)), l = [];
993
+ const { value: o, precision: r } = await a((h, u) => h.connectedComponents(u)), d = [];
995
994
  return await S(e, "Grouping nodes", t, (h) => {
996
- const m = i.indexOf(h);
997
- l.push({ id: h, values: { group: s.labels[m] ?? 0 } });
995
+ const u = i.indexOf(h);
996
+ d.push({ id: h, values: { group: o.labels[u] ?? 0 } });
998
997
  }), {
999
998
  shape: "community",
1000
- fields: ee(!1),
1001
- nodes: l,
1002
- caveats: M({
999
+ fields: oe(!1),
1000
+ nodes: d,
1001
+ caveats: C({
1003
1002
  method: "connected-components",
1004
1003
  direction: "undirected",
1005
1004
  weight: null,
@@ -1009,32 +1008,32 @@ const Ge = class Ge extends z {
1009
1008
  };
1010
1009
  }
1011
1010
  };
1012
- Ge.namespace = "graphty", Ge.type = "connected-components";
1013
- let me = Ge;
1014
- v.register(me);
1015
- const na = [
1016
- ...$({ plainName: "Connections", technicalName: "degree", type: "integer", unit: "links" }),
1017
- re({
1011
+ he.namespace = "graphty", he.type = "connected-components", he.scopeInput = "subgraph";
1012
+ let ke = he;
1013
+ v.register(ke);
1014
+ const da = [
1015
+ ...U({ plainName: "Connections", technicalName: "degree", type: "integer", unit: "links" }),
1016
+ Be({
1018
1017
  name: "inDegree",
1019
1018
  plainName: "Incoming connections",
1020
1019
  technicalName: "inDegree",
1021
1020
  kind: "node",
1022
1021
  type: "integer"
1023
1022
  }),
1024
- re({
1023
+ Be({
1025
1024
  name: "outDegree",
1026
1025
  plainName: "Outgoing connections",
1027
1026
  technicalName: "outDegree",
1028
1027
  kind: "node",
1029
1028
  type: "integer"
1030
1029
  })
1031
- ], He = class He extends G {
1030
+ ], ue = class ue extends j {
1032
1031
  /**
1033
1032
  * The fields a degree result publishes.
1034
1033
  * @returns The uniform node-metric fields, plus `inDegree` and `outDegree`.
1035
1034
  */
1036
1035
  resultFields() {
1037
- return na;
1036
+ return da;
1038
1037
  }
1039
1038
  /**
1040
1039
  * Count every node's edges.
@@ -1044,9 +1043,9 @@ const na = [
1044
1043
  */
1045
1044
  async measure(e, t) {
1046
1045
  const n = this.algorithmGraph("directed"), a = [];
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 } });
1046
+ return await W(t, e, "counting connections", (i) => {
1047
+ const o = n.inDegree(i), r = n.outDegree(i);
1048
+ a.push({ id: i, values: { value: o + r, inDegree: o, outDegree: r } });
1050
1049
  }), {
1051
1050
  nodes: a,
1052
1051
  // A count of edges, published as it was counted.
@@ -1057,15 +1056,17 @@ const na = [
1057
1056
  weight: null,
1058
1057
  precision: "f64",
1059
1058
  method: "degree",
1060
- notes: ["Counted over the graph as the records declared it, so a node's total is its incoming edges plus its outgoing ones."]
1059
+ notes: [
1060
+ "Counted over the graph as the records declared it, so a node's total is its incoming edges plus its outgoing ones."
1061
+ ]
1061
1062
  }
1062
1063
  };
1063
1064
  }
1064
1065
  };
1065
- He.namespace = "graphty", He.type = "degree";
1066
- let ge = He;
1067
- v.register(ge);
1068
- const ia = {
1066
+ ue.namespace = "graphty", ue.type = "degree", ue.scopeInput = "subgraph";
1067
+ let Se = ue;
1068
+ v.register(Se);
1069
+ const la = {
1069
1070
  source: {
1070
1071
  schema: c.union([c.string(), c.number()]).nullable().default(null),
1071
1072
  meta: {
@@ -1097,7 +1098,7 @@ const ia = {
1097
1098
  advanced: !0
1098
1099
  }
1099
1100
  }
1100
- }, L = class L extends z {
1101
+ }, B = class B extends E {
1101
1102
  constructor() {
1102
1103
  super(...arguments), this.legacyOptions = null;
1103
1104
  }
@@ -1122,38 +1123,40 @@ const ia = {
1122
1123
  * @returns The exploration order, or null when there is nothing to walk.
1123
1124
  */
1124
1125
  async compute(e) {
1125
- const t = this.graph.getDataManager(), n = Array.from(t.nodes.keys());
1126
- if (n.length === 0)
1126
+ const t = R(this.input("undirected"));
1127
+ if (t.length === 0)
1127
1128
  return null;
1128
- const a = this.legacyOptions?.source ?? this._schemaOptions.source ?? n[0], { targetNode: i, recursive: s, preOrder: r } = this._schemaOptions;
1129
- if (!t.nodes.has(a))
1129
+ const n = this.legacyOptions?.source ?? this._schemaOptions.source ?? t[0], { targetNode: a, recursive: i, preOrder: o } = this._schemaOptions;
1130
+ if (!t.includes(n))
1130
1131
  return null;
1131
- const l = this.algorithmGraph("undirected");
1132
+ const r = this.algorithmGraph("undirected");
1132
1133
  e.report({ phase: "Walking deep", total: null });
1133
- const h = kt(l, a, {
1134
- targetNode: i ?? void 0,
1135
- recursive: s,
1136
- preOrder: r
1137
- }), m = /* @__PURE__ */ new Map();
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) } });
1134
+ const d = Tt(r, n, {
1135
+ targetNode: a ?? void 0,
1136
+ recursive: i,
1137
+ preOrder: o
1138
+ }), h = /* @__PURE__ */ new Map();
1139
+ d.order.forEach((l, p) => h.set(l, p));
1140
+ const u = [];
1141
+ return await S(e, "Recording the order", t, (l) => {
1142
+ const p = h.get(l);
1143
+ u.push({ id: l, values: { value: p, visited: d.visited.has(l) } });
1143
1144
  }), {
1144
1145
  shape: "node-metric",
1145
- fields: [...Be("node", "integer"), { name: "visited", kind: "node", type: "boolean" }],
1146
- nodes: d,
1147
- caveats: M({
1146
+ fields: [...Ae("node", "integer"), { name: "visited", kind: "node", type: "boolean" }],
1147
+ nodes: u,
1148
+ caveats: C({
1148
1149
  method: "dfs",
1149
1150
  direction: "undirected",
1150
1151
  weight: null,
1151
- notes: [`Walked from ${String(a)}, ${r ? "recording each node as it was reached" : "recording each node as it was left"}.`]
1152
+ notes: [
1153
+ `Walked from ${String(n)}, ${o ? "recording each node as it was reached" : "recording each node as it was left"}.`
1154
+ ]
1152
1155
  })
1153
1156
  };
1154
1157
  }
1155
1158
  };
1156
- L.namespace = "graphty", L.type = "dfs", L.zodOptionsSchema = ia, L.optionsSchema = {
1159
+ B.namespace = "graphty", B.type = "dfs", B.scopeInput = "subgraph", B.zodOptionsSchema = la, B.optionsSchema = {
1157
1160
  source: {
1158
1161
  type: "nodeId",
1159
1162
  default: null,
@@ -1184,9 +1187,9 @@ L.namespace = "graphty", L.type = "dfs", L.zodOptionsSchema = ia, L.optionsSchem
1184
1187
  advanced: !0
1185
1188
  }
1186
1189
  };
1187
- let fe = L;
1188
- v.register(fe);
1189
- const sa = {
1190
+ let Oe = B;
1191
+ v.register(Oe);
1192
+ const ha = {
1190
1193
  source: {
1191
1194
  schema: c.union([c.string(), c.number()]).nullable().default(null),
1192
1195
  meta: {
@@ -1209,7 +1212,7 @@ const sa = {
1209
1212
  advanced: !0
1210
1213
  }
1211
1214
  }
1212
- }, U = class U extends z {
1215
+ }, K = class K extends E {
1213
1216
  constructor() {
1214
1217
  super(...arguments), this.legacyOptions = null;
1215
1218
  }
@@ -1235,53 +1238,57 @@ const sa = {
1235
1238
  * @returns The route, or null when there are no nodes to search.
1236
1239
  */
1237
1240
  async compute(e) {
1238
- const t = this.graph.getDataManager(), n = Array.from(t.nodes.keys());
1241
+ const t = this.input("undirected"), n = R(t);
1239
1242
  if (n.length === 0)
1240
1243
  return null;
1241
- const { snapshot: a, edgeRemap: i, run: s } = this.accelerated("sssp", "undirected");
1242
- if (a.nodeCount === 0)
1243
- return null;
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);
1244
+ const { snapshot: a, edgeRemap: i, run: o } = this.accelerated("sssp", "undirected"), { 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), u = this.nodeIndex(a, "source", d), l = this.nodeIndex(a, "target", h);
1245
1245
  e.report({ phase: "Searching for the route", total: null });
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
- id: w,
1246
+ const { value: p, precision: m } = await o((N, z) => N.sssp(z, u)), f = p.pathTo(l), M = new Set(p.pathEdges(l)), b = /* @__PURE__ */ new Map();
1247
+ f.forEach((N, z) => b.set(N, z));
1248
+ const w = [];
1249
+ await S(e, "Marking the route", n, (N) => {
1250
+ const z = r.indexOf(N), y = z === L ? void 0 : b.get(z);
1251
+ w.push({
1252
+ id: N,
1253
1253
  values: {
1254
- onPath: b !== void 0,
1255
- order: b,
1256
- distance: N === F ? 1 / 0 : p.dist[N]
1254
+ onPath: y !== void 0,
1255
+ order: y,
1256
+ distance: z === L ? 1 / 0 : p.dist[z]
1257
1257
  }
1258
1258
  });
1259
1259
  });
1260
- const I = [];
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) } });
1260
+ const O = ie(t), { src: I, weights: x } = t.graph.edgeList(), T = /* @__PURE__ */ new Map();
1261
+ for (const N of O) {
1262
+ const z = i === null ? N.row : i[N.row] ?? L;
1263
+ if (!M.has(z))
1264
+ continue;
1265
+ const y = t.graph.directed ? `${String(z)}>${String(I[N.row])}` : String(z), $ = x === null ? 1 : x[N.row], se = T.get(y);
1266
+ (se === void 0 || $ < se.weight) && T.set(y, { row: N.row, weight: $ });
1267
+ }
1268
+ const F = new Set([...T.values()].map((N) => N.row)), D = [];
1269
+ return await S(e, "Marking the route", O, (N) => {
1270
+ D.push({ id: N.id, values: { onPath: F.has(N.row) } });
1264
1271
  }), {
1265
1272
  shape: "path",
1266
- fields: [...tt, { name: "distance", kind: "node", type: "number" }],
1267
- nodes: O,
1268
- edges: I,
1273
+ fields: [...rt, { name: "distance", kind: "node", type: "number" }],
1274
+ nodes: w,
1275
+ edges: D,
1269
1276
  graph: {
1270
- length: g.length,
1271
- cost: g.length === 0 ? 0 : p.dist[d],
1272
- hops: Math.max(g.length - 1, 0)
1277
+ length: f.length,
1278
+ cost: f.length === 0 ? 0 : p.dist[l],
1279
+ hops: Math.max(f.length - 1, 0)
1273
1280
  },
1274
- caveats: M({
1281
+ caveats: C({
1275
1282
  method: "dijkstra",
1276
1283
  direction: "undirected",
1277
1284
  weight: { attribute: "weight", meaning: "distance" },
1278
- precision: u,
1279
- notes: g.length === 0 ? [`No route runs from ${String(l)} to ${String(h)}.`] : [`Route from ${String(l)} to ${String(h)}.`]
1285
+ precision: m,
1286
+ notes: f.length === 0 ? [`No route runs from ${String(d)} to ${String(h)}.`] : [`Route from ${String(d)} to ${String(h)}.`]
1280
1287
  })
1281
1288
  };
1282
1289
  }
1283
1290
  };
1284
- U.namespace = "graphty", U.type = "dijkstra", U.zodOptionsSchema = sa, U.optionsSchema = {
1291
+ K.namespace = "graphty", K.type = "dijkstra", K.scopeInput = "subgraph", K.parallelEdges = "min", K.zodOptionsSchema = ha, K.optionsSchema = {
1285
1292
  source: {
1286
1293
  type: "nodeId",
1287
1294
  default: null,
@@ -1304,9 +1311,9 @@ U.namespace = "graphty", U.type = "dijkstra", U.zodOptionsSchema = sa, U.options
1304
1311
  advanced: !0
1305
1312
  }
1306
1313
  };
1307
- let ye = U;
1308
- v.register(ye);
1309
- const oa = {
1314
+ let xe = K;
1315
+ v.register(xe);
1316
+ const ua = {
1310
1317
  maxIterations: {
1311
1318
  schema: c.number().int().min(1).max(1e4).default(1e3),
1312
1319
  meta: {
@@ -1347,16 +1354,16 @@ const oa = {
1347
1354
  advanced: !0
1348
1355
  }
1349
1356
  }
1350
- }, ra = $({
1357
+ }, pa = U({
1351
1358
  plainName: "Influence by association",
1352
1359
  technicalName: "eigenvector score"
1353
- }), R = class R extends G {
1360
+ }), H = class H extends j {
1354
1361
  /**
1355
1362
  * The fields an eigenvector result publishes.
1356
1363
  * @returns The uniform node-metric fields.
1357
1364
  */
1358
1365
  resultFields() {
1359
- return ra;
1366
+ return pa;
1360
1367
  }
1361
1368
  /**
1362
1369
  * Score every node by the influence of its neighbours.
@@ -1365,41 +1372,41 @@ const oa = {
1365
1372
  * @returns One score per node, scaled as the options asked for.
1366
1373
  */
1367
1374
  async measure(e, t) {
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");
1375
+ const { maxIterations: n, tolerance: a, normalized: i, mode: o, endpoints: r } = this.schemaOptions, d = this._schemaOptions.startVector ?? void 0, h = o !== "total" && this.input("declared").graph.directed, u = this.algorithmGraph(h ? "directed" : "undirected");
1369
1376
  e.report({
1370
1377
  phase: "iterating",
1371
1378
  completed: 0,
1372
1379
  total: t.length,
1373
1380
  message: `Power iteration, up to ${String(n)} passes.`
1374
1381
  });
1375
- let d;
1382
+ let l;
1376
1383
  try {
1377
- d = St(m, {
1384
+ l = zt(u, {
1378
1385
  normalized: i,
1379
1386
  maxIterations: n,
1380
1387
  tolerance: a,
1381
- mode: s,
1388
+ mode: o,
1382
1389
  endpoints: r,
1383
- startVector: l
1390
+ startVector: d
1384
1391
  });
1385
- } catch (u) {
1386
- if (!(u instanceof Ot))
1387
- throw u;
1388
- const g = `${R.namespace}:${R.type}`;
1389
- throw new nt({
1392
+ } catch (m) {
1393
+ if (!(m instanceof Et))
1394
+ throw m;
1395
+ const f = `${H.namespace}:${H.type}`;
1396
+ throw new ct({
1390
1397
  code: "E_NOT_CONVERGED",
1391
1398
  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
1399
  source: "run",
1393
1400
  target: { kind: "run", id: e.runId },
1394
- details: { algorithm: g, maxIterations: n, tolerance: a },
1395
- cause: u
1401
+ details: { algorithm: f, maxIterations: n, tolerance: a },
1402
+ cause: m
1396
1403
  });
1397
1404
  }
1398
1405
  e.signal.throwIfAborted();
1399
1406
  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 } });
1407
+ return await W(t, e, "reading scores", (m) => {
1408
+ const f = l[String(m)];
1409
+ p.push({ id: m, values: f === void 0 ? {} : { value: f } });
1403
1410
  }), {
1404
1411
  nodes: p,
1405
1412
  // With `normalized`, the algorithm rescales its eigenvector so the lowest score is 0
@@ -1417,7 +1424,7 @@ const oa = {
1417
1424
  notes: [
1418
1425
  `Power iteration reached a tolerance of ${String(a)} within ${String(n)} passes.`,
1419
1426
  ...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."
1427
+ o === "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
1428
  ] : [],
1422
1429
  "Edge weights are not read."
1423
1430
  ]
@@ -1425,7 +1432,7 @@ const oa = {
1425
1432
  };
1426
1433
  }
1427
1434
  };
1428
- R.namespace = "graphty", R.type = "eigenvector", R.zodOptionsSchema = oa, R.optionsSchema = {
1435
+ H.namespace = "graphty", H.type = "eigenvector", H.scopeInput = "subgraph", H.zodOptionsSchema = ua, H.optionsSchema = {
1429
1436
  maxIterations: {
1430
1437
  type: "integer",
1431
1438
  default: 1e3,
@@ -1472,9 +1479,9 @@ R.namespace = "graphty", R.type = "eigenvector", R.zodOptionsSchema = oa, R.opti
1472
1479
  }
1473
1480
  // Note: startVector is a Map type - programmatic only, not in schema
1474
1481
  };
1475
- let be = R;
1476
- v.register(be);
1477
- const We = class We extends z {
1482
+ let Ie = H;
1483
+ v.register(Ie);
1484
+ const pe = class pe extends E {
1478
1485
  /**
1479
1486
  * Measure the distance between every pair of nodes, and give each node the distance to the
1480
1487
  * node furthest from it.
@@ -1493,42 +1500,42 @@ const We = class We extends z {
1493
1500
  * @returns The all-pairs measurement, or null when there are no nodes to measure.
1494
1501
  */
1495
1502
  async compute(e) {
1496
- const t = Array.from(this.graph.getDataManager().nodes.keys());
1503
+ const t = R(this.input("undirected"));
1497
1504
  if (t.length === 0)
1498
1505
  return null;
1499
1506
  const n = this.algorithmGraph("undirected");
1500
1507
  e.report({ phase: "Measuring every pair", total: null });
1501
- const a = xt(n), i = /* @__PURE__ */ new Map();
1508
+ const a = Mt(n), i = /* @__PURE__ */ new Map();
1502
1509
  await S(e, "Measuring reach", t, (h) => {
1503
- const m = a.distances.get(h);
1504
- if (m === void 0) {
1510
+ const u = a.distances.get(h);
1511
+ if (u === void 0) {
1505
1512
  i.set(h, 1 / 0);
1506
1513
  return;
1507
1514
  }
1508
- let d = 0;
1509
- for (const p of m.values())
1510
- isFinite(p) && p > d && (d = p);
1511
- i.set(h, d);
1515
+ let l = 0;
1516
+ for (const p of u.values())
1517
+ isFinite(p) && p > l && (l = p);
1518
+ i.set(h, l);
1512
1519
  });
1513
- let s = 0, r = 1 / 0;
1520
+ let o = 0, r = 1 / 0;
1514
1521
  for (const h of i.values())
1515
- isFinite(h) && (s = Math.max(s, h), r = Math.min(r, h));
1522
+ isFinite(h) && (o = Math.max(o, h), r = Math.min(r, h));
1516
1523
  r === 1 / 0 && (r = 0);
1517
- const l = [];
1524
+ const d = [];
1518
1525
  return await S(e, "Publishing distances", t, (h) => {
1519
- const m = i.get(h) ?? 1 / 0;
1520
- isFinite(m) && l.push({ id: h, values: { value: m } });
1526
+ const u = i.get(h) ?? 1 / 0;
1527
+ isFinite(u) && d.push({ id: h, values: { value: u } });
1521
1528
  }), {
1522
1529
  shape: "node-metric",
1523
1530
  fields: [
1524
- ...Be("node"),
1531
+ ...Ae("node"),
1525
1532
  { name: "diameter", kind: "graph", type: "number" },
1526
1533
  { name: "radius", kind: "graph", type: "number" },
1527
1534
  { name: "hasNegativeCycle", kind: "graph", type: "boolean" }
1528
1535
  ],
1529
- nodes: l,
1530
- graph: { diameter: s, radius: r, hasNegativeCycle: a.hasNegativeCycle },
1531
- caveats: M({
1536
+ nodes: d,
1537
+ graph: { diameter: o, radius: r, hasNegativeCycle: a.hasNegativeCycle },
1538
+ caveats: C({
1532
1539
  method: "floyd-warshall",
1533
1540
  direction: "undirected",
1534
1541
  weight: { attribute: "weight", meaning: "distance" },
@@ -1539,10 +1546,10 @@ const We = class We extends z {
1539
1546
  };
1540
1547
  }
1541
1548
  };
1542
- We.namespace = "graphty", We.type = "floyd-warshall";
1543
- let we = We;
1544
- v.register(we);
1545
- const ca = {
1549
+ pe.namespace = "graphty", pe.type = "floyd-warshall", pe.scopeInput = "subgraph";
1550
+ let Ce = pe;
1551
+ v.register(Ce);
1552
+ const ma = {
1546
1553
  maxCommunities: {
1547
1554
  schema: c.number().int().min(0).max(100).default(0),
1548
1555
  meta: {
@@ -1566,7 +1573,7 @@ const ca = {
1566
1573
  advanced: !0
1567
1574
  }
1568
1575
  }
1569
- }, j = class j extends z {
1576
+ }, Y = class Y extends E {
1570
1577
  /**
1571
1578
  * Group the nodes into communities by cutting the edges the most routes run through.
1572
1579
  *
@@ -1577,43 +1584,43 @@ const ca = {
1577
1584
  * @returns The community result, or null when there are no nodes to group.
1578
1585
  */
1579
1586
  async compute(e) {
1580
- const t = Array.from(this.graph.getDataManager().nodes.keys());
1587
+ const t = R(this.input("undirected"));
1581
1588
  if (t.length === 0)
1582
1589
  return null;
1583
- const { maxCommunities: n, minCommunitySize: a, maxIterations: i } = this.schemaOptions, s = this.algorithmGraph("undirected");
1590
+ const { maxCommunities: n, minCommunitySize: a, maxIterations: i } = this.schemaOptions, o = this.algorithmGraph("undirected");
1584
1591
  e.report({ phase: "Cutting bridges", total: null });
1585
- const r = It(s, {
1592
+ const r = Dt(o, {
1586
1593
  maxCommunities: n > 0 ? n : void 0,
1587
1594
  minCommunitySize: a,
1588
1595
  maxIterations: i
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,
1596
+ }), d = n > 0 ? r.filter((m) => m.communities.length <= n) : r, u = (d.length > 0 ? d : r.slice(0, 1)).reduce(
1597
+ (m, f) => m === void 0 || f.modularity > m.modularity ? f : m,
1591
1598
  void 0
1592
- ), d = /* @__PURE__ */ new Map();
1593
- if (m !== void 0)
1594
- for (let u = 0; u < m.communities.length; u++)
1595
- for (const g of m.communities[u])
1596
- d.set(g, u);
1599
+ ), l = /* @__PURE__ */ new Map();
1600
+ if (u !== void 0)
1601
+ for (let m = 0; m < u.communities.length; m++)
1602
+ for (const f of u.communities[m])
1603
+ l.set(f, m);
1597
1604
  else
1598
- t.forEach((u, g) => d.set(u, g));
1605
+ t.forEach((m, f) => l.set(m, f));
1599
1606
  const p = [];
1600
- return await S(e, "Grouping nodes", t, (u) => {
1601
- p.push({ id: u, values: { group: d.get(u) ?? 0 } });
1607
+ return await S(e, "Grouping nodes", t, (m) => {
1608
+ p.push({ id: m, values: { group: l.get(m) ?? 0 } });
1602
1609
  }), {
1603
1610
  shape: "community",
1604
- fields: ee(!0),
1611
+ fields: oe(!0),
1605
1612
  nodes: p,
1606
- graph: { modularity: m?.modularity ?? 0 },
1607
- caveats: M({
1613
+ graph: { modularity: u?.modularity ?? 0 },
1614
+ caveats: C({
1608
1615
  method: "girvan-newman",
1609
1616
  direction: "undirected",
1610
1617
  weight: { attribute: "weight", meaning: "strength" },
1611
- notes: m === void 0 ? ["No edge could be cut, so every node is its own community."] : [`Kept the best of ${String(r.length)} successive cuts.`]
1618
+ notes: u === void 0 ? ["No edge could be cut, so every node is its own community."] : [`Kept the best of ${String(r.length)} successive cuts.`]
1612
1619
  })
1613
1620
  };
1614
1621
  }
1615
1622
  };
1616
- j.namespace = "graphty", j.type = "girvan-newman", j.zodOptionsSchema = ca, j.optionsSchema = {
1623
+ Y.namespace = "graphty", Y.type = "girvan-newman", Y.scopeInput = "subgraph", Y.zodOptionsSchema = ma, Y.optionsSchema = {
1617
1624
  maxCommunities: {
1618
1625
  type: "integer",
1619
1626
  default: 0,
@@ -1641,9 +1648,9 @@ j.namespace = "graphty", j.type = "girvan-newman", j.zodOptionsSchema = ca, j.op
1641
1648
  advanced: !0
1642
1649
  }
1643
1650
  };
1644
- let ve = j;
1645
- v.register(ve);
1646
- const la = {
1651
+ let Te = Y;
1652
+ v.register(Te);
1653
+ const ga = {
1647
1654
  maxIterations: {
1648
1655
  schema: c.number().int().min(1).max(1e3).default(100),
1649
1656
  meta: {
@@ -1684,23 +1691,23 @@ const la = {
1684
1691
  advanced: !0
1685
1692
  }
1686
1693
  }
1687
- }, da = [
1688
- ...$({ plainName: "Hub and authority", technicalName: "combined HITS score" }),
1689
- re({ name: "hub", plainName: "Hub", technicalName: "hub score", kind: "node", type: "number" }),
1690
- re({
1694
+ }, fa = [
1695
+ ...U({ plainName: "Hub and authority", technicalName: "combined HITS score" }),
1696
+ Be({ name: "hub", plainName: "Hub", technicalName: "hub score", kind: "node", type: "number" }),
1697
+ Be({
1691
1698
  name: "authority",
1692
1699
  plainName: "Authority",
1693
1700
  technicalName: "authority score",
1694
1701
  kind: "node",
1695
1702
  type: "number"
1696
1703
  })
1697
- ], V = class V extends G {
1704
+ ], Z = class Z extends j {
1698
1705
  /**
1699
1706
  * The fields a HITS result publishes.
1700
1707
  * @returns The uniform node-metric fields, plus `hub` and `authority`.
1701
1708
  */
1702
1709
  resultFields() {
1703
- return da;
1710
+ return fa;
1704
1711
  }
1705
1712
  /**
1706
1713
  * Score every node as a hub and as an authority.
@@ -1709,31 +1716,31 @@ const la = {
1709
1716
  * @returns The combined score per node, with the two halves beside it.
1710
1717
  */
1711
1718
  async measure(e, t) {
1712
- const { maxIterations: n, tolerance: a, normalized: i, mode: s, endpoints: r } = this.schemaOptions, l = this.algorithmGraph("directed");
1719
+ const { maxIterations: n, tolerance: a, normalized: i, mode: o, endpoints: r } = this.schemaOptions, d = this.algorithmGraph("directed");
1713
1720
  e.report({
1714
1721
  phase: "iterating",
1715
1722
  completed: 0,
1716
1723
  total: t.length,
1717
1724
  message: `Hub and authority scores refine each other, up to ${String(n)} passes.`
1718
1725
  });
1719
- const h = Mt(l, {
1726
+ const h = Pt(d, {
1720
1727
  maxIterations: n,
1721
1728
  tolerance: a,
1722
1729
  normalized: i,
1723
- mode: s,
1730
+ mode: o,
1724
1731
  endpoints: r
1725
1732
  });
1726
1733
  e.signal.throwIfAborted();
1727
- const m = [];
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: {} });
1734
+ const u = [];
1735
+ return await W(t, e, "reading scores", (l) => {
1736
+ const p = h.hubs[String(l)], m = h.authorities[String(l)];
1737
+ if (p === void 0 || m === void 0) {
1738
+ u.push({ id: l, values: {} });
1732
1739
  return;
1733
1740
  }
1734
- m.push({ id: d, values: { value: (p + u) / 2, hub: p, authority: u } });
1741
+ u.push({ id: l, values: { value: (p + m) / 2, hub: p, authority: m } });
1735
1742
  }), {
1736
- nodes: m,
1743
+ nodes: u,
1737
1744
  // The combined score is the average of two vectors the algorithm scaled, which leaves
1738
1745
  // it scaled by neither of the two rules this field names. The notes say what was done.
1739
1746
  normalization: "none",
@@ -1756,7 +1763,7 @@ const la = {
1756
1763
  };
1757
1764
  }
1758
1765
  };
1759
- V.namespace = "graphty", V.type = "hits", V.zodOptionsSchema = la, V.optionsSchema = {
1766
+ Z.namespace = "graphty", Z.type = "hits", Z.scopeInput = "subgraph", Z.zodOptionsSchema = ga, Z.optionsSchema = {
1760
1767
  maxIterations: {
1761
1768
  type: "integer",
1762
1769
  default: 100,
@@ -1802,9 +1809,9 @@ V.namespace = "graphty", V.type = "hits", V.zodOptionsSchema = la, V.optionsSche
1802
1809
  advanced: !0
1803
1810
  }
1804
1811
  };
1805
- let Ne = V;
1806
- v.register(Ne);
1807
- const ha = {
1812
+ let ze = Z;
1813
+ v.register(ze);
1814
+ const ya = {
1808
1815
  alpha: {
1809
1816
  schema: c.number().min(0.01).max(0.5).default(0.1),
1810
1817
  meta: {
@@ -1862,16 +1869,16 @@ const ha = {
1862
1869
  advanced: !0
1863
1870
  }
1864
1871
  }
1865
- }, ua = $({
1872
+ }, ba = U({
1866
1873
  plainName: "Influence at a distance",
1867
1874
  technicalName: "Katz score"
1868
- }), q = class q extends G {
1875
+ }), J = class J extends j {
1869
1876
  /**
1870
1877
  * The fields a Katz result publishes.
1871
1878
  * @returns The uniform node-metric fields.
1872
1879
  */
1873
1880
  resultFields() {
1874
- return ua;
1881
+ return ba;
1875
1882
  }
1876
1883
  /**
1877
1884
  * Score every node by the paths that reach it.
@@ -1880,27 +1887,27 @@ const ha = {
1880
1887
  * @returns One score per node, scaled as the options asked for.
1881
1888
  */
1882
1889
  async measure(e, t) {
1883
- const { alpha: n, beta: a, maxIterations: i, tolerance: s, normalized: r, mode: l, endpoints: h } = this.schemaOptions, m = this.algorithmGraph("undirected");
1890
+ const { alpha: n, beta: a, maxIterations: i, tolerance: o, normalized: r, mode: d, endpoints: h } = this.schemaOptions, u = this.algorithmGraph("undirected");
1884
1891
  e.report({
1885
1892
  phase: "iterating",
1886
1893
  completed: 0,
1887
1894
  total: t.length,
1888
1895
  message: `Attenuated path sums, up to ${String(i)} passes.`
1889
1896
  });
1890
- const d = Ct(m, {
1897
+ const l = Rt(u, {
1891
1898
  normalized: r,
1892
1899
  alpha: n,
1893
1900
  beta: a,
1894
1901
  maxIterations: i,
1895
- tolerance: s,
1896
- mode: l,
1902
+ tolerance: o,
1903
+ mode: d,
1897
1904
  endpoints: h
1898
1905
  });
1899
1906
  e.signal.throwIfAborted();
1900
1907
  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 } });
1908
+ return await W(t, e, "reading scores", (m) => {
1909
+ const f = l[String(m)];
1910
+ p.push({ id: m, values: f === void 0 ? {} : { value: f } });
1904
1911
  }), {
1905
1912
  nodes: p,
1906
1913
  // With `normalized`, the algorithm rescales so the lowest score is 0 and the highest
@@ -1916,7 +1923,7 @@ const ha = {
1916
1923
  // either at its tolerance or at its iteration cap and reports neither.
1917
1924
  notes: [
1918
1925
  `Every node starts with a base influence of ${String(a)}, and a path of length k contributes ${String(n)} to the power k.`,
1919
- `Iteration stops at a tolerance of ${String(s)} or after ${String(i)} passes, whichever comes first.`,
1926
+ `Iteration stops at a tolerance of ${String(o)} or after ${String(i)} passes, whichever comes first.`,
1920
1927
  "Whether it reached the tolerance is not reported by the implementation, so this run cannot say whether it converged.",
1921
1928
  "Edge weights are not read."
1922
1929
  ]
@@ -1924,7 +1931,7 @@ const ha = {
1924
1931
  };
1925
1932
  }
1926
1933
  };
1927
- q.namespace = "graphty", q.type = "katz", q.zodOptionsSchema = ha, q.optionsSchema = {
1934
+ J.namespace = "graphty", J.type = "katz", J.scopeInput = "subgraph", J.zodOptionsSchema = ya, J.optionsSchema = {
1928
1935
  alpha: {
1929
1936
  type: "number",
1930
1937
  default: 0.1,
@@ -1989,19 +1996,19 @@ q.namespace = "graphty", q.type = "katz", q.zodOptionsSchema = ha, q.optionsSche
1989
1996
  advanced: !0
1990
1997
  }
1991
1998
  };
1992
- let ke = q;
1993
- v.register(ke);
1994
- const pa = $({
1999
+ let Ee = J;
2000
+ v.register(Ee);
2001
+ const wa = U({
1995
2002
  plainName: "Core depth",
1996
2003
  technicalName: "core number",
1997
2004
  type: "integer"
1998
- }), Ke = class Ke extends G {
2005
+ }), me = class me extends j {
1999
2006
  /**
2000
2007
  * The fields a k-core result publishes.
2001
2008
  * @returns The uniform node-metric fields.
2002
2009
  */
2003
2010
  resultFields() {
2004
- return pa;
2011
+ return wa;
2005
2012
  }
2006
2013
  /**
2007
2014
  * Give every node its core number.
@@ -2012,12 +2019,12 @@ const pa = $({
2012
2019
  async measure(e, t) {
2013
2020
  const n = this.algorithmGraph("undirected");
2014
2021
  e.report({ phase: "peeling cores", total: null });
2015
- const { coreness: a } = zt(n);
2022
+ const { coreness: a } = $t(n);
2016
2023
  e.signal.throwIfAborted();
2017
2024
  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 } });
2025
+ return await W(t, e, "reading core numbers", (o) => {
2026
+ const r = a.get(String(o));
2027
+ i.push({ id: o, values: r === void 0 ? {} : { value: r } });
2021
2028
  }), {
2022
2029
  nodes: i,
2023
2030
  // A count of neighbours, published as it was counted.
@@ -2033,10 +2040,10 @@ const pa = $({
2033
2040
  };
2034
2041
  }
2035
2042
  };
2036
- Ke.namespace = "graphty", Ke.type = "k-core";
2037
- let Se = Ke;
2038
- v.register(Se);
2039
- const Le = class Le extends z {
2043
+ me.namespace = "graphty", me.type = "k-core", me.scopeInput = "subgraph";
2044
+ let Me = me;
2045
+ v.register(Me);
2046
+ const ge = class ge extends E {
2040
2047
  /**
2041
2048
  * Find the cheapest set of edges that still joins every node.
2042
2049
  *
@@ -2047,34 +2054,34 @@ const Le = class Le extends z {
2047
2054
  * @returns The edge set, or null when there are no edges to choose from.
2048
2055
  */
2049
2056
  async compute(e) {
2050
- const t = Array.from(this.graph.getDataManager().edges.values());
2057
+ const t = ie(this.input("undirected"));
2051
2058
  if (t.length === 0)
2052
2059
  return null;
2053
2060
  const { edgeRemap: n, run: a } = this.accelerated("minimumSpanningTree", "undirected");
2054
2061
  e.report({ phase: "Choosing edges", total: null });
2055
- const { value: i, precision: s } = await a((h, m) => h.minimumSpanningTree(m)), r = new Set(i.edges), l = [];
2062
+ const { value: i, precision: o } = await a((h, u) => h.minimumSpanningTree(u)), r = new Set(i.edges), d = [];
2056
2063
  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) } });
2064
+ const u = n === null ? h.row : n[h.row] ?? L;
2065
+ d.push({ id: h.id, values: { in: r.has(u) } });
2059
2066
  }), {
2060
2067
  shape: "edge-set",
2061
- fields: je("edge", { name: "totalWeight", type: "number" }),
2062
- edges: l,
2068
+ fields: Ze("edge", { name: "totalWeight", type: "number" }),
2069
+ edges: d,
2063
2070
  graph: { totalWeight: i.totalWeight },
2064
- caveats: M({
2071
+ caveats: C({
2065
2072
  method: "kruskal",
2066
2073
  direction: "undirected",
2067
2074
  weight: { attribute: "weight", meaning: "distance" },
2068
- precision: s,
2075
+ precision: o,
2069
2076
  notes: [`The tree joins the graph with ${String(i.edges.length)} edges.`]
2070
2077
  })
2071
2078
  };
2072
2079
  }
2073
2080
  };
2074
- Le.namespace = "graphty", Le.type = "kruskal";
2075
- let Oe = Le;
2076
- v.register(Oe);
2077
- const ma = {
2081
+ ge.namespace = "graphty", ge.type = "kruskal", ge.scopeInput = "subgraph";
2082
+ let De = ge;
2083
+ v.register(De);
2084
+ const va = {
2078
2085
  maxIterations: {
2079
2086
  schema: c.number().int().min(1).max(500).default(100),
2080
2087
  meta: {
@@ -2090,7 +2097,7 @@ const ma = {
2090
2097
  advanced: !0
2091
2098
  }
2092
2099
  }
2093
- }, A = class A extends z {
2100
+ }, X = class X extends E {
2094
2101
  /**
2095
2102
  * Group the nodes into communities by letting labels spread between neighbours.
2096
2103
  *
@@ -2102,34 +2109,34 @@ const ma = {
2102
2109
  * @returns The community result, or null when there are no nodes to group.
2103
2110
  */
2104
2111
  async compute(e) {
2105
- const t = Array.from(this.graph.getDataManager().nodes.keys());
2112
+ const t = R(this.input("undirected"));
2106
2113
  if (t.length === 0)
2107
2114
  return null;
2108
2115
  const { maxIterations: n, randomSeed: a } = this.schemaOptions, i = this.algorithmGraph("undirected");
2109
2116
  e.report({ phase: "Spreading labels", total: null });
2110
- const s = Tt(i, {
2117
+ const o = Ft(i, {
2111
2118
  maxIterations: n,
2112
2119
  randomSeed: a
2113
2120
  }), r = [];
2114
- return await S(e, "Grouping nodes", t, (l) => {
2115
- r.push({ id: l, values: { group: s.communities.get(String(l)) ?? 0 } });
2121
+ return await S(e, "Grouping nodes", t, (d) => {
2122
+ r.push({ id: d, values: { group: o.communities.get(String(d)) ?? 0 } });
2116
2123
  }), {
2117
2124
  shape: "community",
2118
- fields: ee(!1),
2125
+ fields: oe(!1),
2119
2126
  nodes: r,
2120
- caveats: M({
2127
+ caveats: C({
2121
2128
  method: "label-propagation",
2122
2129
  direction: "undirected",
2123
2130
  weight: { attribute: "weight", meaning: "strength" },
2124
- converged: s.converged,
2125
- iterations: s.iterations,
2131
+ converged: o.converged,
2132
+ iterations: o.iterations,
2126
2133
  seed: a,
2127
2134
  notes: ["Label propagation does not score its own partition, so it reports no modularity."]
2128
2135
  })
2129
2136
  };
2130
2137
  }
2131
2138
  };
2132
- A.namespace = "graphty", A.type = "label-propagation", A.zodOptionsSchema = ma, A.optionsSchema = {
2139
+ X.namespace = "graphty", X.type = "label-propagation", X.scopeInput = "subgraph", X.zodOptionsSchema = va, X.optionsSchema = {
2133
2140
  maxIterations: {
2134
2141
  type: "integer",
2135
2142
  default: 100,
@@ -2148,9 +2155,9 @@ A.namespace = "graphty", A.type = "label-propagation", A.zodOptionsSchema = ma,
2148
2155
  advanced: !0
2149
2156
  }
2150
2157
  };
2151
- let xe = A;
2152
- v.register(xe);
2153
- const ga = {
2158
+ let Pe = X;
2159
+ v.register(Pe);
2160
+ const Na = {
2154
2161
  resolution: {
2155
2162
  schema: c.number().min(0.1).max(5).default(1),
2156
2163
  meta: {
@@ -2183,7 +2190,7 @@ const ga = {
2183
2190
  advanced: !0
2184
2191
  }
2185
2192
  }
2186
- }, B = class B extends z {
2193
+ }, Q = class Q extends E {
2187
2194
  /**
2188
2195
  * Group the nodes into communities, refining each group before it is kept.
2189
2196
  *
@@ -2194,35 +2201,35 @@ const ga = {
2194
2201
  * @returns The community result, or null when there are no nodes to group.
2195
2202
  */
2196
2203
  async compute(e) {
2197
- const t = Array.from(this.graph.getDataManager().nodes.keys());
2204
+ const t = R(this.input("undirected"));
2198
2205
  if (t.length === 0)
2199
2206
  return null;
2200
- const { resolution: n, randomSeed: a, maxIterations: i, threshold: s } = this.schemaOptions, r = this.algorithmGraph("undirected");
2207
+ const { resolution: n, randomSeed: a, maxIterations: i, threshold: o } = this.schemaOptions, r = this.algorithmGraph("undirected");
2201
2208
  e.report({ phase: "Refining communities", total: null });
2202
- const l = Et(r, {
2209
+ const d = Gt(r, {
2203
2210
  resolution: n,
2204
2211
  randomSeed: a,
2205
2212
  maxIterations: i,
2206
- threshold: s
2213
+ threshold: o
2207
2214
  }), h = [];
2208
- return await S(e, "Grouping nodes", t, (m) => {
2209
- h.push({ id: m, values: { group: l.communities.get(String(m)) ?? 0 } });
2215
+ return await S(e, "Grouping nodes", t, (u) => {
2216
+ h.push({ id: u, values: { group: d.communities.get(String(u)) ?? 0 } });
2210
2217
  }), {
2211
2218
  shape: "community",
2212
- fields: ee(!0),
2219
+ fields: oe(!0),
2213
2220
  nodes: h,
2214
- graph: { modularity: l.modularity },
2215
- caveats: M({
2221
+ graph: { modularity: d.modularity },
2222
+ caveats: C({
2216
2223
  method: "leiden",
2217
2224
  direction: "undirected",
2218
2225
  weight: { attribute: "weight", meaning: "strength" },
2219
- iterations: l.iterations,
2226
+ iterations: d.iterations,
2220
2227
  notes: [`Resolution ${String(n)}.`]
2221
2228
  })
2222
2229
  };
2223
2230
  }
2224
2231
  };
2225
- B.namespace = "graphty", B.type = "leiden", B.zodOptionsSchema = ga, B.optionsSchema = {
2232
+ Q.namespace = "graphty", Q.type = "leiden", Q.scopeInput = "subgraph", Q.zodOptionsSchema = Na, Q.optionsSchema = {
2226
2233
  resolution: {
2227
2234
  type: "number",
2228
2235
  default: 1,
@@ -2260,12 +2267,12 @@ B.namespace = "graphty", B.type = "leiden", B.zodOptionsSchema = ga, B.optionsSc
2260
2267
  advanced: !0
2261
2268
  }
2262
2269
  };
2263
- let Ie = B;
2264
- v.register(Ie);
2265
- const fa = {
2266
- "adamic-adar": Pt,
2267
- "common-neighbors": Dt
2268
- }, ya = {
2270
+ let Re = Q;
2271
+ v.register(Re);
2272
+ const ka = {
2273
+ "adamic-adar": Wt,
2274
+ "common-neighbors": Ht
2275
+ }, Sa = {
2269
2276
  method: {
2270
2277
  schema: c.enum(["adamic-adar", "common-neighbors"]).default("adamic-adar"),
2271
2278
  meta: {
@@ -2280,37 +2287,36 @@ const fa = {
2280
2287
  description: "How many of the best-scoring pairs to keep."
2281
2288
  }
2282
2289
  }
2283
- }, Y = class Y extends z {
2290
+ }, A = class A extends E {
2284
2291
  /**
2285
- * Score every unconnected pair of nodes and keep the best.
2292
+ * Score every unconnected pair of the run's nodes and keep the best. A pair is published as a
2293
+ * row of the result and never written into the graph.
2286
2294
  * @param context - What the element gave the run.
2287
2295
  * @returns The scored pairs, best first, or null when the graph has no nodes.
2288
2296
  */
2289
2297
  compute(e) {
2290
- if (this.graph.getDataManager().nodes.size === 0)
2298
+ if (this.input("undirected").nodeCount === 0)
2291
2299
  return Promise.resolve(null);
2292
2300
  const { method: t, topK: n } = this.schemaOptions, a = this.algorithmGraph("undirected");
2293
2301
  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");
2302
+ const i = /* @__PURE__ */ new Set(), o = ka[t](a).filter(({ source: r, target: d }) => {
2303
+ const h = [String(r), String(d)].sort().join("\0");
2296
2304
  return i.has(h) ? !1 : (i.add(h), !0);
2297
2305
  }).slice(0, n);
2298
2306
  return e.signal.throwIfAborted(), Promise.resolve({
2299
2307
  shape: "pair-list",
2300
2308
  fields: [{ name: "pairs", kind: "graph", type: "table" }],
2301
- graph: { pairs: s },
2302
- caveats: M({
2309
+ graph: { pairs: o },
2310
+ caveats: C({
2303
2311
  method: t,
2304
2312
  direction: "undirected",
2305
2313
  weight: null,
2306
- notes: [
2307
- "Only pairs that are not already joined, and that share at least one neighbour, are scored."
2308
- ]
2314
+ notes: ["Only pairs that are not already joined, and that share at least one neighbour, are scored."]
2309
2315
  })
2310
2316
  });
2311
2317
  }
2312
2318
  };
2313
- Y.namespace = "graphty", Y.type = "link-prediction", Y.zodOptionsSchema = ya, Y.optionsSchema = {
2319
+ A.namespace = "graphty", A.type = "link-prediction", A.scopeInput = "subgraph", A.zodOptionsSchema = Sa, A.optionsSchema = {
2314
2320
  method: {
2315
2321
  type: "select",
2316
2322
  default: "adamic-adar",
@@ -2330,9 +2336,9 @@ Y.namespace = "graphty", Y.type = "link-prediction", Y.zodOptionsSchema = ya, Y.
2330
2336
  max: 1e3
2331
2337
  }
2332
2338
  };
2333
- let Me = Y;
2334
- v.register(Me);
2335
- const ba = {
2339
+ let $e = A;
2340
+ v.register($e);
2341
+ const Oa = {
2336
2342
  resolution: {
2337
2343
  schema: c.number().min(0.1).max(5).default(1),
2338
2344
  meta: {
@@ -2365,7 +2371,7 @@ const ba = {
2365
2371
  advanced: !0
2366
2372
  }
2367
2373
  }
2368
- }, Z = class Z extends z {
2374
+ }, _ = class _ extends E {
2369
2375
  /**
2370
2376
  * Group the nodes into communities by optimising modularity.
2371
2377
  *
@@ -2376,29 +2382,29 @@ const ba = {
2376
2382
  * @returns The community result, or null when there are no nodes to group.
2377
2383
  */
2378
2384
  async compute(e) {
2379
- const t = Array.from(this.graph.getDataManager().nodes.keys());
2385
+ const t = R(this.input("undirected"));
2380
2386
  if (t.length === 0)
2381
2387
  return null;
2382
- const { resolution: n, maxIterations: a, tolerance: i, useOptimized: s } = this.schemaOptions, r = this.algorithmGraph("undirected");
2388
+ const { resolution: n, maxIterations: a, tolerance: i, useOptimized: o } = this.schemaOptions, r = this.algorithmGraph("undirected");
2383
2389
  e.report({ phase: "Optimizing modularity", total: null });
2384
- const l = Rt(r, {
2390
+ const d = Kt(r, {
2385
2391
  resolution: n,
2386
2392
  maxIterations: a,
2387
2393
  tolerance: i,
2388
- useOptimized: s
2394
+ useOptimized: o
2389
2395
  }), h = /* @__PURE__ */ new Map();
2390
- for (let d = 0; d < l.communities.length; d++)
2391
- for (const p of l.communities[d])
2392
- h.set(p, d);
2393
- const m = [];
2394
- return await S(e, "Grouping nodes", t, (d) => {
2395
- m.push({ id: d, values: { group: h.get(d) ?? 0 } });
2396
+ for (let l = 0; l < d.communities.length; l++)
2397
+ for (const p of d.communities[l])
2398
+ h.set(p, l);
2399
+ const u = [];
2400
+ return await S(e, "Grouping nodes", t, (l) => {
2401
+ u.push({ id: l, values: { group: h.get(l) ?? 0 } });
2396
2402
  }), {
2397
2403
  shape: "community",
2398
- fields: ee(!0),
2399
- nodes: m,
2400
- graph: { modularity: l.modularity },
2401
- caveats: M({
2404
+ fields: oe(!0),
2405
+ nodes: u,
2406
+ graph: { modularity: d.modularity },
2407
+ caveats: C({
2402
2408
  method: "louvain",
2403
2409
  direction: "undirected",
2404
2410
  weight: { attribute: "weight", meaning: "strength" },
@@ -2407,7 +2413,7 @@ const ba = {
2407
2413
  };
2408
2414
  }
2409
2415
  };
2410
- Z.namespace = "graphty", Z.type = "louvain", Z.zodOptionsSchema = ba, Z.optionsSchema = {
2416
+ _.namespace = "graphty", _.type = "louvain", _.scopeInput = "subgraph", _.zodOptionsSchema = Oa, _.optionsSchema = {
2411
2417
  resolution: {
2412
2418
  type: "number",
2413
2419
  default: 1,
@@ -2443,9 +2449,9 @@ Z.namespace = "graphty", Z.type = "louvain", Z.zodOptionsSchema = ba, Z.optionsS
2443
2449
  advanced: !0
2444
2450
  }
2445
2451
  };
2446
- let Ce = Z;
2447
- v.register(Ce);
2448
- const wa = {
2452
+ let Fe = _;
2453
+ v.register(Fe);
2454
+ const xa = {
2449
2455
  source: {
2450
2456
  schema: c.union([c.string(), c.number()]).nullable().default(null),
2451
2457
  meta: {
@@ -2460,7 +2466,7 @@ const wa = {
2460
2466
  description: "Sink node for flow network (uses last node if not set)"
2461
2467
  }
2462
2468
  }
2463
- }, X = class X extends z {
2469
+ }, ee = class ee extends E {
2464
2470
  constructor() {
2465
2471
  super(...arguments), this.legacyOptions = null;
2466
2472
  }
@@ -2486,60 +2492,60 @@ const wa = {
2486
2492
  * @returns The flow per edge, or null when there is no network to measure.
2487
2493
  */
2488
2494
  async compute(e) {
2489
- const t = this.graph.getDataManager(), n = Array.from(t.edges.values()), a = Array.from(t.nodes.keys());
2495
+ const t = this.input("declared"), n = ie(t), a = R(t);
2490
2496
  if (n.length === 0 || a.length === 0)
2491
2497
  return null;
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 });
2493
- for (const y of a)
2494
- h.addNode(String(y));
2495
- const m = /* @__PURE__ */ new Map();
2496
- for (const y of n) {
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);
2498
+ const i = this.legacyOptions?.source ?? this._schemaOptions.source, o = this.legacyOptions?.sink ?? this._schemaOptions.sink, r = i === null ? String(a[0]) : Ye("max-flow", "source", i, a), d = o === null ? String(a[a.length - 1]) : Ye("max-flow", "sink", o, a), h = new _e({ directed: !0 });
2499
+ for (const b of a)
2500
+ h.addNode(String(b));
2501
+ const u = /* @__PURE__ */ new Map();
2502
+ for (const b of n) {
2503
+ const w = String(b.source), O = String(b.target), I = this.edgeRecord(b.id), x = I?.capacity ?? I?.value ?? 1, T = typeof x == "number" ? x : 1, F = P(w, O), D = (u.get(F) ?? 0) + T;
2504
+ u.set(F, D), h.removeEdge(w, O), h.addEdge(w, O, D);
2499
2505
  }
2500
2506
  e.report({ phase: "Pushing flow", total: null });
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 } });
2507
+ const l = Lt(h, r, d), p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
2508
+ for (const [b, w] of l.flowGraph)
2509
+ for (const [O, I] of w)
2510
+ m.set(b, (m.get(b) ?? 0) + I), p.set(O, (p.get(O) ?? 0) + I);
2511
+ const f = [];
2512
+ await S(e, "Measuring edges", n, (b) => {
2513
+ const w = String(b.source), O = String(b.target), I = l.flowGraph.get(w)?.get(O) ?? 0, x = u.get(P(w, O)) ?? 1, T = x > 0 ? Math.abs(I) / x : 0;
2514
+ f.push({ id: b.id, values: { value: I, capacity: x, utilization: T } });
2509
2515
  });
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 });
2516
+ const M = [];
2517
+ return await S(e, "Measuring nodes", a, (b) => {
2518
+ const w = String(b), O = p.get(w) ?? 0, I = m.get(w) ?? 0, x = { netFlow: O - I };
2519
+ w === r ? x.role = "source" : w === d && (x.role = "sink"), M.push({ id: b, values: x });
2514
2520
  }), {
2515
2521
  shape: "edge-metric",
2516
2522
  fields: [
2517
- ...Be("edge"),
2523
+ ...Ae("edge"),
2518
2524
  { name: "capacity", kind: "edge", type: "number" },
2519
2525
  { name: "utilization", kind: "edge", type: "number" },
2520
2526
  { name: "netFlow", kind: "node", type: "number" },
2521
2527
  { name: "role", kind: "node", type: "string" },
2522
2528
  { name: "maxFlow", kind: "graph", type: "number" }
2523
2529
  ],
2524
- nodes: x,
2525
- edges: g,
2526
- graph: { maxFlow: d.maxFlow },
2527
- caveats: M({
2530
+ nodes: M,
2531
+ edges: f,
2532
+ graph: { maxFlow: l.maxFlow },
2533
+ caveats: C({
2528
2534
  method: "ford-fulkerson",
2529
2535
  direction: "directed",
2530
2536
  weight: { attribute: "capacity", meaning: "strength" },
2531
2537
  notes: [
2532
- `Flow from ${r} to ${l}.`,
2533
- ...i === null || s === null ? [
2538
+ `Flow from ${r} to ${d}.`,
2539
+ ...i === null || o === null ? [
2534
2540
  "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."
2535
2541
  ] : [],
2536
- ...d.maxFlow === 0 ? [`There is no directed path from ${r} to ${l}, so no flow can run.`] : []
2542
+ ...l.maxFlow === 0 ? [`There is no directed path from ${r} to ${d}, so no flow can run.`] : []
2537
2543
  ]
2538
2544
  })
2539
2545
  };
2540
2546
  }
2541
2547
  };
2542
- X.namespace = "graphty", X.type = "max-flow", X.zodOptionsSchema = wa, X.optionsSchema = {
2548
+ ee.namespace = "graphty", ee.type = "max-flow", ee.scopeInput = "subgraph", ee.zodOptionsSchema = xa, ee.optionsSchema = {
2543
2549
  source: {
2544
2550
  type: "nodeId",
2545
2551
  default: null,
@@ -2555,9 +2561,9 @@ X.namespace = "graphty", X.type = "max-flow", X.zodOptionsSchema = wa, X.options
2555
2561
  required: !1
2556
2562
  }
2557
2563
  };
2558
- let ze = X;
2559
- v.register(ze);
2560
- const va = {
2564
+ let Ge = ee;
2565
+ v.register(Ge);
2566
+ const Ia = {
2561
2567
  source: {
2562
2568
  schema: c.union([c.string(), c.number()]).nullable().default(null),
2563
2569
  meta: {
@@ -2595,7 +2601,7 @@ const va = {
2595
2601
  advanced: !0
2596
2602
  }
2597
2603
  }
2598
- }, J = class J extends z {
2604
+ }, te = class te extends E {
2599
2605
  constructor() {
2600
2606
  super(...arguments), this.legacyOptions = null;
2601
2607
  }
@@ -2627,61 +2633,61 @@ const va = {
2627
2633
  * @returns The edge set, or null when there is nothing to cut.
2628
2634
  */
2629
2635
  async compute(e) {
2630
- const t = this.graph.getDataManager(), n = Array.from(t.edges.values()), a = Array.from(t.nodes.keys());
2636
+ const t = this.input("undirected"), n = ie(t), a = R(t);
2631
2637
  if (n.length === 0 || a.length === 0)
2632
2638
  return null;
2633
- const i = /* @__PURE__ */ new Map(), s = new at({ directed: !1 });
2634
- for (const b of a)
2635
- i.set(String(b), /* @__PURE__ */ new Map()), s.addNode(String(b));
2636
- for (const b of n) {
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);
2639
- }
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));
2639
+ const i = t.subgraph(), { ids: o } = i, { src: r, dst: d, weights: h } = i.edgeList(), u = /* @__PURE__ */ new Map(), l = new _e({ directed: !1 });
2640
+ for (const y of a)
2641
+ u.set(String(y), /* @__PURE__ */ new Map()), l.addNode(String(y));
2642
+ for (let y = 0; y < i.edgeCount; y++) {
2643
+ const $ = String(o.idOf(r[y])), se = String(o.idOf(d[y])), Je = h === null ? 1 : h[y];
2644
+ u.get($)?.set(se, Je), u.get(se)?.set($, Je), l.addEdge($, se, Je);
2645
+ }
2646
+ const p = this.legacyOptions?.useGlobalMinCut ?? this._schemaOptions.useGlobalMinCut, m = this.legacyOptions?.source ?? this._schemaOptions.source, f = this.legacyOptions?.sink ?? this._schemaOptions.sink, { useKarger: M, kargerIterations: b } = this._schemaOptions;
2647
+ let w, O, I, x, T, F;
2648
+ if (e.report({ phase: "Finding the cut", total: null }), p || m === null && f === null)
2649
+ M ? (T = "karger", { partition1: w, partition2: O, cutEdges: I, cutValue: x } = Ut(u, b)) : (T = "stoer-wagner", { partition1: w, partition2: O, cutEdges: I, cutValue: x } = jt(u));
2644
2650
  else {
2645
- y = "min-st-cut";
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);
2651
+ T = "min-st-cut";
2652
+ const y = m === null ? String(a[0]) : Ye("min-cut", "source", m, a), $ = f === null ? String(a[a.length - 1]) : Ye("min-cut", "sink", f, a);
2653
+ (m === null || f === null) && (F = `Only one end was set, so the other was chosen automatically (cut between ${y} and ${$}); set both source and sink to cut between the nodes you mean.`), { partition1: w, partition2: O, cutEdges: I, cutValue: x } = Vt(l, y, $);
2648
2654
  }
2649
- const I = /* @__PURE__ */ new Map();
2650
- for (const b of g)
2651
- I.set(T(b.from, b.to), b.weight), I.set(T(b.to, b.from), b.weight);
2652
- const w = [];
2653
- await S(e, "Marking the cut", n, (b) => {
2654
- const C = I.get(T(b.srcId, b.dstId));
2655
- w.push({ id: b.id, values: { in: C !== void 0 } });
2656
- });
2655
+ const D = /* @__PURE__ */ new Map();
2656
+ for (const y of I)
2657
+ D.set(P(y.from, y.to), y.weight), D.set(P(y.to, y.from), y.weight);
2657
2658
  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" } });
2659
+ await S(e, "Marking the cut", n, (y) => {
2660
+ const $ = D.get(P(y.source, y.target));
2661
+ N.push({ id: y.id, values: { in: $ !== void 0 } });
2662
+ });
2663
+ const z = [];
2664
+ return await S(e, "Marking the sides", a, (y) => {
2665
+ const $ = w.has(String(y));
2666
+ z.push({ id: y, values: { side: $ ? "1" : "2" } });
2661
2667
  }), {
2662
2668
  shape: "edge-set",
2663
2669
  fields: [
2664
- ...je("edge", { name: "cutValue", type: "number" }),
2670
+ ...Ze("edge", { name: "cutValue", type: "number" }),
2665
2671
  { name: "side", kind: "node", type: "string" }
2666
2672
  ],
2667
- nodes: N,
2668
- edges: w,
2673
+ nodes: z,
2674
+ edges: N,
2669
2675
  graph: { cutValue: x },
2670
- caveats: M({
2671
- method: y,
2676
+ caveats: C({
2677
+ method: T,
2672
2678
  direction: "undirected",
2673
2679
  weight: { attribute: "weight", meaning: "strength" },
2674
- exact: y !== "karger",
2675
- iterations: y === "karger" ? d : void 0,
2680
+ exact: T !== "karger",
2681
+ iterations: T === "karger" ? b : void 0,
2676
2682
  notes: [
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]
2683
+ T === "karger" ? "Karger's method is randomised: it finds the cheapest cut with high probability, not certainty." : `The cut separates ${String(w.size)} nodes from ${String(O.size)}.`,
2684
+ ...F === void 0 ? [] : [F]
2679
2685
  ]
2680
2686
  })
2681
2687
  };
2682
2688
  }
2683
2689
  };
2684
- J.namespace = "graphty", J.type = "min-cut", J.zodOptionsSchema = va, J.optionsSchema = {
2690
+ te.namespace = "graphty", te.type = "min-cut", te.scopeInput = "subgraph", te.zodOptionsSchema = Ia, te.optionsSchema = {
2685
2691
  source: {
2686
2692
  type: "nodeId",
2687
2693
  default: null,
@@ -2720,9 +2726,9 @@ J.namespace = "graphty", J.type = "min-cut", J.zodOptionsSchema = va, J.optionsS
2720
2726
  advanced: !0
2721
2727
  }
2722
2728
  };
2723
- let Te = J;
2724
- v.register(Te);
2725
- const _e = {
2729
+ let He = te;
2730
+ v.register(He);
2731
+ const st = {
2726
2732
  dampingFactor: {
2727
2733
  schema: c.number().min(0).max(1).default(0.85),
2728
2734
  meta: {
@@ -2763,21 +2769,21 @@ const _e = {
2763
2769
  advanced: !0
2764
2770
  }
2765
2771
  }
2766
- }, Na = $({
2772
+ }, Ca = U({
2767
2773
  plainName: "Influence",
2768
2774
  technicalName: "PageRank score"
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";
2775
+ }), Ta = 100;
2776
+ function za(s) {
2777
+ 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";
2772
2778
  }
2773
- const Q = class Q extends G {
2779
+ const ae = class ae extends j {
2774
2780
  /**
2775
2781
  * Creates a new PageRank algorithm instance
2776
2782
  * @param g - The graph to run the algorithm on
2777
2783
  * @param options - Optional configuration options
2778
2784
  */
2779
2785
  constructor(e, t) {
2780
- super(e, t), this.zodOptions = Xt(_e, t ?? {}), this.programmaticOptions = {
2786
+ super(e, t), this.zodOptions = aa(st, t ?? {}), this.programmaticOptions = {
2781
2787
  initialRanks: t?.initialRanks ?? null,
2782
2788
  personalization: t?.personalization ?? null
2783
2789
  };
@@ -2787,7 +2793,7 @@ const Q = class Q extends G {
2787
2793
  * @returns The uniform node-metric fields.
2788
2794
  */
2789
2795
  resultFields() {
2790
- return Na;
2796
+ return Ca;
2791
2797
  }
2792
2798
  /**
2793
2799
  * Rank every node by the influence flowing into it.
@@ -2796,101 +2802,101 @@ const Q = class Q extends G {
2796
2802
  * @returns One raw rank per node, unscaled.
2797
2803
  */
2798
2804
  async measure(e, t) {
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({
2800
- directed: this.graph.getDataManager().getSnapshot().directed,
2801
- hasInitialRanks: l !== void 0,
2805
+ 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, u = za({
2806
+ directed: this.input("declared").graph.directed,
2807
+ hasInitialRanks: d !== void 0,
2802
2808
  hasPersonalization: h !== void 0
2803
2809
  });
2804
- if (m === null) {
2805
- const { snapshot: y, run: O } = this.accelerated("pageRank", "directed");
2810
+ if (u === null) {
2811
+ const { snapshot: b, run: w } = this.accelerated("pageRank", "directed");
2806
2812
  e.report({
2807
2813
  phase: "iterating",
2808
2814
  completed: 0,
2809
2815
  total: t.length,
2810
2816
  message: `Power iteration, up to ${String(a)} passes.`
2811
2817
  });
2812
- const { value: I, precision: w } = await O(
2813
- (P, H) => P.pageRank(H, {
2818
+ const { value: O, precision: I } = await w(
2819
+ (D, N) => D.pageRank(N, {
2814
2820
  dampingFactor: n,
2815
2821
  maxIterations: a,
2816
2822
  tolerance: i,
2817
2823
  // ONE weight column, so naming an attribute is the same request as asking for
2818
2824
  // a weighted run: the snapshot carries the weight the element resolved.
2819
- weighted: s !== null
2825
+ weighted: o !== null
2820
2826
  })
2821
2827
  );
2822
2828
  e.signal.throwIfAborted();
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 } });
2829
+ const { ids: x } = b, T = [];
2830
+ await W(t, e, "reading ranks", (D) => {
2831
+ const N = x.indexOf(D), z = N === L ? void 0 : O.scores[N];
2832
+ T.push({ id: D, values: z === void 0 ? {} : { value: z } });
2827
2833
  });
2828
- const C = [
2834
+ const F = [
2829
2835
  `A reader follows a link with probability ${String(n)} and jumps to a random node otherwise.`,
2830
2836
  "The ranks sum to 1 across the graph."
2831
2837
  ];
2832
- return s === null && C.push("Edge weights are not read."), r && C.push(
2838
+ return o === null && F.push("Edge weights are not read."), r && F.push(
2833
2839
  "Power iteration ran: the delta optimisation is the CPU reference implementation's own and has no index-based counterpart, so it was not taken."
2834
2840
  ), {
2835
- nodes: b,
2841
+ nodes: T,
2836
2842
  normalization: "none",
2837
2843
  caveats: {
2838
2844
  exact: !0,
2839
2845
  direction: "directed",
2840
- weight: s === null ? null : { attribute: s, meaning: "strength" },
2841
- precision: w,
2846
+ weight: o === null ? null : { attribute: o, meaning: "strength" },
2847
+ precision: I,
2842
2848
  method: "power-iteration",
2843
- converged: I.converged,
2844
- iterations: I.iterations,
2845
- notes: C
2849
+ converged: O.converged,
2850
+ iterations: O.iterations,
2851
+ notes: F
2846
2852
  }
2847
2853
  };
2848
2854
  }
2849
- const d = this.algorithmGraph("directed"), p = r && d.nodeCount > ka;
2855
+ const l = this.algorithmGraph("directed"), p = r && l.nodeCount > Ta;
2850
2856
  e.report({
2851
2857
  phase: "iterating",
2852
2858
  completed: 0,
2853
2859
  total: t.length,
2854
2860
  message: `Power iteration, up to ${String(a)} passes.`
2855
2861
  });
2856
- const u = Wt(d, {
2862
+ const m = qt(l, {
2857
2863
  dampingFactor: n,
2858
2864
  maxIterations: a,
2859
2865
  tolerance: i,
2860
- weight: s ?? void 0,
2866
+ weight: o ?? void 0,
2861
2867
  useDelta: r,
2862
- initialRanks: l,
2868
+ initialRanks: d,
2863
2869
  personalization: h
2864
2870
  });
2865
2871
  e.signal.throwIfAborted();
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 } });
2872
+ const f = [];
2873
+ await W(t, e, "reading ranks", (b) => {
2874
+ const w = m.ranks[String(b)];
2875
+ f.push({ id: b, values: w === void 0 ? {} : { value: w } });
2870
2876
  });
2871
- const x = [
2877
+ const M = [
2872
2878
  `A reader follows a link with probability ${String(n)} and jumps to a random node otherwise.`,
2873
2879
  "The ranks sum to 1 across the graph.",
2874
- `Computed on the CPU reference implementation: ${m}.`
2880
+ `Computed on the CPU reference implementation: ${u}.`
2875
2881
  ];
2876
- return s === null && x.push("Edge weights are not read."), {
2877
- nodes: g,
2882
+ return o === null && M.push("Edge weights are not read."), {
2883
+ nodes: f,
2878
2884
  // Raw ranks, published as they were computed.
2879
2885
  normalization: "none",
2880
2886
  caveats: {
2881
2887
  exact: !0,
2882
2888
  direction: "directed",
2883
- weight: s === null ? null : { attribute: s, meaning: "strength" },
2889
+ weight: o === null ? null : { attribute: o, meaning: "strength" },
2884
2890
  precision: "f64",
2885
2891
  method: p ? "delta-pagerank" : "power-iteration",
2886
- converged: u.converged,
2887
- iterations: u.iterations,
2888
- notes: x
2892
+ converged: m.converged,
2893
+ iterations: m.iterations,
2894
+ notes: M
2889
2895
  }
2890
2896
  };
2891
2897
  }
2892
2898
  };
2893
- Q.namespace = "graphty", Q.type = "pagerank", Q.zodOptionsSchema = _e, Q.optionsSchema = {
2899
+ ae.namespace = "graphty", ae.type = "pagerank", ae.scopeInput = "subgraph", ae.zodOptionsSchema = st, ae.optionsSchema = {
2894
2900
  dampingFactor: {
2895
2901
  type: "number",
2896
2902
  default: 0.85,
@@ -2934,9 +2940,9 @@ Q.namespace = "graphty", Q.type = "pagerank", Q.zodOptionsSchema = _e, Q.options
2934
2940
  }
2935
2941
  // Note: initialRanks and personalization are Map types - programmatic only, not in schema
2936
2942
  };
2937
- let Ee = Q;
2938
- v.register(Ee);
2939
- const Oa = {
2943
+ let We = ae;
2944
+ v.register(We);
2945
+ const Ea = {
2940
2946
  startNode: {
2941
2947
  schema: c.union([c.string(), c.number()]).nullable().default(null),
2942
2948
  meta: {
@@ -2944,7 +2950,27 @@ const Oa = {
2944
2950
  description: "Starting node for MST growth (uses first node if not set)"
2945
2951
  }
2946
2952
  }
2947
- }, _ = class _ extends z {
2953
+ };
2954
+ function Ma(s, e) {
2955
+ if (e !== void 0 && !s.hasNode(e))
2956
+ throw new Error(`Start node ${String(e)} not found in graph`);
2957
+ const t = Bt(s);
2958
+ if (t.length <= 1)
2959
+ return tt(s, e);
2960
+ const n = [];
2961
+ let a = 0;
2962
+ for (const i of t) {
2963
+ const o = new Set(i), r = new _e({ directed: !1 });
2964
+ for (const h of i)
2965
+ r.addNode(h);
2966
+ for (const h of s.edges())
2967
+ o.has(h.source) && r.addEdge(h.source, h.target, h.weight);
2968
+ const d = tt(r, e !== void 0 && o.has(e) ? e : void 0);
2969
+ n.push(...d.edges), a += d.totalWeight;
2970
+ }
2971
+ return { edges: n, totalWeight: a };
2972
+ }
2973
+ const ne = class ne extends E {
2948
2974
  constructor() {
2949
2975
  super(...arguments), this.legacyOptions = null;
2950
2976
  }
@@ -2968,23 +2994,23 @@ const Oa = {
2968
2994
  * @returns The edge set, or null when there are no edges to choose from.
2969
2995
  */
2970
2996
  async compute(e) {
2971
- const t = Array.from(this.graph.getDataManager().edges.values());
2997
+ const t = ie(this.input("undirected"));
2972
2998
  if (t.length === 0)
2973
2999
  return null;
2974
3000
  const n = this.legacyOptions?.startNode ?? this._schemaOptions.startNode ?? void 0, a = this.algorithmGraph("undirected");
2975
3001
  e.report({ phase: "Choosing edges", total: null });
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));
3002
+ const i = Ma(a, n), o = /* @__PURE__ */ new Set();
3003
+ for (const d of i.edges)
3004
+ o.add(P(d.source, d.target)), o.add(P(d.target, d.source));
2979
3005
  const r = [];
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)) } });
3006
+ return await S(e, "Marking the network", t, (d) => {
3007
+ r.push({ id: d.id, values: { in: o.has(P(d.source, d.target)) } });
2982
3008
  }), {
2983
3009
  shape: "edge-set",
2984
- fields: je("edge", { name: "totalWeight", type: "number" }),
3010
+ fields: Ze("edge", { name: "totalWeight", type: "number" }),
2985
3011
  edges: r,
2986
3012
  graph: { totalWeight: i.totalWeight },
2987
- caveats: M({
3013
+ caveats: C({
2988
3014
  method: "prim",
2989
3015
  direction: "undirected",
2990
3016
  weight: { attribute: "weight", meaning: "distance" },
@@ -2993,7 +3019,7 @@ const Oa = {
2993
3019
  };
2994
3020
  }
2995
3021
  };
2996
- _.namespace = "graphty", _.type = "prim", _.zodOptionsSchema = Oa, _.optionsSchema = {
3022
+ ne.namespace = "graphty", ne.type = "prim", ne.scopeInput = "subgraph", ne.zodOptionsSchema = Ea, ne.optionsSchema = {
2997
3023
  startNode: {
2998
3024
  type: "nodeId",
2999
3025
  default: null,
@@ -3002,9 +3028,9 @@ _.namespace = "graphty", _.type = "prim", _.zodOptionsSchema = Oa, _.optionsSche
3002
3028
  required: !1
3003
3029
  }
3004
3030
  };
3005
- let De = _;
3006
- v.register(De);
3007
- const Ue = class Ue extends z {
3031
+ let Ke = ne;
3032
+ v.register(Ke);
3033
+ const fe = class fe extends E {
3008
3034
  /**
3009
3035
  * Find the pieces of the graph that a directed path can cross both ways.
3010
3036
  *
@@ -3015,23 +3041,23 @@ const Ue = class Ue extends z {
3015
3041
  * @returns The community result, or null when there are no nodes to group.
3016
3042
  */
3017
3043
  async compute(e) {
3018
- const t = Array.from(this.graph.getDataManager().nodes.keys());
3044
+ const t = R(this.input("declared"));
3019
3045
  if (t.length === 0)
3020
3046
  return null;
3021
3047
  const n = this.algorithmGraph("directed");
3022
3048
  e.report({ phase: "Finding pieces", total: null });
3023
- const a = Lt(n), i = /* @__PURE__ */ new Map();
3049
+ const a = Yt(n), i = /* @__PURE__ */ new Map();
3024
3050
  for (let r = 0; r < a.length; r++)
3025
- for (const l of a[r])
3026
- i.set(l, r);
3027
- const s = [];
3051
+ for (const d of a[r])
3052
+ i.set(d, r);
3053
+ const o = [];
3028
3054
  return await S(e, "Grouping nodes", t, (r) => {
3029
- s.push({ id: r, values: { group: i.get(r) ?? 0 } });
3055
+ o.push({ id: r, values: { group: i.get(r) ?? 0 } });
3030
3056
  }), {
3031
3057
  shape: "community",
3032
- fields: ee(!1),
3033
- nodes: s,
3034
- caveats: M({
3058
+ fields: oe(!1),
3059
+ nodes: o,
3060
+ caveats: C({
3035
3061
  method: "strongly-connected-components",
3036
3062
  direction: "directed",
3037
3063
  weight: null,
@@ -3040,38 +3066,38 @@ const Ue = class Ue extends z {
3040
3066
  };
3041
3067
  }
3042
3068
  };
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}` };
3069
+ fe.namespace = "graphty", fe.type = "scc", fe.scopeInput = "subgraph";
3070
+ let Le = fe;
3071
+ v.register(Le);
3072
+ const Da = "results.$";
3073
+ function g(s) {
3074
+ return { ...s, path: `${Da}.${s.name}` };
3049
3075
  }
3050
- function E(o, e) {
3076
+ function G(s, e) {
3051
3077
  return [
3052
- f({
3078
+ g({
3053
3079
  name: "value",
3054
3080
  plainName: e.plainName,
3055
3081
  technicalName: e.technicalName,
3056
- kind: o,
3082
+ kind: s,
3057
3083
  type: e.type ?? "number",
3058
3084
  ...e.unit === void 0 ? {} : { unit: e.unit }
3059
3085
  }),
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({
3086
+ g({ name: "rank", plainName: "Rank", technicalName: "rank", kind: s, type: "integer" }),
3087
+ g({ name: "percentile", plainName: "Percentile", technicalName: "percentile", kind: s, type: "number" }),
3088
+ g({ name: "min", plainName: "Lowest", technicalName: "min", kind: "graph", type: "number" }),
3089
+ g({ name: "max", plainName: "Highest", technicalName: "max", kind: "graph", type: "number" }),
3090
+ g({ name: "median", plainName: "Middle", technicalName: "median", kind: "graph", type: "number" }),
3091
+ g({ name: "mean", plainName: "Average", technicalName: "mean", kind: "graph", type: "number" }),
3092
+ g({ name: "measured", plainName: "Measured", technicalName: "measured", kind: "graph", type: "integer" }),
3093
+ g({
3068
3094
  name: "normalization",
3069
3095
  plainName: "Normalization",
3070
3096
  technicalName: "normalization",
3071
3097
  kind: "graph",
3072
3098
  type: "string"
3073
3099
  }),
3074
- f({
3100
+ g({
3075
3101
  name: "tiedAtMin",
3076
3102
  plainName: "Tied at the lowest value",
3077
3103
  technicalName: "tiedAtMin",
@@ -3080,33 +3106,33 @@ function E(o, e) {
3080
3106
  })
3081
3107
  ];
3082
3108
  }
3083
- function te(o, e) {
3109
+ function re(s, e) {
3084
3110
  const t = [
3085
- f({ name: "group", plainName: o, technicalName: "group", kind: "node", type: "integer" }),
3086
- f({
3111
+ g({ name: "group", plainName: s, technicalName: "group", kind: "node", type: "integer" }),
3112
+ g({
3087
3113
  name: "groupSize",
3088
- plainName: `${o} size`,
3114
+ plainName: `${s} size`,
3089
3115
  technicalName: "groupSize",
3090
3116
  kind: "node",
3091
3117
  type: "integer"
3092
3118
  }),
3093
- f({
3119
+ g({
3094
3120
  name: "groupCount",
3095
- plainName: `${o} count`,
3121
+ plainName: `${s} count`,
3096
3122
  technicalName: "groupCount",
3097
3123
  kind: "graph",
3098
3124
  type: "integer"
3099
3125
  }),
3100
- f({
3126
+ g({
3101
3127
  name: "sizes",
3102
- plainName: `${o} sizes`,
3128
+ plainName: `${s} sizes`,
3103
3129
  technicalName: "sizes",
3104
3130
  kind: "graph",
3105
3131
  type: "table"
3106
3132
  })
3107
3133
  ];
3108
3134
  return e && t.push(
3109
- f({
3135
+ g({
3110
3136
  name: "modularity",
3111
3137
  plainName: "Community strength",
3112
3138
  technicalName: "modularity",
@@ -3115,24 +3141,24 @@ function te(o, e) {
3115
3141
  })
3116
3142
  ), t;
3117
3143
  }
3118
- function oe(o, e, t) {
3144
+ function qe(s, e, t) {
3119
3145
  return [
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" })
3146
+ g({ name: "in", plainName: e, technicalName: "in", kind: s, type: "boolean" }),
3147
+ g({ name: "count", plainName: "Count", technicalName: "count", kind: "graph", type: "integer" }),
3148
+ g({ ...t, kind: "graph" })
3123
3149
  ];
3124
3150
  }
3125
- function k(o) {
3126
- return Ae(o.getZodOptionsSchema());
3151
+ function k(s) {
3152
+ return Qe(s.getZodOptionsSchema());
3127
3153
  }
3128
- function et(...o) {
3154
+ function ot(...s) {
3129
3155
  const e = [], t = /* @__PURE__ */ new Set();
3130
- for (const n of o)
3156
+ for (const n of s)
3131
3157
  for (const a of n)
3132
3158
  t.has(a.name) || (t.add(a.name), e.push(a));
3133
3159
  return e;
3134
3160
  }
3135
- const Ia = {
3161
+ const Pa = {
3136
3162
  method: {
3137
3163
  schema: c.enum(["dijkstra", "bellman-ford"]).nullable().default(null),
3138
3164
  meta: {
@@ -3142,7 +3168,7 @@ const Ia = {
3142
3168
  group: "engine"
3143
3169
  }
3144
3170
  }
3145
- }, Ma = {
3171
+ }, Ra = {
3146
3172
  strength: {
3147
3173
  schema: c.enum(["weak", "strong"]).default("weak"),
3148
3174
  meta: {
@@ -3150,7 +3176,7 @@ const Ia = {
3150
3176
  description: "Weak follows an edge in either direction. Strong needs a directed path each way, and only differs from weak on a directed graph."
3151
3177
  }
3152
3178
  }
3153
- }, ot = [
3179
+ }, $a = [
3154
3180
  {
3155
3181
  key: "degree",
3156
3182
  plainName: "Connections",
@@ -3159,15 +3185,20 @@ const Ia = {
3159
3185
  category: "centrality",
3160
3186
  shape: "node-metric",
3161
3187
  fields: [
3162
- ...E("node", { plainName: "Connections", technicalName: "degree", type: "integer", unit: "links" }),
3163
- f({
3188
+ ...G("node", {
3189
+ plainName: "Connections",
3190
+ technicalName: "degree",
3191
+ type: "integer",
3192
+ unit: "links"
3193
+ }),
3194
+ g({
3164
3195
  name: "inDegree",
3165
3196
  plainName: "Incoming connections",
3166
3197
  technicalName: "inDegree",
3167
3198
  kind: "node",
3168
3199
  type: "integer"
3169
3200
  }),
3170
- f({
3201
+ g({
3171
3202
  name: "outDegree",
3172
3203
  plainName: "Outgoing connections",
3173
3204
  technicalName: "outDegree",
@@ -3175,7 +3206,7 @@ const Ia = {
3175
3206
  type: "integer"
3176
3207
  })
3177
3208
  ],
3178
- options: k(ge),
3209
+ options: k(Se),
3179
3210
  costClass: "instant",
3180
3211
  complexity: "O(n + m)",
3181
3212
  legacyKeys: [{ key: "degree" }]
@@ -3187,8 +3218,8 @@ const Ia = {
3187
3218
  description: "Scores a node by how many of the shortest paths between other nodes run through it, which is what finds the bridges.",
3188
3219
  category: "centrality",
3189
3220
  shape: "node-metric",
3190
- fields: E("node", { plainName: "Bridging", technicalName: "betweenness" }),
3191
- options: k(de),
3221
+ fields: G("node", { plainName: "Bridging", technicalName: "betweenness" }),
3222
+ options: k(be),
3192
3223
  costClass: "heavy",
3193
3224
  complexity: "O(n * m)",
3194
3225
  legacyKeys: [{ key: "betweenness" }]
@@ -3200,8 +3231,8 @@ const Ia = {
3200
3231
  description: "Scores a node by how short its paths to the rest of the graph are, which is what finds the nodes that reach everything quickly.",
3201
3232
  category: "centrality",
3202
3233
  shape: "node-metric",
3203
- fields: E("node", { plainName: "Reach", technicalName: "closeness" }),
3204
- options: k(pe),
3234
+ fields: G("node", { plainName: "Reach", technicalName: "closeness" }),
3235
+ options: k(Ne),
3205
3236
  costClass: "heavy",
3206
3237
  complexity: "O(n * m)",
3207
3238
  legacyKeys: [{ key: "closeness" }]
@@ -3213,8 +3244,8 @@ const Ia = {
3213
3244
  description: "Ranks a node by the influence that flows into it from the nodes that point at it.",
3214
3245
  category: "centrality",
3215
3246
  shape: "node-metric",
3216
- fields: E("node", { plainName: "Influence", technicalName: "PageRank score" }),
3217
- options: k(Ee),
3247
+ fields: G("node", { plainName: "Influence", technicalName: "PageRank score" }),
3248
+ options: k(We),
3218
3249
  costClass: "iterative",
3219
3250
  complexity: "O(k(n + m))",
3220
3251
  legacyKeys: [{ key: "pagerank" }]
@@ -3226,8 +3257,8 @@ const Ia = {
3226
3257
  description: "Scores a node by how influential its neighbours are, so a few important connections count for more than many unimportant ones.",
3227
3258
  category: "centrality",
3228
3259
  shape: "node-metric",
3229
- fields: E("node", { plainName: "Influence by association", technicalName: "eigenvector score" }),
3230
- options: k(be),
3260
+ fields: G("node", { plainName: "Influence by association", technicalName: "eigenvector score" }),
3261
+ options: k(Ie),
3231
3262
  costClass: "iterative",
3232
3263
  complexity: "O(k(n + m))",
3233
3264
  legacyKeys: [{ key: "eigenvector" }]
@@ -3239,8 +3270,8 @@ const Ia = {
3239
3270
  description: "Scores a node by every path that reaches it, with a longer path counting for less.",
3240
3271
  category: "centrality",
3241
3272
  shape: "node-metric",
3242
- fields: E("node", { plainName: "Influence at a distance", technicalName: "Katz score" }),
3243
- options: k(ke),
3273
+ fields: G("node", { plainName: "Influence at a distance", technicalName: "Katz score" }),
3274
+ options: k(Ee),
3244
3275
  costClass: "iterative",
3245
3276
  complexity: "O(k(n + m))",
3246
3277
  legacyKeys: [{ key: "katz" }]
@@ -3253,9 +3284,9 @@ const Ia = {
3253
3284
  category: "centrality",
3254
3285
  shape: "node-metric",
3255
3286
  fields: [
3256
- ...E("node", { plainName: "Hub and authority", technicalName: "combined HITS score" }),
3257
- f({ name: "hub", plainName: "Hub", technicalName: "hub score", kind: "node", type: "number" }),
3258
- f({
3287
+ ...G("node", { plainName: "Hub and authority", technicalName: "combined HITS score" }),
3288
+ g({ name: "hub", plainName: "Hub", technicalName: "hub score", kind: "node", type: "number" }),
3289
+ g({
3259
3290
  name: "authority",
3260
3291
  plainName: "Authority",
3261
3292
  technicalName: "authority score",
@@ -3263,7 +3294,7 @@ const Ia = {
3263
3294
  type: "number"
3264
3295
  })
3265
3296
  ],
3266
- options: k(Ne),
3297
+ options: k(ze),
3267
3298
  costClass: "iterative",
3268
3299
  complexity: "O(k(n + m))",
3269
3300
  legacyKeys: [{ key: "hits" }]
@@ -3275,8 +3306,8 @@ const Ia = {
3275
3306
  description: "Groups nodes into communities by repeatedly merging the groups whose merger tightens the partition the most.",
3276
3307
  category: "community",
3277
3308
  shape: "community",
3278
- fields: te("Community", !0),
3279
- options: k(Ce),
3309
+ fields: re("Community", !0),
3310
+ options: k(Fe),
3280
3311
  costClass: "iterative",
3281
3312
  complexity: "O(k(n + m))",
3282
3313
  legacyKeys: [{ key: "louvain" }]
@@ -3288,8 +3319,8 @@ const Ia = {
3288
3319
  description: "Groups nodes into communities the way Louvain does, with a refinement pass that rules out groups held together by a single node.",
3289
3320
  category: "community",
3290
3321
  shape: "community",
3291
- fields: te("Community", !0),
3292
- options: k(Ie),
3322
+ fields: re("Community", !0),
3323
+ options: k(Re),
3293
3324
  costClass: "iterative",
3294
3325
  complexity: "O(k(n + m))",
3295
3326
  legacyKeys: [{ key: "leiden" }]
@@ -3301,8 +3332,8 @@ const Ia = {
3301
3332
  description: "Groups nodes into communities by letting every node repeatedly take whichever label most of its neighbours carry.",
3302
3333
  category: "community",
3303
3334
  shape: "community",
3304
- fields: te("Community", !1),
3305
- options: k(xe),
3335
+ fields: re("Community", !1),
3336
+ options: k(Pe),
3306
3337
  costClass: "iterative",
3307
3338
  complexity: "O(k(n + m))",
3308
3339
  legacyKeys: [{ key: "label-propagation" }]
@@ -3314,8 +3345,8 @@ const Ia = {
3314
3345
  description: "Groups nodes into communities by repeatedly cutting the edge that the most shortest paths run through, until the graph falls apart.",
3315
3346
  category: "community",
3316
3347
  shape: "community",
3317
- fields: te("Community", !0),
3318
- options: k(ve),
3348
+ fields: re("Community", !0),
3349
+ options: k(Te),
3319
3350
  costClass: "heavy",
3320
3351
  complexity: "O(n * m^2)",
3321
3352
  legacyKeys: [{ key: "girvan-newman" }]
@@ -3327,11 +3358,11 @@ const Ia = {
3327
3358
  description: "Finds the separate pieces of the graph: two nodes belong to the same piece when a path joins them.",
3328
3359
  category: "structure",
3329
3360
  shape: "community",
3330
- fields: te("Piece", !1),
3331
- options: et(
3332
- k(me),
3333
- k(Pe),
3334
- Ae(Ma)
3361
+ fields: re("Piece", !1),
3362
+ options: ot(
3363
+ k(ke),
3364
+ k(Le),
3365
+ Qe(Ra)
3335
3366
  ),
3336
3367
  costClass: "instant",
3337
3368
  complexity: "O(n + m)",
@@ -3345,14 +3376,50 @@ const Ia = {
3345
3376
  category: "path",
3346
3377
  shape: "path",
3347
3378
  fields: [
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({
3379
+ g({
3380
+ name: "onPath",
3381
+ plainName: "On the route",
3382
+ technicalName: "onPath",
3383
+ kind: "node",
3384
+ type: "boolean"
3385
+ }),
3386
+ g({
3387
+ name: "order",
3388
+ plainName: "Position on the route",
3389
+ technicalName: "order",
3390
+ kind: "node",
3391
+ type: "integer"
3392
+ }),
3393
+ g({
3394
+ name: "distance",
3395
+ plainName: "Distance from the source",
3396
+ technicalName: "distance",
3397
+ kind: "node",
3398
+ type: "number"
3399
+ }),
3400
+ g({
3401
+ name: "onPath",
3402
+ plainName: "On the route",
3403
+ technicalName: "onPath",
3404
+ kind: "edge",
3405
+ type: "boolean"
3406
+ }),
3407
+ g({
3408
+ name: "length",
3409
+ plainName: "Nodes on the route",
3410
+ technicalName: "length",
3411
+ kind: "graph",
3412
+ type: "integer"
3413
+ }),
3414
+ g({ name: "cost", plainName: "Total cost", technicalName: "cost", kind: "graph", type: "number" }),
3415
+ g({
3416
+ name: "hops",
3417
+ plainName: "Edges on the route",
3418
+ technicalName: "hops",
3419
+ kind: "graph",
3420
+ type: "integer"
3421
+ }),
3422
+ g({
3356
3423
  name: "hasNegativeCycle",
3357
3424
  plainName: "Has a loop that costs less every time round",
3358
3425
  technicalName: "hasNegativeCycle",
@@ -3360,10 +3427,10 @@ const Ia = {
3360
3427
  type: "boolean"
3361
3428
  })
3362
3429
  ],
3363
- options: et(
3430
+ options: ot(
3431
+ k(xe),
3364
3432
  k(ye),
3365
- k(le),
3366
- Ae(Ia)
3433
+ Qe(Pa)
3367
3434
  ),
3368
3435
  costClass: "instant",
3369
3436
  complexity: "O((n + m) log n) with dijkstra, O(n * m) with bellman-ford",
@@ -3388,10 +3455,22 @@ const Ia = {
3388
3455
  category: "path",
3389
3456
  shape: "node-metric",
3390
3457
  fields: [
3391
- ...E("node", { plainName: "Distance to the furthest node", technicalName: "eccentricity" }),
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({
3458
+ ...G("node", { plainName: "Distance to the furthest node", technicalName: "eccentricity" }),
3459
+ g({
3460
+ name: "diameter",
3461
+ plainName: "Widest distance",
3462
+ technicalName: "diameter",
3463
+ kind: "graph",
3464
+ type: "number"
3465
+ }),
3466
+ g({
3467
+ name: "radius",
3468
+ plainName: "Narrowest distance",
3469
+ technicalName: "radius",
3470
+ kind: "graph",
3471
+ type: "number"
3472
+ }),
3473
+ g({
3395
3474
  name: "hasNegativeCycle",
3396
3475
  plainName: "Has a loop that costs less every time round",
3397
3476
  technicalName: "hasNegativeCycle",
@@ -3399,7 +3478,7 @@ const Ia = {
3399
3478
  type: "boolean"
3400
3479
  })
3401
3480
  ],
3402
- options: k(we),
3481
+ options: k(Ce),
3403
3482
  costClass: "cubic",
3404
3483
  complexity: "O(n^3)",
3405
3484
  legacyKeys: [{ key: "floyd-warshall" }]
@@ -3412,14 +3491,32 @@ const Ia = {
3412
3491
  category: "path",
3413
3492
  shape: "layered-grouping",
3414
3493
  fields: [
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" })
3494
+ g({ name: "level", plainName: "Steps away", technicalName: "level", kind: "node", type: "integer" }),
3495
+ g({
3496
+ name: "levelSize",
3497
+ plainName: "Nodes this many steps away",
3498
+ technicalName: "levelSize",
3499
+ kind: "node",
3500
+ type: "integer"
3501
+ }),
3502
+ g({ name: "order", plainName: "Visit order", technicalName: "order", kind: "node", type: "integer" }),
3503
+ g({
3504
+ name: "levelCount",
3505
+ plainName: "Levels",
3506
+ technicalName: "levelCount",
3507
+ kind: "graph",
3508
+ type: "integer"
3509
+ }),
3510
+ g({ name: "sizes", plainName: "Level sizes", technicalName: "sizes", kind: "graph", type: "table" }),
3511
+ g({
3512
+ name: "targetFound",
3513
+ plainName: "Target reached",
3514
+ technicalName: "targetFound",
3515
+ kind: "graph",
3516
+ type: "boolean"
3517
+ })
3421
3518
  ],
3422
- options: k(he),
3519
+ options: k(we),
3423
3520
  costClass: "instant",
3424
3521
  complexity: "O(n + m)",
3425
3522
  legacyKeys: [{ key: "bfs" }]
@@ -3432,10 +3529,14 @@ const Ia = {
3432
3529
  category: "path",
3433
3530
  shape: "node-metric",
3434
3531
  fields: [
3435
- ...E("node", { plainName: "Exploration order", technicalName: "discovery time", type: "integer" }),
3436
- f({ name: "visited", plainName: "Reached", technicalName: "visited", kind: "node", type: "boolean" })
3532
+ ...G("node", {
3533
+ plainName: "Exploration order",
3534
+ technicalName: "discovery time",
3535
+ type: "integer"
3536
+ }),
3537
+ g({ name: "visited", plainName: "Reached", technicalName: "visited", kind: "node", type: "boolean" })
3437
3538
  ],
3438
- options: k(fe),
3539
+ options: k(Oe),
3439
3540
  costClass: "instant",
3440
3541
  complexity: "O(n + m)",
3441
3542
  legacyKeys: [{ key: "dfs" }]
@@ -3447,13 +3548,13 @@ const Ia = {
3447
3548
  description: "Finds the cheapest set of edges that still joins every node, by taking the cheapest edge that does not close a loop.",
3448
3549
  category: "structure",
3449
3550
  shape: "edge-set",
3450
- fields: oe("edge", "In the network", {
3551
+ fields: qe("edge", "In the network", {
3451
3552
  name: "totalWeight",
3452
3553
  plainName: "Total cost",
3453
3554
  technicalName: "totalWeight",
3454
3555
  type: "number"
3455
3556
  }),
3456
- options: k(Oe),
3557
+ options: k(De),
3457
3558
  costClass: "instant",
3458
3559
  complexity: "O(m log m)",
3459
3560
  requires: { directed: !1 },
@@ -3466,13 +3567,13 @@ const Ia = {
3466
3567
  description: "Finds the cheapest set of edges that still joins every node, by growing outwards from one starting node.",
3467
3568
  category: "structure",
3468
3569
  shape: "edge-set",
3469
- fields: oe("edge", "In the network", {
3570
+ fields: qe("edge", "In the network", {
3470
3571
  name: "totalWeight",
3471
3572
  plainName: "Total cost",
3472
3573
  technicalName: "totalWeight",
3473
3574
  type: "number"
3474
3575
  }),
3475
- options: k(De),
3576
+ options: k(Ke),
3476
3577
  costClass: "instant",
3477
3578
  complexity: "O(m log n)",
3478
3579
  requires: { directed: !1 },
@@ -3486,16 +3587,16 @@ const Ia = {
3486
3587
  category: "structure",
3487
3588
  shape: "edge-set",
3488
3589
  fields: [
3489
- ...oe("edge", "In the pairing", {
3590
+ ...qe("edge", "In the pairing", {
3490
3591
  name: "bipartite",
3491
3592
  plainName: "Has two sides",
3492
3593
  technicalName: "bipartite",
3493
3594
  type: "boolean"
3494
3595
  }),
3495
- f({ name: "side", plainName: "Side", technicalName: "side", kind: "node", type: "string" }),
3496
- f({ name: "matched", plainName: "Paired", technicalName: "matched", kind: "node", type: "boolean" })
3596
+ g({ name: "side", plainName: "Side", technicalName: "side", kind: "node", type: "string" }),
3597
+ g({ name: "matched", plainName: "Paired", technicalName: "matched", kind: "node", type: "boolean" })
3497
3598
  ],
3498
- options: k(ue),
3599
+ options: k(ve),
3499
3600
  costClass: "heavy",
3500
3601
  complexity: "O(n * m)",
3501
3602
  requires: { directed: !1 },
@@ -3509,14 +3610,26 @@ const Ia = {
3509
3610
  category: "flow",
3510
3611
  shape: "edge-metric",
3511
3612
  fields: [
3512
- ...E("edge", { plainName: "Flow", technicalName: "flow" }),
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" })
3613
+ ...G("edge", { plainName: "Flow", technicalName: "flow" }),
3614
+ g({ name: "capacity", plainName: "Capacity", technicalName: "capacity", kind: "edge", type: "number" }),
3615
+ g({
3616
+ name: "utilization",
3617
+ plainName: "Share of capacity used",
3618
+ technicalName: "utilization",
3619
+ kind: "edge",
3620
+ type: "number"
3621
+ }),
3622
+ g({ name: "netFlow", plainName: "Net flow", technicalName: "netFlow", kind: "node", type: "number" }),
3623
+ g({ name: "role", plainName: "Source or sink", technicalName: "role", kind: "node", type: "string" }),
3624
+ g({
3625
+ name: "maxFlow",
3626
+ plainName: "Most that can flow",
3627
+ technicalName: "maxFlow",
3628
+ kind: "graph",
3629
+ type: "number"
3630
+ })
3518
3631
  ],
3519
- options: k(ze),
3632
+ options: k(Ge),
3520
3633
  costClass: "heavy",
3521
3634
  complexity: "O(n * m^2)",
3522
3635
  legacyKeys: [{ key: "max-flow" }]
@@ -3529,15 +3642,15 @@ const Ia = {
3529
3642
  category: "flow",
3530
3643
  shape: "edge-set",
3531
3644
  fields: [
3532
- ...oe("edge", "In the cut", {
3645
+ ...qe("edge", "In the cut", {
3533
3646
  name: "cutValue",
3534
3647
  plainName: "Cost of the cut",
3535
3648
  technicalName: "cutValue",
3536
3649
  type: "number"
3537
3650
  }),
3538
- f({ name: "side", plainName: "Side", technicalName: "side", kind: "node", type: "string" })
3651
+ g({ name: "side", plainName: "Side", technicalName: "side", kind: "node", type: "string" })
3539
3652
  ],
3540
- options: k(Te),
3653
+ options: k(He),
3541
3654
  costClass: "heavy",
3542
3655
  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",
3543
3656
  legacyKeys: [{ key: "min-cut" }]
@@ -3549,8 +3662,8 @@ const Ia = {
3549
3662
  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
3663
  category: "structure",
3551
3664
  shape: "node-metric",
3552
- fields: E("node", { plainName: "Core depth", technicalName: "core number", type: "integer" }),
3553
- options: k(Se),
3665
+ fields: G("node", { plainName: "Core depth", technicalName: "core number", type: "integer" }),
3666
+ options: k(Me),
3554
3667
  costClass: "instant",
3555
3668
  complexity: "O(n + m)",
3556
3669
  legacyKeys: [{ key: "k-core" }]
@@ -3563,65 +3676,102 @@ const Ia = {
3563
3676
  category: "prediction",
3564
3677
  shape: "pair-list",
3565
3678
  fields: [
3566
- f({ name: "pairs", plainName: "Likely new links", technicalName: "pairs", kind: "graph", type: "table" })
3679
+ g({
3680
+ name: "pairs",
3681
+ plainName: "Likely new links",
3682
+ technicalName: "pairs",
3683
+ kind: "graph",
3684
+ type: "table"
3685
+ })
3567
3686
  ],
3568
- options: k(Me),
3687
+ options: k($e),
3569
3688
  costClass: "heavy",
3570
3689
  complexity: "O(n^2 * d)",
3571
3690
  legacyKeys: [{ key: "link-prediction" }]
3572
3691
  }
3573
- ];
3574
- function ja(o) {
3575
- return ot.find((e) => e.key === o);
3692
+ ], Fa = new Map(
3693
+ [
3694
+ ye,
3695
+ be,
3696
+ we,
3697
+ ve,
3698
+ Ne,
3699
+ ke,
3700
+ Se,
3701
+ Oe,
3702
+ xe,
3703
+ Ie,
3704
+ Ce,
3705
+ Te,
3706
+ ze,
3707
+ Ee,
3708
+ Me,
3709
+ De,
3710
+ Pe,
3711
+ Re,
3712
+ $e,
3713
+ Fe,
3714
+ Ge,
3715
+ He,
3716
+ We,
3717
+ Ke,
3718
+ Le
3719
+ ].map((s) => [s.type, s])
3720
+ ), ht = $a.map((s) => ({
3721
+ ...s,
3722
+ scopeInput: s.legacyKeys.every((e) => Fa.get(e.key)?.scopeInput === "subgraph") ? "subgraph" : "none"
3723
+ }));
3724
+ function Aa(s) {
3725
+ return ht.find((e) => e.key === s);
3576
3726
  }
3577
- function Va(o) {
3578
- for (const e of ot)
3727
+ function _a(s) {
3728
+ for (const e of ht)
3579
3729
  for (const t of e.legacyKeys)
3580
- if (t.key === o)
3730
+ if (t.key === s)
3581
3731
  return { descriptor: e, params: t.params ?? {} };
3582
3732
  }
3583
3733
  export {
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
3734
+ He as A,
3735
+ ht as B,
3736
+ lt as C,
3737
+ Se as D,
3738
+ Ie as E,
3739
+ Ce as F,
3740
+ Te as G,
3741
+ ze as H,
3742
+ Me as I,
3743
+ $e as J,
3744
+ Ee as K,
3745
+ Fe as L,
3746
+ Ge as M,
3747
+ _t as N,
3748
+ ta as O,
3749
+ We as P,
3750
+ Le as S,
3751
+ dt as a,
3752
+ Ue as b,
3753
+ Aa as c,
3754
+ _a as d,
3755
+ Ja as e,
3756
+ Xa as f,
3757
+ Ya as g,
3758
+ Za as h,
3759
+ Va as i,
3760
+ qa as j,
3761
+ Qa as k,
3762
+ ea as l,
3763
+ Ba as m,
3764
+ xe as n,
3765
+ be as o,
3766
+ Ne as p,
3767
+ Re as q,
3768
+ Pe as r,
3769
+ ye as s,
3770
+ Xt as t,
3771
+ we as u,
3772
+ Oe as v,
3773
+ ke as w,
3774
+ De as x,
3775
+ Ke as y,
3776
+ ve as z
3627
3777
  };