@graphty/graphty-element 2.0.1 → 2.2.1
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/README.md +3 -3
- package/dist/ai.js +4 -4
- package/dist/catalog.js +5 -5
- package/dist/chunks/{AiManager-awS0MNr1.js → AiManager-Dp1mOkPm.js} +5 -5
- package/dist/chunks/{Algorithm-BdcqHKps.js → Algorithm-RQ629NLb.js} +210 -92
- package/dist/chunks/{DataSource-DK4GZBKg.js → DataSource-DEg3igzS.js} +3 -3
- package/dist/chunks/{GraphSession-D87eymV8.js → GraphSession-D3AV8tpF.js} +2527 -2248
- package/dist/chunks/{GraphtyError-B3eKs4yg.js → GraphtyError-BwcnblTH.js} +10 -8
- package/dist/chunks/{GraphtyLogger-CK03SnJi.js → GraphtyLogger-5KEttFUo.js} +1 -1
- package/dist/chunks/{NodeStyle-CS7dj20m.js → NodeStyle-Cup9O1lu.js} +2 -1
- package/dist/chunks/{VoiceInputAdapter-CcnCmxo5.js → VoiceInputAdapter-Bbze1r8k.js} +1 -1
- package/dist/chunks/{XRPivotCameraController-UjMsbran.js → XRPivotCameraController-8Il3KxFm.js} +2 -2
- package/dist/chunks/{cameras-BeIAlMWR.js → cameras-CeJYi-Na.js} +17 -18
- package/dist/chunks/{capability-check-DcKFwS6q.js → capability-check-EUCOfQLP.js} +1 -1
- package/dist/chunks/{detect-B-YbbP7i.js → detect-CqN0mC6u.js} +3 -3
- package/dist/chunks/{format-detection-DohSEZnb.js → format-detection-C8vbCSlS.js} +1 -1
- package/dist/chunks/{index-uohvGegX.js → index-Cz47b_vU.js} +1957 -1318
- package/dist/chunks/{paletteRegistry-B-oS4YxP.js → paletteRegistry-NrWOKT-A.js} +17 -17
- package/dist/chunks/{registry-DU-e49Y2.js → registry-CSba5QGJ.js} +1 -1
- package/dist/chunks/{scales-DvGid5Ln.js → scales-ulKMZPfG.js} +2206 -1357
- package/dist/custom-elements.json +1 -1
- package/dist/extend.js +26 -27
- package/dist/graphty-catalog.json +7 -4
- package/dist/graphty.bundle.js +36572 -34379
- package/dist/graphty.js +66 -64
- package/dist/index.d.ts +1 -1
- package/dist/logging.js +2 -2
- package/dist/schema.js +1 -1
- package/dist/session.d.ts +2 -1
- package/dist/session.js +37 -33
- package/dist/src/Edge.d.ts +1 -1
- package/dist/src/Graph.d.ts +42 -8
- package/dist/src/Node.d.ts +3 -4
- package/dist/src/acceleration/AccelerationController.d.ts +27 -0
- package/dist/src/acceleration/index.d.ts +1 -1
- package/dist/src/acceleration/narrow.d.ts +56 -0
- package/dist/src/acceleration/types.d.ts +88 -7
- package/dist/src/algorithms/Algorithm.d.ts +96 -2
- package/dist/src/algorithms/BFSAlgorithm.d.ts +9 -0
- package/dist/src/algorithms/DijkstraAlgorithm.d.ts +2 -8
- package/dist/src/algorithms/PageRankAlgorithm.d.ts +8 -0
- package/dist/src/algorithms/utils/graphUtils.d.ts +13 -0
- package/dist/src/cameras/OrbitCameraController.d.ts +1 -0
- package/dist/src/catalog/layouts.d.ts +13 -1
- package/dist/src/config/GraphBehavior.d.ts +16 -0
- package/dist/src/config/GraphStyle.d.ts +1 -1
- package/dist/src/config/StyleTemplate.d.ts +10 -0
- package/dist/src/data/CSVDataSource.d.ts +1 -0
- package/dist/src/data/csv-variant-detection.d.ts +11 -0
- package/dist/src/errors/codes.d.ts +14 -1
- package/dist/src/events.d.ts +17 -4
- package/dist/src/graphty-element.d.ts +52 -4
- package/dist/src/layout/ForceAtlas2LayoutEngine.d.ts +28 -45
- package/dist/src/layout/LayoutEngine.d.ts +7 -7
- package/dist/src/layout/SimulationLayoutEngine.d.ts +458 -0
- package/dist/src/layout/SpringElectricalLayoutEngine.d.ts +32 -0
- package/dist/src/layout/SpringLayoutEngine.d.ts +22 -32
- package/dist/src/managers/DataManager.d.ts +2 -0
- package/dist/src/managers/EventManager.d.ts +7 -0
- package/dist/src/managers/GraphContext.d.ts +6 -0
- package/dist/src/managers/LabelDeclutter.d.ts +97 -0
- package/dist/src/managers/LayoutManager.d.ts +98 -4
- package/dist/src/managers/RenderManager.d.ts +7 -0
- package/dist/src/managers/UpdateManager.d.ts +1 -1
- package/dist/src/meshes/NodeEffects.d.ts +29 -5
- package/dist/src/meshes/RichTextLabel.d.ts +17 -0
- package/dist/src/session/catalog.d.ts +2 -2
- package/dist/src/session/query.d.ts +83 -0
- package/dist/src/session/runs/types.d.ts +10 -4
- package/dist/src/session/selection/targets.d.ts +20 -3
- package/dist/src/session/styles/StylesApi.d.ts +18 -0
- package/dist/src/session/styles/channels.d.ts +0 -2
- package/dist/src/session/styles/legend.d.ts +9 -0
- package/dist/src/session/styles/predicate.d.ts +11 -0
- package/dist/src/session/styles/sources.d.ts +16 -0
- package/dist/src/session/types.d.ts +38 -2
- package/dist/src/testing/fakeAccelerator.d.ts +323 -0
- package/dist/webgpu.d.ts +23 -1
- package/dist/webgpu.js +70 -32
- package/package.json +10 -8
- package/dist/chunks/types-Dwm9waL2.js +0 -7
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @graphty/graphty-element
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@graphty/graphty-element)
|
|
4
|
-
[](https://github.com/graphty-org/graphty-monorepo/actions/workflows/ci.yml)
|
|
5
5
|
[](https://coveralls.io/github/graphty-org/graphty-element?branch=master)
|
|
6
6
|
[](https://graphty.app/docs/graphty-element/)
|
|
7
|
-
[](https://graphty.app/storybook/element/)
|
|
7
|
+
[](https://graphty.app/storybook/graphty-element/)
|
|
8
8
|
|
|
9
9
|
A Web Component for 3D/2D graph visualization built with Lit and Babylon.js.
|
|
10
10
|
|
|
@@ -52,7 +52,7 @@ npm install @graphty/graphty-element @babylonjs/core lit
|
|
|
52
52
|
- [Getting Started Guide](https://graphty.app/docs/graphty-element/guide/getting-started)
|
|
53
53
|
- [Installation](https://graphty.app/docs/graphty-element/guide/installation)
|
|
54
54
|
- [API Reference](https://graphty.app/docs/graphty-element/api/)
|
|
55
|
-
- [Interactive Examples (Storybook)](https://graphty.app/storybook/element/)
|
|
55
|
+
- [Interactive Examples (Storybook)](https://graphty.app/storybook/graphty-element/)
|
|
56
56
|
|
|
57
57
|
## Features
|
|
58
58
|
|
package/dist/ai.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { f as p } from "./chunks/AiManager-
|
|
2
|
-
import { A as L, a as M, b as D, C as V, M as j, S as E, c as z, V as N, d as q, e as W, g as G, h as T, i as F, j as U, k as _, l as B, m as J, q as O, s as Y, n as H, o as Q, p as K, r as X, z as Z } from "./chunks/AiManager-
|
|
1
|
+
import { f as p } from "./chunks/AiManager-Dp1mOkPm.js";
|
|
2
|
+
import { A as L, a as M, b as D, C as V, M as j, S as E, c as z, V as N, d as q, e as W, g as G, h as T, i as F, j as U, k as _, l as B, m as J, q as O, s as Y, n as H, o as Q, p as K, r as X, z as Z } from "./chunks/AiManager-Dp1mOkPm.js";
|
|
3
3
|
import { A as te } from "./chunks/ApiKeyManager-C0ac91dE.js";
|
|
4
|
-
import { V as se } from "./chunks/VoiceInputAdapter-
|
|
4
|
+
import { V as se } from "./chunks/VoiceInputAdapter-Bbze1r8k.js";
|
|
5
5
|
import { z as r } from "zod";
|
|
6
|
-
import { A as u } from "./chunks/Algorithm-
|
|
6
|
+
import { A as u } from "./chunks/Algorithm-RQ629NLb.js";
|
|
7
7
|
const m = r.object({
|
|
8
8
|
namespace: r.string().describe("The namespace of the algorithm (e.g., 'graphty')"),
|
|
9
9
|
type: r.string().describe("The type of algorithm to run (e.g., 'degree', 'pagerank')")
|
package/dist/catalog.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { B as y, L as f, a as m, P as T, S, U as v, b as O, c as E, l as A, d as N, e as I, p as R, f as k, s as x, g as _ } from "./chunks/scales-
|
|
2
|
-
import { C, a as L, b as P, c as W, d as U, e as F, f as B } from "./chunks/cameras-
|
|
3
|
-
import { d as M, a as K } from "./chunks/detect-
|
|
4
|
-
import { F as Y, U as G, t as z, u as V, o as q } from "./chunks/paletteRegistry-
|
|
5
|
-
import { L as Z, l as $ } from "./chunks/GraphtyLogger-
|
|
1
|
+
import { B as y, L as f, a as m, P as T, S, U as v, b as O, c as E, l as A, d as N, e as I, p as R, f as k, s as x, g as _ } from "./chunks/scales-ulKMZPfG.js";
|
|
2
|
+
import { C, a as L, b as P, c as W, d as U, e as F, f as B } from "./chunks/cameras-CeJYi-Na.js";
|
|
3
|
+
import { d as M, a as K } from "./chunks/detect-CqN0mC6u.js";
|
|
4
|
+
import { F as Y, U as G, t as z, u as V, o as q } from "./chunks/paletteRegistry-NrWOKT-A.js";
|
|
5
|
+
import { L as Z, l as $ } from "./chunks/GraphtyLogger-5KEttFUo.js";
|
|
6
6
|
import { A as Q, C as ee, f as te, K as ae, a as oe, b as ne, c as re, d as ie, g as se, O as he, R as le, h as de, j as ce, k as we, i as ue, e as pe } from "./chunks/types-B7bX5c0K.js";
|
|
7
7
|
const d = Object.keys({
|
|
8
8
|
enabled: 0,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { l as _ } from "./VoiceInputAdapter-
|
|
2
|
-
import { G as K } from "./GraphtyLogger-
|
|
1
|
+
import { l as _ } from "./VoiceInputAdapter-Bbze1r8k.js";
|
|
2
|
+
import { G as K } from "./GraphtyLogger-5KEttFUo.js";
|
|
3
3
|
import W from "jmespath";
|
|
4
4
|
import { z as m } from "zod";
|
|
5
|
-
import { e as G } from "./Algorithm-
|
|
6
|
-
import { N as H, c as B, C as X } from "./cameras-
|
|
5
|
+
import { e as G } from "./Algorithm-RQ629NLb.js";
|
|
6
|
+
import { N as H, c as B, C as X } from "./cameras-CeJYi-Na.js";
|
|
7
7
|
import { inferSchema as C } from "@jsonhero/schema-infer";
|
|
8
|
-
import { i as Z } from "./GraphtyError-
|
|
8
|
+
import { i as Z } from "./GraphtyError-BwcnblTH.js";
|
|
9
9
|
import { createAnthropic as Y } from "@ai-sdk/anthropic";
|
|
10
10
|
import { createGoogleGenerativeAI as J } from "@ai-sdk/google";
|
|
11
11
|
import { createOpenAI as Q } from "@ai-sdk/openai";
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { q as
|
|
2
|
-
import { K as
|
|
3
|
-
import { G as d } from "./GraphtyError-
|
|
4
|
-
import { Graph as
|
|
5
|
-
|
|
1
|
+
import { q as C } from "./GraphtyLogger-5KEttFUo.js";
|
|
2
|
+
import { K as $, f as N } from "./types-B7bX5c0K.js";
|
|
3
|
+
import { G as d } from "./GraphtyError-BwcnblTH.js";
|
|
4
|
+
import { Graph as _, accelerated as y } from "@graphty/algorithms";
|
|
5
|
+
import { INVALID_INDEX as w } from "@graphty/graph-format";
|
|
6
|
+
const p = C({
|
|
6
7
|
kind: "camera",
|
|
7
8
|
idOf: (e) => e.descriptor.id,
|
|
8
9
|
descriptorOf: (e) => e.descriptor,
|
|
9
10
|
implementationOf: (e) => e.compute,
|
|
10
|
-
builtInIds: () =>
|
|
11
|
+
builtInIds: () => $
|
|
11
12
|
});
|
|
12
|
-
function
|
|
13
|
+
function K(e, t) {
|
|
13
14
|
const s = e.descriptor;
|
|
14
15
|
if (s === void 0 || typeof s != "object")
|
|
15
16
|
throw new d({
|
|
@@ -39,25 +40,57 @@ function R(e, t) {
|
|
|
39
40
|
source: "registry",
|
|
40
41
|
details: { kind: "camera", name: String(s.id), field: "compute" }
|
|
41
42
|
});
|
|
42
|
-
|
|
43
|
+
p.register(e, t);
|
|
44
|
+
}
|
|
45
|
+
function z() {
|
|
46
|
+
return p.descriptors();
|
|
47
|
+
}
|
|
48
|
+
function W(e) {
|
|
49
|
+
return p.byId(e);
|
|
50
|
+
}
|
|
51
|
+
function Y() {
|
|
52
|
+
p.clearForTesting();
|
|
43
53
|
}
|
|
44
|
-
|
|
45
|
-
|
|
54
|
+
const I = ["forceAtlas2", "fruchtermanReingold", "springElectrical", "release"], k = [
|
|
55
|
+
"pageRank",
|
|
56
|
+
"sssp",
|
|
57
|
+
"breadthFirstSearch",
|
|
58
|
+
"connectedComponents",
|
|
59
|
+
"weaklyConnectedComponents",
|
|
60
|
+
"minimumSpanningTree"
|
|
61
|
+
];
|
|
62
|
+
function H(e) {
|
|
63
|
+
const t = {
|
|
64
|
+
kind: e.backend
|
|
65
|
+
};
|
|
66
|
+
for (const s of I) {
|
|
67
|
+
const r = e[s];
|
|
68
|
+
typeof r == "function" && (t[s] = r.bind(e));
|
|
69
|
+
}
|
|
70
|
+
return t;
|
|
46
71
|
}
|
|
47
|
-
function
|
|
48
|
-
|
|
72
|
+
function R(e) {
|
|
73
|
+
const t = {
|
|
74
|
+
kind: e.backend
|
|
75
|
+
};
|
|
76
|
+
for (const s of k) {
|
|
77
|
+
const r = e[s];
|
|
78
|
+
typeof r == "function" && (t[s] = r.bind(e));
|
|
79
|
+
}
|
|
80
|
+
return t;
|
|
49
81
|
}
|
|
50
|
-
|
|
51
|
-
|
|
82
|
+
const D = ["auto", "off", "required"], Z = "auto";
|
|
83
|
+
function X(e) {
|
|
84
|
+
return typeof e == "string" && D.includes(e);
|
|
52
85
|
}
|
|
53
|
-
const
|
|
86
|
+
const M = "f64", J = "f32", Q = "acceleration.minNodes", ee = 0, g = C({
|
|
54
87
|
kind: "algorithm",
|
|
55
88
|
idOf: (e) => e.descriptor.key,
|
|
56
89
|
descriptorOf: (e) => e.descriptor,
|
|
57
90
|
implementationOf: (e) => e.descriptor,
|
|
58
|
-
builtInIds: () =>
|
|
91
|
+
builtInIds: () => N
|
|
59
92
|
});
|
|
60
|
-
function
|
|
93
|
+
function T(e, t) {
|
|
61
94
|
if (e.descriptor.key !== e.type)
|
|
62
95
|
throw new d({
|
|
63
96
|
code: "E_BAD_COMMAND",
|
|
@@ -71,18 +104,18 @@ function A(e, t) {
|
|
|
71
104
|
namespace: e.namespace
|
|
72
105
|
}
|
|
73
106
|
});
|
|
74
|
-
|
|
107
|
+
g.register(e, t);
|
|
75
108
|
}
|
|
76
|
-
function
|
|
77
|
-
return
|
|
109
|
+
function te() {
|
|
110
|
+
return g.descriptors();
|
|
78
111
|
}
|
|
79
|
-
function
|
|
80
|
-
return
|
|
112
|
+
function se(e) {
|
|
113
|
+
return g.byId(e);
|
|
81
114
|
}
|
|
82
|
-
function
|
|
83
|
-
|
|
115
|
+
function re() {
|
|
116
|
+
g.clearForTesting();
|
|
84
117
|
}
|
|
85
|
-
class
|
|
118
|
+
class a extends Error {
|
|
86
119
|
/**
|
|
87
120
|
* Creates an option validation error
|
|
88
121
|
* @param optionKey - The key of the option that failed validation
|
|
@@ -92,93 +125,106 @@ class o extends Error {
|
|
|
92
125
|
super(`Option '${t}': ${s}`), this.optionKey = t, this.name = "OptionValidationError";
|
|
93
126
|
}
|
|
94
127
|
}
|
|
95
|
-
function
|
|
128
|
+
function v(e, t, s) {
|
|
96
129
|
if (t == null) {
|
|
97
130
|
if (s.required)
|
|
98
|
-
throw new
|
|
131
|
+
throw new a(e, "is required but was not provided");
|
|
99
132
|
return;
|
|
100
133
|
}
|
|
101
134
|
switch (s.type) {
|
|
102
135
|
case "number":
|
|
103
|
-
|
|
136
|
+
A(e, t, s, !1);
|
|
104
137
|
break;
|
|
105
138
|
case "integer":
|
|
106
|
-
|
|
139
|
+
A(e, t, s, !0);
|
|
107
140
|
break;
|
|
108
141
|
case "boolean":
|
|
109
142
|
if (typeof t != "boolean")
|
|
110
|
-
throw new
|
|
143
|
+
throw new a(e, `must be a boolean, got ${typeof t}`);
|
|
111
144
|
break;
|
|
112
145
|
case "string":
|
|
113
146
|
if (typeof t != "string")
|
|
114
|
-
throw new
|
|
147
|
+
throw new a(e, `must be a string, got ${typeof t}`);
|
|
115
148
|
break;
|
|
116
149
|
case "select":
|
|
117
|
-
|
|
150
|
+
L(e, t, s);
|
|
118
151
|
break;
|
|
119
152
|
case "nodeId":
|
|
120
153
|
if (typeof t != "string" && typeof t != "number")
|
|
121
|
-
throw new
|
|
154
|
+
throw new a(e, `must be a string or number (node ID), got ${typeof t}`);
|
|
122
155
|
break;
|
|
123
156
|
default:
|
|
124
|
-
throw new
|
|
157
|
+
throw new a(e, `has unknown type '${s.type}'`);
|
|
125
158
|
}
|
|
126
159
|
}
|
|
127
|
-
function
|
|
160
|
+
function A(e, t, s, r) {
|
|
128
161
|
if (typeof t != "number")
|
|
129
|
-
throw new
|
|
162
|
+
throw new a(e, `must be a number, got ${typeof t}`);
|
|
130
163
|
if (Number.isNaN(t))
|
|
131
|
-
throw new
|
|
164
|
+
throw new a(e, "must not be NaN");
|
|
132
165
|
if (!Number.isFinite(t))
|
|
133
|
-
throw new
|
|
166
|
+
throw new a(e, "must be finite");
|
|
134
167
|
if (r && !Number.isInteger(t))
|
|
135
|
-
throw new
|
|
168
|
+
throw new a(e, `must be an integer, got ${t}`);
|
|
136
169
|
if (s.min !== void 0 && t < s.min)
|
|
137
|
-
throw new
|
|
170
|
+
throw new a(e, `must be >= ${s.min}, got ${t}`);
|
|
138
171
|
if (s.max !== void 0 && t > s.max)
|
|
139
|
-
throw new
|
|
172
|
+
throw new a(e, `must be <= ${s.max}, got ${t}`);
|
|
140
173
|
}
|
|
141
|
-
function
|
|
174
|
+
function L(e, t, s) {
|
|
142
175
|
if (!s.options || s.options.length === 0)
|
|
143
|
-
throw new
|
|
144
|
-
if (!s.options.map((
|
|
145
|
-
const
|
|
146
|
-
throw new
|
|
176
|
+
throw new a(e, "is a select type but has no options defined");
|
|
177
|
+
if (!s.options.map((n) => n.value).includes(t)) {
|
|
178
|
+
const n = s.options.map((i) => `'${String(i.value)}'`).join(", ");
|
|
179
|
+
throw new a(e, `must be one of [${n}], got '${String(t)}'`);
|
|
147
180
|
}
|
|
148
181
|
}
|
|
149
|
-
function
|
|
182
|
+
function P(e, t) {
|
|
150
183
|
const s = {};
|
|
151
|
-
for (const [r,
|
|
152
|
-
const c = t?.[r] ??
|
|
153
|
-
|
|
184
|
+
for (const [r, n] of Object.entries(e)) {
|
|
185
|
+
const c = t?.[r] ?? n.default;
|
|
186
|
+
v(r, c, n), s[r] = c;
|
|
154
187
|
}
|
|
155
188
|
return s;
|
|
156
189
|
}
|
|
157
|
-
function
|
|
190
|
+
function ne(e) {
|
|
158
191
|
return e;
|
|
159
192
|
}
|
|
160
|
-
function
|
|
161
|
-
const s = e.getSnapshot(), r = t === "directed" ? s : e.undirected(s).snapshot,
|
|
162
|
-
return
|
|
193
|
+
function x(e, t) {
|
|
194
|
+
const s = e.getSnapshot(), r = t === "directed" ? s : e.undirected(s).snapshot, n = r.flags.multigraph ? r.simplified({ weights: "sum" }).snapshot : r;
|
|
195
|
+
return B(n, t);
|
|
163
196
|
}
|
|
164
|
-
function
|
|
197
|
+
function oe(e) {
|
|
165
198
|
const t = e.getSnapshot();
|
|
166
199
|
return t.flags.multigraph ? t.edgeCount - t.simplified({ weights: "sum" }).snapshot.edgeCount : 0;
|
|
167
200
|
}
|
|
168
|
-
function
|
|
169
|
-
const s = new
|
|
201
|
+
function B(e, t) {
|
|
202
|
+
const s = new _({
|
|
170
203
|
directed: t !== "undirected"
|
|
171
204
|
}), { ids: r } = e;
|
|
172
|
-
for (let
|
|
173
|
-
s.addNode(r.idOf(
|
|
174
|
-
const { src:
|
|
175
|
-
for (let
|
|
176
|
-
const
|
|
177
|
-
s.addEdge(
|
|
205
|
+
for (let o = 0; o < e.nodeCount; o++)
|
|
206
|
+
s.addNode(r.idOf(o));
|
|
207
|
+
const { src: n, dst: i, weights: c } = e.edgeList();
|
|
208
|
+
for (let o = 0; o < e.edgeCount; o++) {
|
|
209
|
+
const u = r.idOf(n[o]), h = r.idOf(i[o]), l = c === null ? 1 : c[o];
|
|
210
|
+
s.addEdge(u, h, l);
|
|
178
211
|
}
|
|
179
212
|
return s;
|
|
180
213
|
}
|
|
181
|
-
const
|
|
214
|
+
const m = /* @__PURE__ */ new Map();
|
|
215
|
+
function F(e, t) {
|
|
216
|
+
if (t === null)
|
|
217
|
+
return e;
|
|
218
|
+
if (e === null)
|
|
219
|
+
return t;
|
|
220
|
+
const s = new Uint32Array(e.length);
|
|
221
|
+
for (let r = 0; r < e.length; r++) {
|
|
222
|
+
const n = e[r];
|
|
223
|
+
s[r] = n === w ? w : t[n];
|
|
224
|
+
}
|
|
225
|
+
return s;
|
|
226
|
+
}
|
|
227
|
+
const O = class O {
|
|
182
228
|
/**
|
|
183
229
|
* Getter for schema options
|
|
184
230
|
*
|
|
@@ -208,7 +254,71 @@ const g = /* @__PURE__ */ new Map(), h = class h {
|
|
|
208
254
|
* @returns a freshly built Graph for the algorithm package
|
|
209
255
|
*/
|
|
210
256
|
algorithmGraph(t) {
|
|
211
|
-
return
|
|
257
|
+
return x(this.graph.getDataManager(), t);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* The route an algorithm with an accelerated implementation takes.
|
|
261
|
+
*
|
|
262
|
+
* It is the counterpart of {@link algorithmGraph} for the algorithms `@graphty/algorithms`
|
|
263
|
+
* can dispatch: instead of copying the snapshot into an object graph, the work runs over the
|
|
264
|
+
* snapshot itself, on the attached accelerator or on the index-based CPU port, and the adapter
|
|
265
|
+
* writes one loop over an index-aligned result either way.
|
|
266
|
+
*
|
|
267
|
+
* THE DECISION IS TAKEN ONCE, HERE, BEFORE ANY WORK STARTS. The controller answers "the policy
|
|
268
|
+
* is off", "no accelerator", "below `acceleration.minNodes`" or "this accelerator does not
|
|
269
|
+
* implement that" up front, and under `acceleration="required"` it throws `E_NO_ACCELERATOR`
|
|
270
|
+
* rather than answering quietly. After the work has started there is no second decision: a
|
|
271
|
+
* failure from the accelerator propagates with its code and fails the run, because a number
|
|
272
|
+
* that silently came from somewhere else is worse than no number.
|
|
273
|
+
* @param capability - The accelerator member this work would use, such as `"pageRank"`.
|
|
274
|
+
* @param mode - The shape this algorithm needs; see {@link AlgorithmGraphMode}. `"undirected"`
|
|
275
|
+
* takes the snapshot's undirected view, which is what collapses a reciprocal pair into one
|
|
276
|
+
* edge.
|
|
277
|
+
* @returns The snapshot, the edge map onto it, and the runner.
|
|
278
|
+
* @example
|
|
279
|
+
* ```ts
|
|
280
|
+
* const { snapshot, run } = this.accelerated("connectedComponents", "undirected");
|
|
281
|
+
* const { value, precision } = await run((dispatch, s) => dispatch.connectedComponents(s));
|
|
282
|
+
* const group = value.labels[snapshot.ids.indexOf(nodeId)];
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
|
+
accelerated(t, s) {
|
|
286
|
+
const r = this.graph.getDataManager(), n = r.getSnapshot(), i = s === "undirected" ? r.undirected(n) : null, c = i === null ? n : i.snapshot, o = c.flags.multigraph ? c.simplified({ weights: "sum" }) : null, u = o === null ? c : o.snapshot, h = this.graph.acceleration, l = { capability: t, nodeCount: u.nodeCount };
|
|
287
|
+
return {
|
|
288
|
+
snapshot: u,
|
|
289
|
+
edgeRemap: F(i?.edgeRemap ?? null, o?.edgeRemap ?? null),
|
|
290
|
+
run: async (b) => {
|
|
291
|
+
const f = await h.run(
|
|
292
|
+
l,
|
|
293
|
+
(S) => b(y(R(S)), u)
|
|
294
|
+
);
|
|
295
|
+
return f.accelerated ? { value: f.value, precision: f.precision } : { value: await b(y(null), u), precision: M };
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* The dense row of a node the reader named in an option.
|
|
301
|
+
*
|
|
302
|
+
* A search takes its source as an id and the snapshot answers in indices, so this is where the
|
|
303
|
+
* two meet -- and where an id that names no node in the graph is reported as what it is: an
|
|
304
|
+
* option whose value is outside the permitted range, carrying the option's name and what was
|
|
305
|
+
* passed, rather than a silent empty result or a search from row zero.
|
|
306
|
+
* @param snapshot - The graph the work runs over.
|
|
307
|
+
* @param option - The option the id came from, named in the error.
|
|
308
|
+
* @param id - The node id the reader gave.
|
|
309
|
+
* @returns The node's dense row.
|
|
310
|
+
* @throws A `GraphtyError` with `E_OPTION_RANGE` when the graph has no such node.
|
|
311
|
+
*/
|
|
312
|
+
nodeIndex(t, s, r) {
|
|
313
|
+
const n = t.ids.indexOf(r);
|
|
314
|
+
if (n === w)
|
|
315
|
+
throw new d({
|
|
316
|
+
code: "E_OPTION_RANGE",
|
|
317
|
+
message: `the graph has no node "${String(r)}", so "${s}" names nothing to run from`,
|
|
318
|
+
source: "run",
|
|
319
|
+
details: { option: s, value: r }
|
|
320
|
+
});
|
|
321
|
+
return n;
|
|
212
322
|
}
|
|
213
323
|
/**
|
|
214
324
|
* Resolves and validates options against the schema
|
|
@@ -217,7 +327,7 @@ const g = /* @__PURE__ */ new Map(), h = class h {
|
|
|
217
327
|
*/
|
|
218
328
|
resolveOptions(t) {
|
|
219
329
|
const s = this.constructor.optionsSchema;
|
|
220
|
-
return Object.keys(s).length === 0 ? {} :
|
|
330
|
+
return Object.keys(s).length === 0 ? {} : P(s, t);
|
|
221
331
|
}
|
|
222
332
|
/**
|
|
223
333
|
* Gets the algorithm type
|
|
@@ -270,14 +380,14 @@ const g = /* @__PURE__ */ new Map(), h = class h {
|
|
|
270
380
|
* @returns The registered algorithm class
|
|
271
381
|
*/
|
|
272
382
|
static register(t) {
|
|
273
|
-
const s = t, r = String(s.type),
|
|
274
|
-
return
|
|
275
|
-
descriptor:
|
|
276
|
-
namespace:
|
|
383
|
+
const s = t, r = String(s.type), n = String(s.namespace), { descriptor: i, cost: c, version: o } = s;
|
|
384
|
+
return i !== void 0 && T({
|
|
385
|
+
descriptor: i,
|
|
386
|
+
namespace: n,
|
|
277
387
|
type: r,
|
|
278
388
|
...c === void 0 ? {} : { cost: c },
|
|
279
|
-
...
|
|
280
|
-
}),
|
|
389
|
+
...o === void 0 ? {} : { version: o }
|
|
390
|
+
}), m.set(`${n}:${r}`, t), t;
|
|
281
391
|
}
|
|
282
392
|
/**
|
|
283
393
|
* Gets an algorithm instance from the registry
|
|
@@ -287,9 +397,9 @@ const g = /* @__PURE__ */ new Map(), h = class h {
|
|
|
287
397
|
* @param options - Optional algorithm-specific options to pass to constructor
|
|
288
398
|
* @returns A new instance of the algorithm, or null if not found
|
|
289
399
|
*/
|
|
290
|
-
static get(t, s, r,
|
|
291
|
-
const
|
|
292
|
-
return
|
|
400
|
+
static get(t, s, r, n) {
|
|
401
|
+
const i = m.get(`${s}:${r}`);
|
|
402
|
+
return i ? new i(t, n) : null;
|
|
293
403
|
}
|
|
294
404
|
/**
|
|
295
405
|
* Gets an algorithm class from the registry
|
|
@@ -298,7 +408,7 @@ const g = /* @__PURE__ */ new Map(), h = class h {
|
|
|
298
408
|
* @returns The algorithm class, or null if not found
|
|
299
409
|
*/
|
|
300
410
|
static getClass(t, s) {
|
|
301
|
-
return
|
|
411
|
+
return m.get(`${t}:${s}`) ?? null;
|
|
302
412
|
}
|
|
303
413
|
/**
|
|
304
414
|
* Get the options schema for this algorithm
|
|
@@ -337,7 +447,7 @@ const g = /* @__PURE__ */ new Map(), h = class h {
|
|
|
337
447
|
*/
|
|
338
448
|
static getRegisteredAlgorithms(t) {
|
|
339
449
|
const s = [];
|
|
340
|
-
for (const r of
|
|
450
|
+
for (const r of m.keys())
|
|
341
451
|
(!t || r.startsWith(`${t}:`)) && s.push(r);
|
|
342
452
|
return s.sort();
|
|
343
453
|
}
|
|
@@ -357,20 +467,28 @@ const g = /* @__PURE__ */ new Map(), h = class h {
|
|
|
357
467
|
return this.getRegisteredAlgorithms();
|
|
358
468
|
}
|
|
359
469
|
};
|
|
360
|
-
|
|
361
|
-
let
|
|
470
|
+
O.optionsSchema = {};
|
|
471
|
+
let E = O;
|
|
362
472
|
export {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
473
|
+
E as A,
|
|
474
|
+
M as C,
|
|
475
|
+
J as D,
|
|
476
|
+
a as O,
|
|
477
|
+
Y as a,
|
|
478
|
+
te as b,
|
|
479
|
+
re as c,
|
|
480
|
+
ne as d,
|
|
481
|
+
z as e,
|
|
482
|
+
P as f,
|
|
483
|
+
D as g,
|
|
484
|
+
Z as h,
|
|
485
|
+
X as i,
|
|
486
|
+
W as j,
|
|
487
|
+
ee as k,
|
|
488
|
+
Q as l,
|
|
489
|
+
se as m,
|
|
490
|
+
H as n,
|
|
491
|
+
oe as o,
|
|
492
|
+
K as r,
|
|
493
|
+
v
|
|
376
494
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z as p } from "zod/v4";
|
|
2
2
|
import * as $ from "zod/v4/core";
|
|
3
|
-
import { F as w, v as E } from "./paletteRegistry-
|
|
4
|
-
import { b as F } from "./GraphtyLogger-
|
|
5
|
-
import { G as f } from "./GraphtyError-
|
|
3
|
+
import { F as w, v as E } from "./paletteRegistry-NrWOKT-A.js";
|
|
4
|
+
import { b as F } from "./GraphtyLogger-5KEttFUo.js";
|
|
5
|
+
import { G as f } from "./GraphtyError-BwcnblTH.js";
|
|
6
6
|
class C {
|
|
7
7
|
/**
|
|
8
8
|
* Creates a new ErrorAggregator instance.
|