twokeys 2.0.1 → 2.2.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/README.md +422 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +470 -1
- package/dist/index.d.ts +470 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,472 @@
|
|
|
1
|
+
type GraphNodeInput<NodeId extends string = string> = NodeId | {
|
|
2
|
+
id: NodeId;
|
|
3
|
+
};
|
|
4
|
+
interface GraphEdge<NodeId extends string = string> {
|
|
5
|
+
from: NodeId;
|
|
6
|
+
to: NodeId;
|
|
7
|
+
weight?: number;
|
|
8
|
+
}
|
|
9
|
+
interface GraphBuildOptions {
|
|
10
|
+
directed?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface GraphNeighbor<NodeId extends string = string> {
|
|
13
|
+
id: NodeId;
|
|
14
|
+
weight: number;
|
|
15
|
+
}
|
|
16
|
+
interface GraphAdjacency<NodeId extends string = string> {
|
|
17
|
+
nodes: NodeId[];
|
|
18
|
+
neighborsByNode: Map<NodeId, GraphNeighbor<NodeId>[]>;
|
|
19
|
+
incomingByNode: Map<NodeId, GraphNeighbor<NodeId>[]>;
|
|
20
|
+
edges: Array<Required<GraphEdge<NodeId>>>;
|
|
21
|
+
directed: boolean;
|
|
22
|
+
}
|
|
23
|
+
type GraphAlgorithmErrorCode = 'NEGATIVE_WEIGHT' | 'NEGATIVE_CYCLE' | 'INVALID_ARGUMENT';
|
|
24
|
+
declare class GraphAlgorithmError extends Error {
|
|
25
|
+
readonly code: GraphAlgorithmErrorCode;
|
|
26
|
+
constructor(code: GraphAlgorithmErrorCode, message: string);
|
|
27
|
+
}
|
|
28
|
+
interface TopologicalSortOptions<NodeId extends string = string> {
|
|
29
|
+
tieBreaker?: (left: NodeId, right: NodeId) => number;
|
|
30
|
+
priority?: (nodeId: NodeId) => number;
|
|
31
|
+
priorityByNode?: Map<NodeId, number> | Partial<Record<NodeId, number>>;
|
|
32
|
+
}
|
|
33
|
+
interface TopologicalSortResult<NodeId extends string = string> {
|
|
34
|
+
order: NodeId[];
|
|
35
|
+
cycleNodes: NodeId[];
|
|
36
|
+
isDag: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface StronglyConnectedComponentsOptions extends GraphBuildOptions {
|
|
39
|
+
}
|
|
40
|
+
interface StronglyConnectedComponentsResult<NodeId extends string = string> {
|
|
41
|
+
components: NodeId[][];
|
|
42
|
+
componentByNode: Map<NodeId, number>;
|
|
43
|
+
}
|
|
44
|
+
interface WeaklyConnectedComponentsResult<NodeId extends string = string> {
|
|
45
|
+
components: NodeId[][];
|
|
46
|
+
componentByNode: Map<NodeId, number>;
|
|
47
|
+
}
|
|
48
|
+
interface DegreeCentralityRecord {
|
|
49
|
+
inDegree: number;
|
|
50
|
+
outDegree: number;
|
|
51
|
+
degree: number;
|
|
52
|
+
normalized: number;
|
|
53
|
+
}
|
|
54
|
+
type ClosenessCentralityMode = 'classic' | 'harmonic';
|
|
55
|
+
interface ClosenessCentralityRecord {
|
|
56
|
+
reachableCount: number;
|
|
57
|
+
distanceSum: number;
|
|
58
|
+
score: number;
|
|
59
|
+
normalized: number;
|
|
60
|
+
mode: ClosenessCentralityMode;
|
|
61
|
+
negativeCycle: boolean;
|
|
62
|
+
}
|
|
63
|
+
interface BetweennessCentralityRecord {
|
|
64
|
+
raw: number;
|
|
65
|
+
normalized: number;
|
|
66
|
+
}
|
|
67
|
+
interface PageRankOptions extends GraphBuildOptions {
|
|
68
|
+
dampingFactor?: number;
|
|
69
|
+
tolerance?: number;
|
|
70
|
+
maxIterations?: number;
|
|
71
|
+
}
|
|
72
|
+
interface PageRankRecord {
|
|
73
|
+
score: number;
|
|
74
|
+
normalized: number;
|
|
75
|
+
rank: number;
|
|
76
|
+
}
|
|
77
|
+
interface PageRankResult<NodeId extends string = string> {
|
|
78
|
+
byNode: Map<NodeId, PageRankRecord>;
|
|
79
|
+
order: NodeId[];
|
|
80
|
+
iterations: number;
|
|
81
|
+
converged: boolean;
|
|
82
|
+
dampingFactor: number;
|
|
83
|
+
}
|
|
84
|
+
interface MinimumSpanningTreeOptions<NodeId extends string = string> {
|
|
85
|
+
tieBreaker?: (left: NodeId, right: NodeId) => number;
|
|
86
|
+
}
|
|
87
|
+
interface MinimumSpanningTreeResult<NodeId extends string = string> {
|
|
88
|
+
edges: Array<Required<GraphEdge<NodeId>>>;
|
|
89
|
+
totalWeight: number;
|
|
90
|
+
componentCount: number;
|
|
91
|
+
spanning: boolean;
|
|
92
|
+
}
|
|
93
|
+
interface ArticulationBridgeResult<NodeId extends string = string> {
|
|
94
|
+
articulationPoints: NodeId[];
|
|
95
|
+
bridges: Array<Required<GraphEdge<NodeId>>>;
|
|
96
|
+
}
|
|
97
|
+
interface GraphAnalysisResult<NodeId extends string = string> {
|
|
98
|
+
degree: Map<NodeId, DegreeCentralityRecord>;
|
|
99
|
+
closeness: Map<NodeId, ClosenessCentralityRecord>;
|
|
100
|
+
betweenness: Map<NodeId, BetweennessCentralityRecord>;
|
|
101
|
+
pageRank: Map<NodeId, PageRankRecord>;
|
|
102
|
+
stronglyConnectedComponents: NodeId[][];
|
|
103
|
+
weaklyConnectedComponents: NodeId[][];
|
|
104
|
+
articulationPoints: NodeId[];
|
|
105
|
+
bridges: Array<Required<GraphEdge<NodeId>>>;
|
|
106
|
+
}
|
|
107
|
+
interface GraphAnalysisOptions extends GraphBuildOptions {
|
|
108
|
+
closenessMode?: ClosenessCentralityMode;
|
|
109
|
+
shortestPathAlgorithm?: ShortestPathAlgorithm;
|
|
110
|
+
pageRankOptions?: Omit<PageRankOptions, 'directed'>;
|
|
111
|
+
}
|
|
112
|
+
type ShortestPathAlgorithm = 'auto' | 'dijkstra' | 'bellman-ford';
|
|
113
|
+
interface ShortestPathOptions extends GraphBuildOptions {
|
|
114
|
+
algorithm?: ShortestPathAlgorithm;
|
|
115
|
+
failOnNegativeCycle?: boolean;
|
|
116
|
+
}
|
|
117
|
+
interface ShortestPathResult<NodeId extends string = string> {
|
|
118
|
+
source: NodeId;
|
|
119
|
+
target: NodeId;
|
|
120
|
+
path: NodeId[];
|
|
121
|
+
distance: number;
|
|
122
|
+
reachable: boolean;
|
|
123
|
+
explored: number;
|
|
124
|
+
algorithm: ShortestPathAlgorithm;
|
|
125
|
+
hasNegativeWeights: boolean;
|
|
126
|
+
negativeCycle: boolean;
|
|
127
|
+
}
|
|
128
|
+
interface LabelPropagationOptions<NodeId extends string = string> extends GraphBuildOptions {
|
|
129
|
+
maxIterations?: number;
|
|
130
|
+
tieBreaker?: (left: NodeId, right: NodeId) => number;
|
|
131
|
+
}
|
|
132
|
+
interface LouvainOptions<NodeId extends string = string> extends GraphBuildOptions {
|
|
133
|
+
maxPasses?: number;
|
|
134
|
+
tolerance?: number;
|
|
135
|
+
tieBreaker?: (left: NodeId, right: NodeId) => number;
|
|
136
|
+
}
|
|
137
|
+
interface CommunityDetectionResult<NodeId extends string = string> {
|
|
138
|
+
communities: NodeId[][];
|
|
139
|
+
communityByNode: Map<NodeId, number>;
|
|
140
|
+
iterations: number;
|
|
141
|
+
converged: boolean;
|
|
142
|
+
algorithm: 'label-propagation' | 'louvain';
|
|
143
|
+
modularity: number;
|
|
144
|
+
}
|
|
145
|
+
type SimilarityMetric = 'common-neighbors' | 'jaccard' | 'cosine' | 'overlap' | 'adamic-adar' | 'resource-allocation' | 'preferential-attachment';
|
|
146
|
+
interface SimilarityOptions extends GraphBuildOptions {
|
|
147
|
+
metric?: SimilarityMetric;
|
|
148
|
+
minScore?: number;
|
|
149
|
+
}
|
|
150
|
+
interface NodeSimilarityRecord<NodeId extends string = string> {
|
|
151
|
+
left: NodeId;
|
|
152
|
+
right: NodeId;
|
|
153
|
+
score: number;
|
|
154
|
+
metric: SimilarityMetric;
|
|
155
|
+
rank: number;
|
|
156
|
+
}
|
|
157
|
+
interface NodeSimilarityResult<NodeId extends string = string> {
|
|
158
|
+
metric: SimilarityMetric;
|
|
159
|
+
pairs: NodeSimilarityRecord<NodeId>[];
|
|
160
|
+
}
|
|
161
|
+
interface KNearestNeighborsOptions extends GraphBuildOptions {
|
|
162
|
+
metric?: SimilarityMetric;
|
|
163
|
+
k?: number;
|
|
164
|
+
minScore?: number;
|
|
165
|
+
}
|
|
166
|
+
interface KNearestNeighbor<NodeId extends string = string> {
|
|
167
|
+
nodeId: NodeId;
|
|
168
|
+
score: number;
|
|
169
|
+
}
|
|
170
|
+
interface KNearestNeighborsResult<NodeId extends string = string> {
|
|
171
|
+
metric: SimilarityMetric;
|
|
172
|
+
k: number;
|
|
173
|
+
neighborsByNode: Map<NodeId, KNearestNeighbor<NodeId>[]>;
|
|
174
|
+
}
|
|
175
|
+
interface LinkPredictionOptions<NodeId extends string = string> extends GraphBuildOptions {
|
|
176
|
+
metric?: SimilarityMetric;
|
|
177
|
+
limit?: number;
|
|
178
|
+
minScore?: number;
|
|
179
|
+
allowExistingEdges?: boolean;
|
|
180
|
+
sourceFilter?: NodeId[];
|
|
181
|
+
targetFilter?: NodeId[];
|
|
182
|
+
}
|
|
183
|
+
interface LinkPredictionRecord<NodeId extends string = string> {
|
|
184
|
+
from: NodeId;
|
|
185
|
+
to: NodeId;
|
|
186
|
+
score: number;
|
|
187
|
+
metric: SimilarityMetric;
|
|
188
|
+
rank: number;
|
|
189
|
+
}
|
|
190
|
+
interface LinkPredictionResult<NodeId extends string = string> {
|
|
191
|
+
metric: SimilarityMetric;
|
|
192
|
+
predictions: LinkPredictionRecord<NodeId>[];
|
|
193
|
+
}
|
|
194
|
+
interface AStarOptions<NodeId extends string = string> extends GraphBuildOptions {
|
|
195
|
+
heuristic?: (nodeId: NodeId, targetId: NodeId) => number;
|
|
196
|
+
}
|
|
197
|
+
interface AStarResult<NodeId extends string = string> {
|
|
198
|
+
source: NodeId;
|
|
199
|
+
target: NodeId;
|
|
200
|
+
path: NodeId[];
|
|
201
|
+
distance: number;
|
|
202
|
+
reachable: boolean;
|
|
203
|
+
explored: number;
|
|
204
|
+
estimatedDistance: number;
|
|
205
|
+
}
|
|
206
|
+
interface PathRecord<NodeId extends string = string> {
|
|
207
|
+
path: NodeId[];
|
|
208
|
+
distance: number;
|
|
209
|
+
}
|
|
210
|
+
interface YenKShortestPathsOptions extends GraphBuildOptions {
|
|
211
|
+
k?: number;
|
|
212
|
+
shortestPathAlgorithm?: ShortestPathAlgorithm;
|
|
213
|
+
}
|
|
214
|
+
interface YenKShortestPathsResult<NodeId extends string = string> {
|
|
215
|
+
source: NodeId;
|
|
216
|
+
target: NodeId;
|
|
217
|
+
paths: PathRecord<NodeId>[];
|
|
218
|
+
complete: boolean;
|
|
219
|
+
}
|
|
220
|
+
interface AllPairsShortestPathsOptions extends GraphBuildOptions {
|
|
221
|
+
algorithm?: ShortestPathAlgorithm;
|
|
222
|
+
failOnNegativeCycle?: boolean;
|
|
223
|
+
}
|
|
224
|
+
interface AllPairsShortestPathsResult<NodeId extends string = string> {
|
|
225
|
+
nodes: NodeId[];
|
|
226
|
+
distanceBySource: Map<NodeId, Map<NodeId, number>>;
|
|
227
|
+
previousBySource: Map<NodeId, Map<NodeId, NodeId>>;
|
|
228
|
+
algorithm: ShortestPathAlgorithm;
|
|
229
|
+
hasNegativeWeights: boolean;
|
|
230
|
+
negativeCycle: boolean;
|
|
231
|
+
}
|
|
232
|
+
interface FlowEdge<NodeId extends string = string> {
|
|
233
|
+
from: NodeId;
|
|
234
|
+
to: NodeId;
|
|
235
|
+
capacity: number;
|
|
236
|
+
cost?: number;
|
|
237
|
+
}
|
|
238
|
+
interface FlowEdgeResult<NodeId extends string = string> {
|
|
239
|
+
from: NodeId;
|
|
240
|
+
to: NodeId;
|
|
241
|
+
flow: number;
|
|
242
|
+
capacity: number;
|
|
243
|
+
}
|
|
244
|
+
interface MaximumFlowOptions extends GraphBuildOptions {
|
|
245
|
+
}
|
|
246
|
+
interface MaximumFlowResult<NodeId extends string = string> {
|
|
247
|
+
source: NodeId;
|
|
248
|
+
sink: NodeId;
|
|
249
|
+
maxFlow: number;
|
|
250
|
+
augmentations: number;
|
|
251
|
+
flowByEdge: FlowEdgeResult<NodeId>[];
|
|
252
|
+
sourcePartition: NodeId[];
|
|
253
|
+
sinkPartition: NodeId[];
|
|
254
|
+
cutEdges: Array<Required<GraphEdge<NodeId>>>;
|
|
255
|
+
}
|
|
256
|
+
interface MinCostMaxFlowOptions extends GraphBuildOptions {
|
|
257
|
+
targetFlow?: number;
|
|
258
|
+
}
|
|
259
|
+
interface MinCostFlowEdgeResult<NodeId extends string = string> extends FlowEdgeResult<NodeId> {
|
|
260
|
+
cost: number;
|
|
261
|
+
}
|
|
262
|
+
interface MinCostMaxFlowResult<NodeId extends string = string> {
|
|
263
|
+
source: NodeId;
|
|
264
|
+
sink: NodeId;
|
|
265
|
+
flow: number;
|
|
266
|
+
cost: number;
|
|
267
|
+
complete: boolean;
|
|
268
|
+
augmentations: number;
|
|
269
|
+
flowByEdge: MinCostFlowEdgeResult<NodeId>[];
|
|
270
|
+
}
|
|
271
|
+
type KMeansNormalization = 'none' | 'zscore' | 'minmax';
|
|
272
|
+
interface KMeansOptions {
|
|
273
|
+
maxIterations?: number;
|
|
274
|
+
tolerance?: number;
|
|
275
|
+
seed?: number;
|
|
276
|
+
nInit?: number;
|
|
277
|
+
normalization?: KMeansNormalization;
|
|
278
|
+
useKMeansPlusPlus?: boolean;
|
|
279
|
+
}
|
|
280
|
+
interface KMeansCluster {
|
|
281
|
+
centroid: number[];
|
|
282
|
+
indices: number[];
|
|
283
|
+
}
|
|
284
|
+
interface KMeansResult {
|
|
285
|
+
assignments: number[];
|
|
286
|
+
clusters: KMeansCluster[];
|
|
287
|
+
iterations: number;
|
|
288
|
+
inertia: number;
|
|
289
|
+
converged: boolean;
|
|
290
|
+
silhouette: number | null;
|
|
291
|
+
selectedSeed: number;
|
|
292
|
+
}
|
|
293
|
+
interface KMeansAutoOptions extends KMeansOptions {
|
|
294
|
+
kMin?: number;
|
|
295
|
+
kMax?: number;
|
|
296
|
+
}
|
|
297
|
+
interface KMeansAutoCandidate {
|
|
298
|
+
k: number;
|
|
299
|
+
silhouette: number | null;
|
|
300
|
+
inertia: number;
|
|
301
|
+
}
|
|
302
|
+
interface KMeansAutoResult extends KMeansResult {
|
|
303
|
+
selectedK: number;
|
|
304
|
+
candidates: KMeansAutoCandidate[];
|
|
305
|
+
}
|
|
306
|
+
interface TravelingSalesmanOptions<NodeId extends string = string> extends GraphBuildOptions {
|
|
307
|
+
start?: NodeId;
|
|
308
|
+
returnToStart?: boolean;
|
|
309
|
+
twoOptPasses?: number;
|
|
310
|
+
multiStartCount?: number;
|
|
311
|
+
startCandidates?: NodeId[];
|
|
312
|
+
seed?: number;
|
|
313
|
+
shortestPathAlgorithm?: ShortestPathAlgorithm;
|
|
314
|
+
}
|
|
315
|
+
interface TravelingSalesmanSegment<NodeId extends string = string> {
|
|
316
|
+
from: NodeId;
|
|
317
|
+
to: NodeId;
|
|
318
|
+
distance: number;
|
|
319
|
+
path: NodeId[];
|
|
320
|
+
}
|
|
321
|
+
interface TravelingSalesmanResult<NodeId extends string = string> {
|
|
322
|
+
order: NodeId[];
|
|
323
|
+
distance: number;
|
|
324
|
+
segments: TravelingSalesmanSegment<NodeId>[];
|
|
325
|
+
visitedCount: number;
|
|
326
|
+
complete: boolean;
|
|
327
|
+
unreachableNodes: NodeId[];
|
|
328
|
+
lowerBound: number;
|
|
329
|
+
optimalityGap: number | null;
|
|
330
|
+
}
|
|
331
|
+
declare function buildGraphAdjacency<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: GraphBuildOptions): GraphAdjacency<NodeId>;
|
|
332
|
+
declare function stronglyConnectedComponents<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: StronglyConnectedComponentsOptions): StronglyConnectedComponentsResult<NodeId>;
|
|
333
|
+
declare function weaklyConnectedComponents<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[]): WeaklyConnectedComponentsResult<NodeId>;
|
|
334
|
+
declare function topologicalSort<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: TopologicalSortOptions<NodeId>): TopologicalSortResult<NodeId>;
|
|
335
|
+
declare function degreeCentrality<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: GraphBuildOptions): Map<NodeId, DegreeCentralityRecord>;
|
|
336
|
+
interface ClosenessCentralityOptions extends GraphBuildOptions {
|
|
337
|
+
mode?: ClosenessCentralityMode;
|
|
338
|
+
shortestPathAlgorithm?: ShortestPathAlgorithm;
|
|
339
|
+
}
|
|
340
|
+
declare function closenessCentrality<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: ClosenessCentralityOptions): Map<NodeId, ClosenessCentralityRecord>;
|
|
341
|
+
declare function betweennessCentrality<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: GraphBuildOptions): Map<NodeId, BetweennessCentralityRecord>;
|
|
342
|
+
declare function pageRank<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: PageRankOptions): PageRankResult<NodeId>;
|
|
343
|
+
declare function minimumSpanningTree<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: MinimumSpanningTreeOptions<NodeId>): MinimumSpanningTreeResult<NodeId>;
|
|
344
|
+
declare function articulationPointsAndBridges<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[]): ArticulationBridgeResult<NodeId>;
|
|
345
|
+
declare function analyzeGraph<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: GraphAnalysisOptions): GraphAnalysisResult<NodeId>;
|
|
346
|
+
declare function shortestPath<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], source: NodeId, target: NodeId, options?: ShortestPathOptions): ShortestPathResult<NodeId>;
|
|
347
|
+
declare function labelPropagationCommunities<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: LabelPropagationOptions<NodeId>): CommunityDetectionResult<NodeId>;
|
|
348
|
+
declare function louvainCommunities<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: LouvainOptions<NodeId>): CommunityDetectionResult<NodeId>;
|
|
349
|
+
declare function nodeSimilarity<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: SimilarityOptions): NodeSimilarityResult<NodeId>;
|
|
350
|
+
declare function kNearestNeighbors<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: KNearestNeighborsOptions): KNearestNeighborsResult<NodeId>;
|
|
351
|
+
declare function predictLinks<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: LinkPredictionOptions<NodeId>): LinkPredictionResult<NodeId>;
|
|
352
|
+
declare function linkPrediction<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: LinkPredictionOptions<NodeId>): LinkPredictionResult<NodeId>;
|
|
353
|
+
declare function aStarShortestPath<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], source: NodeId, target: NodeId, options?: AStarOptions<NodeId>): AStarResult<NodeId>;
|
|
354
|
+
declare function allPairsShortestPaths<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: AllPairsShortestPathsOptions): AllPairsShortestPathsResult<NodeId>;
|
|
355
|
+
declare function yenKShortestPaths<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], source: NodeId, target: NodeId, options?: YenKShortestPathsOptions): YenKShortestPathsResult<NodeId>;
|
|
356
|
+
declare function maximumFlow<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], source: NodeId, sink: NodeId, options?: MaximumFlowOptions): MaximumFlowResult<NodeId>;
|
|
357
|
+
declare function minCostMaxFlow<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: FlowEdge<NodeId>[], source: NodeId, sink: NodeId, options?: MinCostMaxFlowOptions): MinCostMaxFlowResult<NodeId>;
|
|
358
|
+
declare function kMeansClustering(points: number[][], k: number, options?: KMeansOptions): KMeansResult;
|
|
359
|
+
declare function kMeansAuto(points: number[][], options?: KMeansAutoOptions): KMeansAutoResult;
|
|
360
|
+
declare function travelingSalesmanApprox<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: TravelingSalesmanOptions<NodeId>): TravelingSalesmanResult<NodeId>;
|
|
361
|
+
|
|
362
|
+
interface GdsProjectOptions {
|
|
363
|
+
directed?: boolean;
|
|
364
|
+
replace?: boolean;
|
|
365
|
+
metadata?: Record<string, unknown>;
|
|
366
|
+
}
|
|
367
|
+
interface GdsGraphProjection<NodeId extends string = string> {
|
|
368
|
+
name: string;
|
|
369
|
+
nodes: NodeId[];
|
|
370
|
+
edges: Array<Required<GraphEdge<NodeId>>>;
|
|
371
|
+
directed: boolean;
|
|
372
|
+
createdAt: number;
|
|
373
|
+
metadata: Record<string, unknown>;
|
|
374
|
+
}
|
|
375
|
+
interface GdsCatalogEntry {
|
|
376
|
+
name: string;
|
|
377
|
+
nodeCount: number;
|
|
378
|
+
edgeCount: number;
|
|
379
|
+
directed: boolean;
|
|
380
|
+
createdAt: number;
|
|
381
|
+
metadata: Record<string, unknown>;
|
|
382
|
+
}
|
|
383
|
+
type GdsPipelineStep<NodeId extends string = string> = {
|
|
384
|
+
id: string;
|
|
385
|
+
kind: 'page-rank';
|
|
386
|
+
options?: PageRankOptions;
|
|
387
|
+
} | {
|
|
388
|
+
id: string;
|
|
389
|
+
kind: 'louvain';
|
|
390
|
+
options?: LouvainOptions<NodeId>;
|
|
391
|
+
} | {
|
|
392
|
+
id: string;
|
|
393
|
+
kind: 'label-propagation';
|
|
394
|
+
options?: LabelPropagationOptions<NodeId>;
|
|
395
|
+
} | {
|
|
396
|
+
id: string;
|
|
397
|
+
kind: 'similarity';
|
|
398
|
+
options?: SimilarityOptions;
|
|
399
|
+
} | {
|
|
400
|
+
id: string;
|
|
401
|
+
kind: 'knn';
|
|
402
|
+
options?: KNearestNeighborsOptions;
|
|
403
|
+
} | {
|
|
404
|
+
id: string;
|
|
405
|
+
kind: 'link-prediction';
|
|
406
|
+
options?: LinkPredictionOptions<NodeId>;
|
|
407
|
+
} | {
|
|
408
|
+
id: string;
|
|
409
|
+
kind: 'shortest-path';
|
|
410
|
+
source: NodeId;
|
|
411
|
+
target: NodeId;
|
|
412
|
+
options?: ShortestPathOptions;
|
|
413
|
+
} | {
|
|
414
|
+
id: string;
|
|
415
|
+
kind: 'a-star';
|
|
416
|
+
source: NodeId;
|
|
417
|
+
target: NodeId;
|
|
418
|
+
options?: AStarOptions<NodeId>;
|
|
419
|
+
} | {
|
|
420
|
+
id: string;
|
|
421
|
+
kind: 'yen-k-shortest-paths';
|
|
422
|
+
source: NodeId;
|
|
423
|
+
target: NodeId;
|
|
424
|
+
options?: YenKShortestPathsOptions;
|
|
425
|
+
} | {
|
|
426
|
+
id: string;
|
|
427
|
+
kind: 'max-flow';
|
|
428
|
+
source: NodeId;
|
|
429
|
+
sink: NodeId;
|
|
430
|
+
options?: MaximumFlowOptions;
|
|
431
|
+
} | {
|
|
432
|
+
id: string;
|
|
433
|
+
kind: 'min-cost-max-flow';
|
|
434
|
+
source: NodeId;
|
|
435
|
+
sink: NodeId;
|
|
436
|
+
edges?: FlowEdge<NodeId>[] | null;
|
|
437
|
+
options?: MinCostMaxFlowOptions;
|
|
438
|
+
} | {
|
|
439
|
+
id: string;
|
|
440
|
+
kind: 'all-pairs-shortest-paths';
|
|
441
|
+
options?: AllPairsShortestPathsOptions;
|
|
442
|
+
};
|
|
443
|
+
type GdsPipelineOutput<NodeId extends string = string> = PageRankResult<NodeId> | CommunityDetectionResult<NodeId> | NodeSimilarityResult<NodeId> | KNearestNeighborsResult<NodeId> | LinkPredictionResult<NodeId> | ShortestPathResult<NodeId> | AStarResult<NodeId> | YenKShortestPathsResult<NodeId> | MaximumFlowResult<NodeId> | MinCostMaxFlowResult<NodeId> | AllPairsShortestPathsResult<NodeId>;
|
|
444
|
+
declare class GraphCatalog<NodeId extends string = string> {
|
|
445
|
+
private projections;
|
|
446
|
+
project(name: string, nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: GdsProjectOptions): GdsGraphProjection<NodeId>;
|
|
447
|
+
drop(name: string): boolean;
|
|
448
|
+
clear(): void;
|
|
449
|
+
exists(name: string): boolean;
|
|
450
|
+
get(name: string): GdsGraphProjection<NodeId> | null;
|
|
451
|
+
list(): GdsCatalogEntry[];
|
|
452
|
+
pageRank(name: string, options?: PageRankOptions): PageRankResult<NodeId>;
|
|
453
|
+
louvain(name: string, options?: LouvainOptions<NodeId>): CommunityDetectionResult<NodeId>;
|
|
454
|
+
labelPropagation(name: string, options?: LabelPropagationOptions<NodeId>): CommunityDetectionResult<NodeId>;
|
|
455
|
+
similarity(name: string, options?: SimilarityOptions): NodeSimilarityResult<NodeId>;
|
|
456
|
+
knn(name: string, options?: KNearestNeighborsOptions): KNearestNeighborsResult<NodeId>;
|
|
457
|
+
linkPrediction(name: string, options?: LinkPredictionOptions<NodeId>): LinkPredictionResult<NodeId>;
|
|
458
|
+
shortestPath(name: string, source: NodeId, target: NodeId, options?: ShortestPathOptions): ShortestPathResult<NodeId>;
|
|
459
|
+
aStar(name: string, source: NodeId, target: NodeId, options?: AStarOptions<NodeId>): AStarResult<NodeId>;
|
|
460
|
+
yen(name: string, source: NodeId, target: NodeId, options?: YenKShortestPathsOptions): YenKShortestPathsResult<NodeId>;
|
|
461
|
+
allPairs(name: string, options?: AllPairsShortestPathsOptions): AllPairsShortestPathsResult<NodeId>;
|
|
462
|
+
maxFlow(name: string, source: NodeId, sink: NodeId, options?: MaximumFlowOptions): MaximumFlowResult<NodeId>;
|
|
463
|
+
minCostMaxFlow(name: string, source: NodeId, sink: NodeId, edges?: FlowEdge<NodeId>[] | null, options?: MinCostMaxFlowOptions): MinCostMaxFlowResult<NodeId>;
|
|
464
|
+
runPipeline(name: string, steps: GdsPipelineStep<NodeId>[]): Map<string, GdsPipelineOutput<NodeId>>;
|
|
465
|
+
private requireProjection;
|
|
466
|
+
}
|
|
467
|
+
declare function createGraphCatalog<NodeId extends string = string>(): GraphCatalog<NodeId>;
|
|
468
|
+
declare const gds: GraphCatalog<string>;
|
|
469
|
+
|
|
1
470
|
/**
|
|
2
471
|
* Twokeys - A small data exploration and manipulation library
|
|
3
472
|
* Named after John Tukey, pioneer of exploratory data analysis (EDA)
|
|
@@ -190,4 +659,4 @@ declare class Twokeys {
|
|
|
190
659
|
static randomPoints: typeof randomPoints;
|
|
191
660
|
}
|
|
192
661
|
|
|
193
|
-
export { type BinnedResult, type MedianResult, type ModeResult, Points, type PointsDescription, type PointsOptions, type RankInfo, type RankedResult, Series, type SeriesDescription, type SeriesOptions, Twokeys, Twokeys as default };
|
|
662
|
+
export { type AStarOptions, type AStarResult, type AllPairsShortestPathsOptions, type AllPairsShortestPathsResult, type ArticulationBridgeResult, type BetweennessCentralityRecord, type BinnedResult, type ClosenessCentralityMode, type ClosenessCentralityOptions, type ClosenessCentralityRecord, type CommunityDetectionResult, type DegreeCentralityRecord, type FlowEdge, type FlowEdgeResult, type GdsCatalogEntry, type GdsGraphProjection, type GdsPipelineOutput, type GdsPipelineStep, type GdsProjectOptions, type GraphAdjacency, GraphAlgorithmError, type GraphAlgorithmErrorCode, type GraphAnalysisOptions, type GraphAnalysisResult, type GraphBuildOptions, GraphCatalog, type GraphEdge, type GraphNeighbor, type GraphNodeInput, type KMeansAutoCandidate, type KMeansAutoOptions, type KMeansAutoResult, type KMeansCluster, type KMeansNormalization, type KMeansOptions, type KMeansResult, type KNearestNeighbor, type KNearestNeighborsOptions, type KNearestNeighborsResult, type LabelPropagationOptions, type LinkPredictionOptions, type LinkPredictionRecord, type LinkPredictionResult, type LouvainOptions, type MaximumFlowOptions, type MaximumFlowResult, type MedianResult, type MinCostFlowEdgeResult, type MinCostMaxFlowOptions, type MinCostMaxFlowResult, type MinimumSpanningTreeOptions, type MinimumSpanningTreeResult, type ModeResult, type NodeSimilarityRecord, type NodeSimilarityResult, type PageRankOptions, type PageRankRecord, type PageRankResult, type PathRecord, Points, type PointsDescription, type PointsOptions, type RankInfo, type RankedResult, Series, type SeriesDescription, type SeriesOptions, type ShortestPathAlgorithm, type ShortestPathOptions, type ShortestPathResult, type SimilarityMetric, type SimilarityOptions, type StronglyConnectedComponentsOptions, type StronglyConnectedComponentsResult, type TopologicalSortOptions, type TopologicalSortResult, type TravelingSalesmanOptions, type TravelingSalesmanResult, type TravelingSalesmanSegment, Twokeys, type WeaklyConnectedComponentsResult, type YenKShortestPathsOptions, type YenKShortestPathsResult, aStarShortestPath, allPairsShortestPaths, analyzeGraph, articulationPointsAndBridges, betweennessCentrality, buildGraphAdjacency, closenessCentrality, createGraphCatalog, Twokeys as default, degreeCentrality, gds, kMeansAuto, kMeansClustering, kNearestNeighbors, labelPropagationCommunities, linkPrediction, louvainCommunities, maximumFlow, minCostMaxFlow, minimumSpanningTree, nodeSimilarity, pageRank, predictLinks, shortestPath, stronglyConnectedComponents, topologicalSort, travelingSalesmanApprox, weaklyConnectedComponents, yenKShortestPaths };
|