@graphty/graphty-element 2.5.1 → 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.
- package/dist/ai.js +3 -3
- package/dist/catalog.d.ts +16 -0
- package/dist/catalog.js +34 -32
- package/dist/chunks/{AiManager-CrbvKdEK.js → AiManager-4iQpsJW1.js} +4 -4
- package/dist/chunks/{DataSource-qU-nLhXN.js → DataSource-BL2UzPff.js} +2 -2
- package/dist/chunks/GraphSession-BhuHSXIo.js +12819 -0
- package/dist/chunks/{GraphtyLogger-DOTwCiMR.js → GraphtyLogger-B_O67a6c.js} +1 -1
- package/dist/chunks/{VoiceInputAdapter-D4NrRL_1.js → VoiceInputAdapter-Cc6mHXTI.js} +1 -1
- package/dist/chunks/{XRPivotCameraController-Uqa47vmo.js → XRPivotCameraController-BLa89LXn.js} +2 -2
- package/dist/chunks/{algorithms-D-ab-Auu.js → algorithms-BJ6DQMOe.js} +931 -781
- package/dist/chunks/{capability-check-Vw3IcqiE.js → capability-check-Am2zliFj.js} +1 -1
- package/dist/chunks/{detect-B4Qrw976.js → detect-fyuVnlCT.js} +1 -1
- package/dist/chunks/{format-detection-r2IfNFXO.js → format-detection-BHwrAVzW.js} +1 -1
- package/dist/chunks/{index-J9MgLio9.js → index-BkBLbvui.js} +2691 -2434
- package/dist/chunks/optionsFromZod-CKMYSwTz.js +3636 -0
- package/dist/chunks/{paletteRegistry-Kt-6CeoN.js → paletteRegistry-BCFSwJGK.js} +224 -189
- package/dist/chunks/parse-BMTqt4SS.js +3658 -0
- package/dist/chunks/{types-C_c53VgR.js → types-DFchv4Ny.js} +4 -1
- package/dist/custom-elements.json +1 -1
- package/dist/extend.d.ts +10 -8
- package/dist/extend.js +6 -6
- package/dist/graphty-catalog.json +75 -38
- package/dist/graphty.bundle.js +55368 -48970
- package/dist/graphty.js +19 -19
- package/dist/index.d.ts +1 -1
- package/dist/logging.js +2 -2
- package/dist/schema.d.ts +15 -1
- package/dist/schema.js +1 -1
- package/dist/session.d.ts +30 -7
- package/dist/session.js +40 -37
- package/dist/src/Graph.d.ts +35 -7
- package/dist/src/acceleration/types.d.ts +79 -43
- package/dist/src/algorithms/Algorithm.d.ts +52 -4
- package/dist/src/algorithms/BFSAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/BellmanFordAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/BetweennessCentralityAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/BipartiteMatchingAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/ClosenessCentralityAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/ConnectedComponentsAlgorithm.d.ts +4 -1
- package/dist/src/algorithms/DFSAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/DegreeAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/DijkstraAlgorithm.d.ts +6 -0
- package/dist/src/algorithms/EigenvectorCentralityAlgorithm.d.ts +2 -0
- package/dist/src/algorithms/FloydWarshallAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/GirvanNewmanAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/HITSAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/KCoreAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/KatzCentralityAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/KruskalAlgorithm.d.ts +4 -1
- package/dist/src/algorithms/LabelPropagationAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/LeidenAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/LinkPredictionAlgorithm.d.ts +4 -1
- package/dist/src/algorithms/LouvainAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/MaxFlowAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/MinCutAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/PageRankAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/PrimAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/StronglyConnectedComponentsAlgorithm.d.ts +3 -0
- package/dist/src/algorithms/input/ScopedInput.d.ts +185 -0
- package/dist/src/algorithms/input/derivedInputs.d.ts +199 -0
- package/dist/src/algorithms/input/maskBack.d.ts +37 -0
- package/dist/src/algorithms/metrics/MetricAlgorithm.d.ts +3 -3
- package/dist/src/algorithms/results/DeclaredAlgorithm.d.ts +4 -3
- package/dist/src/algorithms/results/types.d.ts +28 -6
- package/dist/src/algorithms/utils/communityUtils.d.ts +0 -48
- package/dist/src/algorithms/utils/graphUtils.d.ts +2 -68
- package/dist/src/algorithms/utils/snapshotGraph.d.ts +3 -1
- package/dist/src/catalog/algorithms.d.ts +3 -0
- package/dist/src/catalog/layouts.d.ts +2 -0
- package/dist/src/catalog/sets/canonical.d.ts +68 -0
- package/dist/src/catalog/sets/hash.d.ts +126 -0
- package/dist/src/catalog/sets/parse.d.ts +115 -0
- package/dist/src/catalog/types.d.ts +329 -8
- package/dist/src/data/GraphStore.d.ts +73 -1
- package/dist/src/data/edgeIdentity.d.ts +202 -1
- package/dist/src/data/ingest.d.ts +3 -1
- package/dist/src/data/report.d.ts +20 -0
- package/dist/src/graphty-element.d.ts +42 -6
- package/dist/src/layout/D3GraphLayoutEngine.d.ts +11 -0
- package/dist/src/layout/LayoutEngine.d.ts +56 -0
- package/dist/src/layout/NGraphLayoutEngine.d.ts +10 -0
- package/dist/src/layout/SimulationLayoutEngine.d.ts +11 -0
- package/dist/src/managers/AlgorithmManager.d.ts +8 -0
- package/dist/src/managers/DataManager.d.ts +11 -0
- package/dist/src/managers/LayoutManager.d.ts +126 -2
- package/dist/src/managers/StatsManager.d.ts +1 -0
- package/dist/src/session/GraphSession.d.ts +48 -0
- package/dist/src/session/attributes.d.ts +121 -1
- package/dist/src/session/cost/estimate.d.ts +20 -0
- package/dist/src/session/cost/index.d.ts +1 -1
- package/dist/src/session/planning.d.ts +32 -2
- package/dist/src/session/query.d.ts +7 -0
- package/dist/src/session/results/ResultsApi.d.ts +14 -1
- package/dist/src/session/runs/Run.d.ts +65 -4
- package/dist/src/session/runs/RunsApi.d.ts +58 -2
- package/dist/src/session/runs/runId.d.ts +55 -6
- package/dist/src/session/runs/types.d.ts +36 -8
- package/dist/src/session/scope/ElementMask.d.ts +14 -1
- package/dist/src/session/scope/ScopeApi.d.ts +160 -31
- package/dist/src/session/scope/index.d.ts +1 -1
- package/dist/src/session/selection/SelectionApi.d.ts +15 -10
- package/dist/src/session/selection/index.d.ts +1 -1
- package/dist/src/session/selection/targets.d.ts +6 -7
- package/dist/src/session/sets/SetsApi.d.ts +110 -0
- package/dist/src/session/sets/algebra.d.ts +124 -0
- package/dist/src/session/sets/cache.d.ts +197 -0
- package/dist/src/session/sets/captures.d.ts +83 -0
- package/dist/src/session/sets/dependencies.d.ts +167 -0
- package/dist/src/session/sets/layers.d.ts +101 -0
- package/dist/src/session/sets/notify.d.ts +122 -0
- package/dist/src/session/sets/offers.d.ts +103 -0
- package/dist/src/session/sets/path.d.ts +37 -0
- package/dist/src/session/sets/prepare.d.ts +209 -0
- package/dist/src/session/sets/resolve.d.ts +311 -0
- package/dist/src/session/sets/signature.d.ts +77 -0
- package/dist/src/session/sets/status.d.ts +98 -0
- package/dist/src/session/sets/store.d.ts +196 -0
- package/dist/src/session/sets/types.d.ts +386 -0
- package/dist/src/session/styles/Layer.d.ts +9 -2
- package/dist/src/session/styles/StylesApi.d.ts +5 -2
- package/dist/src/session/styles/explain.d.ts +5 -2
- package/dist/src/session/styles/predicate.d.ts +41 -2
- package/dist/src/session/styles/repaint.d.ts +19 -0
- package/dist/src/session/styles/selector.d.ts +16 -5
- package/dist/src/session/types.d.ts +18 -0
- package/dist/src/session/visibility/VisibilityApi.d.ts +47 -3
- package/dist/src/session/visibility/filter.d.ts +86 -51
- package/dist/src/session/visibility/index.d.ts +1 -1
- package/dist/src/testing/fakeAccelerator.d.ts +5 -0
- package/dist/src/utils/queue-migration.d.ts +17 -0
- package/package.json +15 -9
- package/dist/chunks/GraphSession-DuAhRgCd.js +0 -8622
- package/dist/chunks/optionsFromZod-B9RncoTX.js +0 -2578
- package/dist/chunks/scales-CJCRwi2J.js +0 -3220
- package/dist/src/algorithms/utils/index.d.ts +0 -6
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { E as
|
|
3
|
-
import {
|
|
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
|
|
6
|
-
import { G as
|
|
7
|
-
import { INVALID_INDEX as
|
|
8
|
-
var
|
|
9
|
-
function
|
|
10
|
-
return
|
|
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
|
|
13
|
-
function
|
|
14
|
-
return Number.isFinite(
|
|
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
|
|
17
|
-
return
|
|
16
|
+
function je(s) {
|
|
17
|
+
return s.toString(16).padStart(2, "0");
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
if (!
|
|
19
|
+
function Jt(s) {
|
|
20
|
+
if (!Zt.test(s))
|
|
21
21
|
return null;
|
|
22
|
-
const e =
|
|
23
|
-
const
|
|
24
|
-
return parseInt(
|
|
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
|
|
34
|
-
return typeof
|
|
33
|
+
function Ba(s) {
|
|
34
|
+
return typeof s != "object" || s === null || !("hex" in s) ? null : s;
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
if (
|
|
36
|
+
function Xt(s) {
|
|
37
|
+
if (s == null)
|
|
38
38
|
return null;
|
|
39
|
-
if (typeof
|
|
40
|
-
return
|
|
41
|
-
const e =
|
|
39
|
+
if (typeof s == "object")
|
|
40
|
+
return at(s);
|
|
41
|
+
const e = Jt(s);
|
|
42
42
|
if (e !== null)
|
|
43
|
-
return
|
|
43
|
+
return at(e);
|
|
44
44
|
try {
|
|
45
|
-
const t =
|
|
46
|
-
return t === void 0 ? null :
|
|
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
|
|
52
|
-
const e =
|
|
53
|
-
return { r: e, g: t, b: n, a, hex: a === 1 ? i : `${i}${
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
-
},
|
|
366
|
-
|
|
367
|
-
(
|
|
365
|
+
}, dt = Object.keys(Ue);
|
|
366
|
+
dt.filter(
|
|
367
|
+
(s) => Ue[s].accepts === "color"
|
|
368
368
|
);
|
|
369
|
-
function
|
|
370
|
-
return typeof
|
|
369
|
+
function ea(s) {
|
|
370
|
+
return typeof s == "string" && Object.hasOwn(Ue, s);
|
|
371
371
|
}
|
|
372
|
-
function
|
|
373
|
-
return
|
|
372
|
+
function Ya(s) {
|
|
373
|
+
return ea(s) ? Ue[s] : void 0;
|
|
374
374
|
}
|
|
375
|
-
function
|
|
376
|
-
return
|
|
377
|
-
(e) => e.target ===
|
|
375
|
+
function Za(s) {
|
|
376
|
+
return dt.map((e) => Ue[e]).filter(
|
|
377
|
+
(e) => e.target === s
|
|
378
378
|
);
|
|
379
379
|
}
|
|
380
|
-
const
|
|
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
|
|
418
|
-
return
|
|
417
|
+
function Ja(s) {
|
|
418
|
+
return lt.find((e) => e.id === s) ?? ft(s)?.descriptor;
|
|
419
419
|
}
|
|
420
|
-
function
|
|
421
|
-
return [...
|
|
422
|
-
(e) => e.modes.includes(
|
|
420
|
+
function Xa(s) {
|
|
421
|
+
return [...lt, ...yt()].filter(
|
|
422
|
+
(e) => e.modes.includes(s)
|
|
423
423
|
);
|
|
424
424
|
}
|
|
425
|
-
function
|
|
426
|
-
return
|
|
425
|
+
function Qa(s) {
|
|
426
|
+
return s;
|
|
427
427
|
}
|
|
428
|
-
function
|
|
428
|
+
function ta(s) {
|
|
429
429
|
const e = {};
|
|
430
|
-
for (const [t, n] of Object.entries(
|
|
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
|
|
435
|
-
return
|
|
434
|
+
function aa(s, e) {
|
|
435
|
+
return ta(s).parse(e);
|
|
436
436
|
}
|
|
437
|
-
function
|
|
438
|
-
return `${String(
|
|
437
|
+
function P(s, e) {
|
|
438
|
+
return `${String(s)}:${String(e)}`;
|
|
439
439
|
}
|
|
440
|
-
function
|
|
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
|
|
443
|
+
throw new ct({
|
|
444
444
|
code: "E_OPTION_RANGE",
|
|
445
445
|
source: "run",
|
|
446
|
-
message: `${
|
|
447
|
-
details: { algorithm:
|
|
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
|
|
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
|
-
},
|
|
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.
|
|
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],
|
|
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 =
|
|
498
|
-
|
|
499
|
-
for (const
|
|
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
|
|
502
|
-
await S(e, "Marking the route", n, (
|
|
503
|
-
const
|
|
504
|
-
|
|
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
|
|
507
|
-
await S(e, "Marking the route",
|
|
508
|
-
const
|
|
509
|
-
p.push({ id:
|
|
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
|
|
512
|
-
return r.hasNegativeCycle &&
|
|
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
|
-
...
|
|
515
|
+
...rt,
|
|
516
516
|
{ name: "distance", kind: "node", type: "number" },
|
|
517
517
|
{ name: "hasNegativeCycle", kind: "graph", type: "boolean" }
|
|
518
518
|
],
|
|
519
|
-
nodes:
|
|
519
|
+
nodes: u,
|
|
520
520
|
edges: p,
|
|
521
521
|
graph: {
|
|
522
|
-
length:
|
|
523
|
-
cost:
|
|
524
|
-
hops: Math.max(
|
|
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:
|
|
527
|
+
caveats: C({
|
|
528
528
|
method: "bellman-ford",
|
|
529
529
|
direction: "undirected",
|
|
530
530
|
weight: { attribute: "weight", meaning: "distance" },
|
|
531
|
-
notes:
|
|
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(
|
|
557
|
+
t.add(P(e[n], e[n + 1]));
|
|
558
558
|
return t;
|
|
559
559
|
}
|
|
560
560
|
};
|
|
561
|
-
|
|
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
|
|
578
|
-
v.register(
|
|
579
|
-
const
|
|
580
|
-
function
|
|
577
|
+
let ye = V;
|
|
578
|
+
v.register(ye);
|
|
579
|
+
const ia = 2048;
|
|
580
|
+
function sa(s) {
|
|
581
581
|
return {
|
|
582
|
-
runId:
|
|
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
|
|
592
|
-
const a =
|
|
591
|
+
async function W(s, e, t, n) {
|
|
592
|
+
const a = s.length;
|
|
593
593
|
let i = performance.now();
|
|
594
|
-
for (let
|
|
595
|
-
e.signal.throwIfAborted(), n(o
|
|
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
|
|
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(
|
|
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.
|
|
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),
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
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
|
|
664
|
+
const oa = U({
|
|
663
665
|
plainName: "Bridging",
|
|
664
666
|
technicalName: "betweenness"
|
|
665
|
-
}),
|
|
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
|
|
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 =
|
|
689
|
+
const a = St(n);
|
|
688
690
|
e.signal.throwIfAborted();
|
|
689
691
|
const i = [];
|
|
690
|
-
return await
|
|
691
|
-
const r = a[String(
|
|
692
|
-
i.push({ id:
|
|
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
|
-
|
|
713
|
-
let
|
|
714
|
-
v.register(
|
|
715
|
-
const
|
|
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
|
-
},
|
|
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 =
|
|
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.
|
|
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,
|
|
766
|
-
const { snapshot:
|
|
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:
|
|
769
|
-
for (let
|
|
770
|
-
|
|
771
|
-
const
|
|
772
|
-
return await S(e, "Recording levels", t, (
|
|
773
|
-
const
|
|
774
|
-
|
|
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: [...
|
|
778
|
-
nodes:
|
|
779
|
-
caveats:
|
|
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:
|
|
784
|
-
notes: [`Walked outwards from ${String(
|
|
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
|
|
801
|
-
let
|
|
802
|
-
e.report({ phase: "Walking outwards", total: null }),
|
|
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: (
|
|
805
|
-
|
|
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, (
|
|
810
|
-
const p =
|
|
811
|
-
p !== void 0 && h.push({ id:
|
|
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
|
-
...
|
|
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:
|
|
821
|
-
caveats:
|
|
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
|
-
|
|
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
|
|
851
|
-
v.register(
|
|
852
|
-
const
|
|
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 =
|
|
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
|
-
...
|
|
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 =
|
|
872
|
+
const i = xt(n);
|
|
874
873
|
if (i === null) {
|
|
875
|
-
const
|
|
874
|
+
const l = [];
|
|
876
875
|
return await S(e, "Marking the pairing", t, (p) => {
|
|
877
|
-
|
|
876
|
+
l.push({ id: p.id, values: { in: !1 } });
|
|
878
877
|
}), {
|
|
879
878
|
shape: "edge-set",
|
|
880
879
|
fields: a,
|
|
881
|
-
edges:
|
|
880
|
+
edges: l,
|
|
882
881
|
graph: { bipartite: !1 },
|
|
883
|
-
caveats:
|
|
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
|
|
891
|
+
const o = It(n, {
|
|
893
892
|
leftNodes: i.left,
|
|
894
893
|
rightNodes: i.right
|
|
895
894
|
}), r = /* @__PURE__ */ new Set();
|
|
896
|
-
for (const [
|
|
897
|
-
r.add(
|
|
898
|
-
const
|
|
899
|
-
await S(e, "Marking the pairing", t, (
|
|
900
|
-
|
|
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(
|
|
903
|
-
return await S(e, "Marking sides", Array.from(i.left), (
|
|
904
|
-
|
|
905
|
-
}), await S(e, "Marking sides", Array.from(i.right), (
|
|
906
|
-
|
|
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:
|
|
911
|
-
edges:
|
|
909
|
+
nodes: u,
|
|
910
|
+
edges: d,
|
|
912
911
|
graph: { bipartite: !0 },
|
|
913
|
-
caveats:
|
|
912
|
+
caveats: C({
|
|
914
913
|
method: "bipartite-matching",
|
|
915
914
|
direction: "undirected",
|
|
916
915
|
weight: null,
|
|
917
|
-
notes: [`${String(
|
|
916
|
+
notes: [`${String(o.size)} of the two sides' nodes found a partner.`]
|
|
918
917
|
})
|
|
919
918
|
};
|
|
920
919
|
}
|
|
921
920
|
};
|
|
922
|
-
|
|
923
|
-
let
|
|
924
|
-
v.register(
|
|
925
|
-
const
|
|
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
|
-
}),
|
|
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
|
|
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 =
|
|
949
|
+
const a = Ct(n);
|
|
951
950
|
e.signal.throwIfAborted();
|
|
952
951
|
const i = [];
|
|
953
|
-
return await
|
|
954
|
-
const r = a[String(
|
|
955
|
-
i.push({ id:
|
|
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
|
-
|
|
976
|
-
let
|
|
977
|
-
v.register(
|
|
978
|
-
const
|
|
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 =
|
|
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:
|
|
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
|
|
997
|
-
|
|
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:
|
|
1001
|
-
nodes:
|
|
1002
|
-
caveats:
|
|
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
|
-
|
|
1013
|
-
let
|
|
1014
|
-
v.register(
|
|
1015
|
-
const
|
|
1016
|
-
|
|
1017
|
-
|
|
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
|
-
|
|
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
|
-
],
|
|
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
|
|
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
|
|
1048
|
-
const
|
|
1049
|
-
a.push({ id: i, values: { value:
|
|
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: [
|
|
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
|
-
|
|
1066
|
-
let
|
|
1067
|
-
v.register(
|
|
1068
|
-
const
|
|
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
|
-
},
|
|
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.
|
|
1126
|
-
if (
|
|
1126
|
+
const t = R(this.input("undirected"));
|
|
1127
|
+
if (t.length === 0)
|
|
1127
1128
|
return null;
|
|
1128
|
-
const
|
|
1129
|
-
if (!t.
|
|
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
|
|
1132
|
+
const r = this.algorithmGraph("undirected");
|
|
1132
1133
|
e.report({ phase: "Walking deep", total: null });
|
|
1133
|
-
const
|
|
1134
|
-
targetNode:
|
|
1135
|
-
recursive:
|
|
1136
|
-
preOrder:
|
|
1137
|
-
}),
|
|
1138
|
-
|
|
1139
|
-
const
|
|
1140
|
-
return await S(e, "Recording the order",
|
|
1141
|
-
const
|
|
1142
|
-
|
|
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: [...
|
|
1146
|
-
nodes:
|
|
1147
|
-
caveats:
|
|
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: [
|
|
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
|
-
|
|
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
|
|
1188
|
-
v.register(
|
|
1189
|
-
const
|
|
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
|
-
},
|
|
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.
|
|
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:
|
|
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:
|
|
1247
|
-
|
|
1248
|
-
const
|
|
1249
|
-
await S(e, "Marking the route", n, (
|
|
1250
|
-
const
|
|
1251
|
-
|
|
1252
|
-
id:
|
|
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:
|
|
1255
|
-
order:
|
|
1256
|
-
distance:
|
|
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
|
-
|
|
1262
|
-
const
|
|
1263
|
-
|
|
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: [...
|
|
1267
|
-
nodes:
|
|
1268
|
-
edges:
|
|
1273
|
+
fields: [...rt, { name: "distance", kind: "node", type: "number" }],
|
|
1274
|
+
nodes: w,
|
|
1275
|
+
edges: D,
|
|
1269
1276
|
graph: {
|
|
1270
|
-
length:
|
|
1271
|
-
cost:
|
|
1272
|
-
hops: Math.max(
|
|
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:
|
|
1281
|
+
caveats: C({
|
|
1275
1282
|
method: "dijkstra",
|
|
1276
1283
|
direction: "undirected",
|
|
1277
1284
|
weight: { attribute: "weight", meaning: "distance" },
|
|
1278
|
-
precision:
|
|
1279
|
-
notes:
|
|
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
|
-
|
|
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
|
|
1308
|
-
v.register(
|
|
1309
|
-
const
|
|
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
|
-
},
|
|
1357
|
+
}, pa = U({
|
|
1351
1358
|
plainName: "Influence by association",
|
|
1352
1359
|
technicalName: "eigenvector score"
|
|
1353
|
-
}),
|
|
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
|
|
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:
|
|
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
|
|
1382
|
+
let l;
|
|
1376
1383
|
try {
|
|
1377
|
-
|
|
1384
|
+
l = zt(u, {
|
|
1378
1385
|
normalized: i,
|
|
1379
1386
|
maxIterations: n,
|
|
1380
1387
|
tolerance: a,
|
|
1381
|
-
mode:
|
|
1388
|
+
mode: o,
|
|
1382
1389
|
endpoints: r,
|
|
1383
|
-
startVector:
|
|
1390
|
+
startVector: d
|
|
1384
1391
|
});
|
|
1385
|
-
} catch (
|
|
1386
|
-
if (!(
|
|
1387
|
-
throw
|
|
1388
|
-
const
|
|
1389
|
-
throw new
|
|
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:
|
|
1395
|
-
cause:
|
|
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
|
|
1401
|
-
const
|
|
1402
|
-
p.push({ id:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
1476
|
-
v.register(
|
|
1477
|
-
const
|
|
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 =
|
|
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 =
|
|
1508
|
+
const a = Mt(n), i = /* @__PURE__ */ new Map();
|
|
1502
1509
|
await S(e, "Measuring reach", t, (h) => {
|
|
1503
|
-
const
|
|
1504
|
-
if (
|
|
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
|
|
1509
|
-
for (const p of
|
|
1510
|
-
isFinite(p) && p >
|
|
1511
|
-
i.set(h,
|
|
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
|
|
1520
|
+
let o = 0, r = 1 / 0;
|
|
1514
1521
|
for (const h of i.values())
|
|
1515
|
-
isFinite(h) && (
|
|
1522
|
+
isFinite(h) && (o = Math.max(o, h), r = Math.min(r, h));
|
|
1516
1523
|
r === 1 / 0 && (r = 0);
|
|
1517
|
-
const
|
|
1524
|
+
const d = [];
|
|
1518
1525
|
return await S(e, "Publishing distances", t, (h) => {
|
|
1519
|
-
const
|
|
1520
|
-
isFinite(
|
|
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
|
-
...
|
|
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:
|
|
1530
|
-
graph: { diameter:
|
|
1531
|
-
caveats:
|
|
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
|
-
|
|
1543
|
-
let
|
|
1544
|
-
v.register(
|
|
1545
|
-
const
|
|
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
|
-
},
|
|
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 =
|
|
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,
|
|
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 =
|
|
1592
|
+
const r = Dt(o, {
|
|
1586
1593
|
maxCommunities: n > 0 ? n : void 0,
|
|
1587
1594
|
minCommunitySize: a,
|
|
1588
1595
|
maxIterations: i
|
|
1589
|
-
}),
|
|
1590
|
-
(
|
|
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
|
-
),
|
|
1593
|
-
if (
|
|
1594
|
-
for (let
|
|
1595
|
-
for (const
|
|
1596
|
-
|
|
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((
|
|
1605
|
+
t.forEach((m, f) => l.set(m, f));
|
|
1599
1606
|
const p = [];
|
|
1600
|
-
return await S(e, "Grouping nodes", t, (
|
|
1601
|
-
p.push({ id:
|
|
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:
|
|
1611
|
+
fields: oe(!0),
|
|
1605
1612
|
nodes: p,
|
|
1606
|
-
graph: { modularity:
|
|
1607
|
-
caveats:
|
|
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:
|
|
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
|
-
|
|
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
|
|
1645
|
-
v.register(
|
|
1646
|
-
const
|
|
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
|
-
},
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
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
|
-
],
|
|
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
|
|
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:
|
|
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 =
|
|
1726
|
+
const h = Pt(d, {
|
|
1720
1727
|
maxIterations: n,
|
|
1721
1728
|
tolerance: a,
|
|
1722
1729
|
normalized: i,
|
|
1723
|
-
mode:
|
|
1730
|
+
mode: o,
|
|
1724
1731
|
endpoints: r
|
|
1725
1732
|
});
|
|
1726
1733
|
e.signal.throwIfAborted();
|
|
1727
|
-
const
|
|
1728
|
-
return await
|
|
1729
|
-
const p = h.hubs[String(
|
|
1730
|
-
if (p === void 0 ||
|
|
1731
|
-
|
|
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
|
-
|
|
1741
|
+
u.push({ id: l, values: { value: (p + m) / 2, hub: p, authority: m } });
|
|
1735
1742
|
}), {
|
|
1736
|
-
nodes:
|
|
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
|
-
|
|
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
|
|
1806
|
-
v.register(
|
|
1807
|
-
const
|
|
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
|
-
},
|
|
1872
|
+
}, ba = U({
|
|
1866
1873
|
plainName: "Influence at a distance",
|
|
1867
1874
|
technicalName: "Katz score"
|
|
1868
|
-
}),
|
|
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
|
|
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:
|
|
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
|
|
1897
|
+
const l = Rt(u, {
|
|
1891
1898
|
normalized: r,
|
|
1892
1899
|
alpha: n,
|
|
1893
1900
|
beta: a,
|
|
1894
1901
|
maxIterations: i,
|
|
1895
|
-
tolerance:
|
|
1896
|
-
mode:
|
|
1902
|
+
tolerance: o,
|
|
1903
|
+
mode: d,
|
|
1897
1904
|
endpoints: h
|
|
1898
1905
|
});
|
|
1899
1906
|
e.signal.throwIfAborted();
|
|
1900
1907
|
const p = [];
|
|
1901
|
-
return await
|
|
1902
|
-
const
|
|
1903
|
-
p.push({ id:
|
|
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(
|
|
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
|
-
|
|
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
|
|
1993
|
-
v.register(
|
|
1994
|
-
const
|
|
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
|
-
}),
|
|
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
|
|
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 } =
|
|
2022
|
+
const { coreness: a } = $t(n);
|
|
2016
2023
|
e.signal.throwIfAborted();
|
|
2017
2024
|
const i = [];
|
|
2018
|
-
return await
|
|
2019
|
-
const r = a.get(String(
|
|
2020
|
-
i.push({ id:
|
|
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
|
-
|
|
2037
|
-
let
|
|
2038
|
-
v.register(
|
|
2039
|
-
const
|
|
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 =
|
|
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:
|
|
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
|
|
2058
|
-
|
|
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:
|
|
2062
|
-
edges:
|
|
2068
|
+
fields: Ze("edge", { name: "totalWeight", type: "number" }),
|
|
2069
|
+
edges: d,
|
|
2063
2070
|
graph: { totalWeight: i.totalWeight },
|
|
2064
|
-
caveats:
|
|
2071
|
+
caveats: C({
|
|
2065
2072
|
method: "kruskal",
|
|
2066
2073
|
direction: "undirected",
|
|
2067
2074
|
weight: { attribute: "weight", meaning: "distance" },
|
|
2068
|
-
precision:
|
|
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
|
-
|
|
2075
|
-
let
|
|
2076
|
-
v.register(
|
|
2077
|
-
const
|
|
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
|
-
},
|
|
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 =
|
|
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
|
|
2117
|
+
const o = Ft(i, {
|
|
2111
2118
|
maxIterations: n,
|
|
2112
2119
|
randomSeed: a
|
|
2113
2120
|
}), r = [];
|
|
2114
|
-
return await S(e, "Grouping nodes", t, (
|
|
2115
|
-
r.push({ id:
|
|
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:
|
|
2125
|
+
fields: oe(!1),
|
|
2119
2126
|
nodes: r,
|
|
2120
|
-
caveats:
|
|
2127
|
+
caveats: C({
|
|
2121
2128
|
method: "label-propagation",
|
|
2122
2129
|
direction: "undirected",
|
|
2123
2130
|
weight: { attribute: "weight", meaning: "strength" },
|
|
2124
|
-
converged:
|
|
2125
|
-
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
|
-
|
|
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
|
|
2152
|
-
v.register(
|
|
2153
|
-
const
|
|
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
|
-
},
|
|
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 =
|
|
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:
|
|
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
|
|
2209
|
+
const d = Gt(r, {
|
|
2203
2210
|
resolution: n,
|
|
2204
2211
|
randomSeed: a,
|
|
2205
2212
|
maxIterations: i,
|
|
2206
|
-
threshold:
|
|
2213
|
+
threshold: o
|
|
2207
2214
|
}), h = [];
|
|
2208
|
-
return await S(e, "Grouping nodes", t, (
|
|
2209
|
-
h.push({ id:
|
|
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:
|
|
2219
|
+
fields: oe(!0),
|
|
2213
2220
|
nodes: h,
|
|
2214
|
-
graph: { modularity:
|
|
2215
|
-
caveats:
|
|
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:
|
|
2226
|
+
iterations: d.iterations,
|
|
2220
2227
|
notes: [`Resolution ${String(n)}.`]
|
|
2221
2228
|
})
|
|
2222
2229
|
};
|
|
2223
2230
|
}
|
|
2224
2231
|
};
|
|
2225
|
-
|
|
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
|
|
2264
|
-
v.register(
|
|
2265
|
-
const
|
|
2266
|
-
"adamic-adar":
|
|
2267
|
-
"common-neighbors":
|
|
2268
|
-
},
|
|
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
|
-
},
|
|
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.
|
|
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(),
|
|
2295
|
-
const h = [String(r), String(
|
|
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:
|
|
2302
|
-
caveats:
|
|
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
|
-
|
|
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
|
|
2334
|
-
v.register(
|
|
2335
|
-
const
|
|
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
|
-
},
|
|
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 =
|
|
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:
|
|
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
|
|
2390
|
+
const d = Kt(r, {
|
|
2385
2391
|
resolution: n,
|
|
2386
2392
|
maxIterations: a,
|
|
2387
2393
|
tolerance: i,
|
|
2388
|
-
useOptimized:
|
|
2394
|
+
useOptimized: o
|
|
2389
2395
|
}), h = /* @__PURE__ */ new Map();
|
|
2390
|
-
for (let
|
|
2391
|
-
for (const p of
|
|
2392
|
-
h.set(p,
|
|
2393
|
-
const
|
|
2394
|
-
return await S(e, "Grouping nodes", t, (
|
|
2395
|
-
|
|
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:
|
|
2399
|
-
nodes:
|
|
2400
|
-
graph: { modularity:
|
|
2401
|
-
caveats:
|
|
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
|
-
|
|
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
|
|
2447
|
-
v.register(
|
|
2448
|
-
const
|
|
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
|
-
},
|
|
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.
|
|
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,
|
|
2493
|
-
for (const
|
|
2494
|
-
h.addNode(String(
|
|
2495
|
-
const
|
|
2496
|
-
for (const
|
|
2497
|
-
const
|
|
2498
|
-
|
|
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
|
|
2502
|
-
for (const [
|
|
2503
|
-
for (const [
|
|
2504
|
-
|
|
2505
|
-
const
|
|
2506
|
-
await S(e, "Measuring edges", n, (
|
|
2507
|
-
const
|
|
2508
|
-
|
|
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
|
|
2511
|
-
return await S(e, "Measuring nodes", a, (
|
|
2512
|
-
const
|
|
2513
|
-
|
|
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
|
-
...
|
|
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:
|
|
2525
|
-
edges:
|
|
2526
|
-
graph: { maxFlow:
|
|
2527
|
-
caveats:
|
|
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 ${
|
|
2533
|
-
...i === 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
|
-
...
|
|
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
|
-
|
|
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
|
|
2559
|
-
v.register(
|
|
2560
|
-
const
|
|
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
|
-
},
|
|
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.
|
|
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(),
|
|
2634
|
-
for (const
|
|
2635
|
-
|
|
2636
|
-
for (
|
|
2637
|
-
const
|
|
2638
|
-
|
|
2639
|
-
}
|
|
2640
|
-
const
|
|
2641
|
-
let
|
|
2642
|
-
if (e.report({ phase: "Finding the cut", total: null }),
|
|
2643
|
-
|
|
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
|
-
|
|
2646
|
-
const
|
|
2647
|
-
(
|
|
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
|
|
2650
|
-
for (const
|
|
2651
|
-
|
|
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
|
-
|
|
2659
|
-
const
|
|
2660
|
-
N.push({ id:
|
|
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
|
-
...
|
|
2670
|
+
...Ze("edge", { name: "cutValue", type: "number" }),
|
|
2665
2671
|
{ name: "side", kind: "node", type: "string" }
|
|
2666
2672
|
],
|
|
2667
|
-
nodes:
|
|
2668
|
-
edges:
|
|
2673
|
+
nodes: z,
|
|
2674
|
+
edges: N,
|
|
2669
2675
|
graph: { cutValue: x },
|
|
2670
|
-
caveats:
|
|
2671
|
-
method:
|
|
2676
|
+
caveats: C({
|
|
2677
|
+
method: T,
|
|
2672
2678
|
direction: "undirected",
|
|
2673
2679
|
weight: { attribute: "weight", meaning: "strength" },
|
|
2674
|
-
exact:
|
|
2675
|
-
iterations:
|
|
2680
|
+
exact: T !== "karger",
|
|
2681
|
+
iterations: T === "karger" ? b : void 0,
|
|
2676
2682
|
notes: [
|
|
2677
|
-
|
|
2678
|
-
...
|
|
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
|
-
|
|
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
|
|
2724
|
-
v.register(
|
|
2725
|
-
const
|
|
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
|
-
},
|
|
2772
|
+
}, Ca = U({
|
|
2767
2773
|
plainName: "Influence",
|
|
2768
2774
|
technicalName: "PageRank score"
|
|
2769
|
-
}),
|
|
2770
|
-
function
|
|
2771
|
-
return
|
|
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
|
|
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 =
|
|
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
|
|
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:
|
|
2800
|
-
directed: this.
|
|
2801
|
-
hasInitialRanks:
|
|
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 (
|
|
2805
|
-
const { snapshot:
|
|
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:
|
|
2813
|
-
(
|
|
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:
|
|
2825
|
+
weighted: o !== null
|
|
2820
2826
|
})
|
|
2821
2827
|
);
|
|
2822
2828
|
e.signal.throwIfAborted();
|
|
2823
|
-
const { ids:
|
|
2824
|
-
await
|
|
2825
|
-
const
|
|
2826
|
-
|
|
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
|
|
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
|
|
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:
|
|
2841
|
+
nodes: T,
|
|
2836
2842
|
normalization: "none",
|
|
2837
2843
|
caveats: {
|
|
2838
2844
|
exact: !0,
|
|
2839
2845
|
direction: "directed",
|
|
2840
|
-
weight:
|
|
2841
|
-
precision:
|
|
2846
|
+
weight: o === null ? null : { attribute: o, meaning: "strength" },
|
|
2847
|
+
precision: I,
|
|
2842
2848
|
method: "power-iteration",
|
|
2843
|
-
converged:
|
|
2844
|
-
iterations:
|
|
2845
|
-
notes:
|
|
2849
|
+
converged: O.converged,
|
|
2850
|
+
iterations: O.iterations,
|
|
2851
|
+
notes: F
|
|
2846
2852
|
}
|
|
2847
2853
|
};
|
|
2848
2854
|
}
|
|
2849
|
-
const
|
|
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
|
|
2862
|
+
const m = qt(l, {
|
|
2857
2863
|
dampingFactor: n,
|
|
2858
2864
|
maxIterations: a,
|
|
2859
2865
|
tolerance: i,
|
|
2860
|
-
weight:
|
|
2866
|
+
weight: o ?? void 0,
|
|
2861
2867
|
useDelta: r,
|
|
2862
|
-
initialRanks:
|
|
2868
|
+
initialRanks: d,
|
|
2863
2869
|
personalization: h
|
|
2864
2870
|
});
|
|
2865
2871
|
e.signal.throwIfAborted();
|
|
2866
|
-
const
|
|
2867
|
-
await
|
|
2868
|
-
const
|
|
2869
|
-
|
|
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
|
|
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: ${
|
|
2880
|
+
`Computed on the CPU reference implementation: ${u}.`
|
|
2875
2881
|
];
|
|
2876
|
-
return
|
|
2877
|
-
nodes:
|
|
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:
|
|
2889
|
+
weight: o === null ? null : { attribute: o, meaning: "strength" },
|
|
2884
2890
|
precision: "f64",
|
|
2885
2891
|
method: p ? "delta-pagerank" : "power-iteration",
|
|
2886
|
-
converged:
|
|
2887
|
-
iterations:
|
|
2888
|
-
notes:
|
|
2892
|
+
converged: m.converged,
|
|
2893
|
+
iterations: m.iterations,
|
|
2894
|
+
notes: M
|
|
2889
2895
|
}
|
|
2890
2896
|
};
|
|
2891
2897
|
}
|
|
2892
2898
|
};
|
|
2893
|
-
|
|
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
|
|
2938
|
-
v.register(
|
|
2939
|
-
const
|
|
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
|
-
}
|
|
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 =
|
|
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 =
|
|
2977
|
-
for (const
|
|
2978
|
-
|
|
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, (
|
|
2981
|
-
r.push({ id:
|
|
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:
|
|
3010
|
+
fields: Ze("edge", { name: "totalWeight", type: "number" }),
|
|
2985
3011
|
edges: r,
|
|
2986
3012
|
graph: { totalWeight: i.totalWeight },
|
|
2987
|
-
caveats:
|
|
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
|
-
|
|
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
|
|
3006
|
-
v.register(
|
|
3007
|
-
const
|
|
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 =
|
|
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 =
|
|
3049
|
+
const a = Yt(n), i = /* @__PURE__ */ new Map();
|
|
3024
3050
|
for (let r = 0; r < a.length; r++)
|
|
3025
|
-
for (const
|
|
3026
|
-
i.set(
|
|
3027
|
-
const
|
|
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
|
-
|
|
3055
|
+
o.push({ id: r, values: { group: i.get(r) ?? 0 } });
|
|
3030
3056
|
}), {
|
|
3031
3057
|
shape: "community",
|
|
3032
|
-
fields:
|
|
3033
|
-
nodes:
|
|
3034
|
-
caveats:
|
|
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
|
-
|
|
3044
|
-
let
|
|
3045
|
-
v.register(
|
|
3046
|
-
const
|
|
3047
|
-
function
|
|
3048
|
-
return { ...
|
|
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
|
|
3076
|
+
function G(s, e) {
|
|
3051
3077
|
return [
|
|
3052
|
-
|
|
3078
|
+
g({
|
|
3053
3079
|
name: "value",
|
|
3054
3080
|
plainName: e.plainName,
|
|
3055
3081
|
technicalName: e.technicalName,
|
|
3056
|
-
kind:
|
|
3082
|
+
kind: s,
|
|
3057
3083
|
type: e.type ?? "number",
|
|
3058
3084
|
...e.unit === void 0 ? {} : { unit: e.unit }
|
|
3059
3085
|
}),
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
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
|
-
|
|
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
|
|
3109
|
+
function re(s, e) {
|
|
3084
3110
|
const t = [
|
|
3085
|
-
|
|
3086
|
-
|
|
3111
|
+
g({ name: "group", plainName: s, technicalName: "group", kind: "node", type: "integer" }),
|
|
3112
|
+
g({
|
|
3087
3113
|
name: "groupSize",
|
|
3088
|
-
plainName: `${
|
|
3114
|
+
plainName: `${s} size`,
|
|
3089
3115
|
technicalName: "groupSize",
|
|
3090
3116
|
kind: "node",
|
|
3091
3117
|
type: "integer"
|
|
3092
3118
|
}),
|
|
3093
|
-
|
|
3119
|
+
g({
|
|
3094
3120
|
name: "groupCount",
|
|
3095
|
-
plainName: `${
|
|
3121
|
+
plainName: `${s} count`,
|
|
3096
3122
|
technicalName: "groupCount",
|
|
3097
3123
|
kind: "graph",
|
|
3098
3124
|
type: "integer"
|
|
3099
3125
|
}),
|
|
3100
|
-
|
|
3126
|
+
g({
|
|
3101
3127
|
name: "sizes",
|
|
3102
|
-
plainName: `${
|
|
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
|
-
|
|
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
|
|
3144
|
+
function qe(s, e, t) {
|
|
3119
3145
|
return [
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
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(
|
|
3126
|
-
return
|
|
3151
|
+
function k(s) {
|
|
3152
|
+
return Qe(s.getZodOptionsSchema());
|
|
3127
3153
|
}
|
|
3128
|
-
function
|
|
3154
|
+
function ot(...s) {
|
|
3129
3155
|
const e = [], t = /* @__PURE__ */ new Set();
|
|
3130
|
-
for (const n of
|
|
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
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
...
|
|
3163
|
-
|
|
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
|
-
|
|
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(
|
|
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:
|
|
3191
|
-
options: k(
|
|
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:
|
|
3204
|
-
options: k(
|
|
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:
|
|
3217
|
-
options: k(
|
|
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:
|
|
3230
|
-
options: k(
|
|
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:
|
|
3243
|
-
options: k(
|
|
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
|
-
...
|
|
3257
|
-
|
|
3258
|
-
|
|
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(
|
|
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:
|
|
3279
|
-
options: k(
|
|
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:
|
|
3292
|
-
options: k(
|
|
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:
|
|
3305
|
-
options: k(
|
|
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:
|
|
3318
|
-
options: k(
|
|
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:
|
|
3331
|
-
options:
|
|
3332
|
-
k(
|
|
3333
|
-
k(
|
|
3334
|
-
|
|
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
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
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:
|
|
3430
|
+
options: ot(
|
|
3431
|
+
k(xe),
|
|
3364
3432
|
k(ye),
|
|
3365
|
-
|
|
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
|
-
...
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
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(
|
|
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
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
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(
|
|
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
|
-
...
|
|
3436
|
-
|
|
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(
|
|
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:
|
|
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(
|
|
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:
|
|
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(
|
|
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
|
-
...
|
|
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
|
-
|
|
3496
|
-
|
|
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(
|
|
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
|
-
...
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
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(
|
|
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
|
-
...
|
|
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
|
-
|
|
3651
|
+
g({ name: "side", plainName: "Side", technicalName: "side", kind: "node", type: "string" })
|
|
3539
3652
|
],
|
|
3540
|
-
options: k(
|
|
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:
|
|
3553
|
-
options: k(
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
3575
|
-
|
|
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
|
|
3578
|
-
for (const e of
|
|
3727
|
+
function _a(s) {
|
|
3728
|
+
for (const e of ht)
|
|
3579
3729
|
for (const t of e.legacyKeys)
|
|
3580
|
-
if (t.key ===
|
|
3730
|
+
if (t.key === s)
|
|
3581
3731
|
return { descriptor: e, params: t.params ?? {} };
|
|
3582
3732
|
}
|
|
3583
3733
|
export {
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
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
|
};
|