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