twokeys 2.2.0 → 3.0.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 +286 -323
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +154 -1
- package/dist/index.d.ts +154 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +12 -11
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vector Distance & Similarity Functions
|
|
3
|
+
*
|
|
4
|
+
* Standalone functions for vector math — zero dependencies.
|
|
5
|
+
* These are the workhorses that Points, graph algorithms, and consumers all use.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Cosine similarity between two dense vectors.
|
|
9
|
+
* Returns a value in [-1, 1] where 1 means identical direction.
|
|
10
|
+
*/
|
|
11
|
+
declare function cosineSimilarity(a: number[], b: number[]): number;
|
|
12
|
+
/**
|
|
13
|
+
* Squared Euclidean distance between two dense vectors.
|
|
14
|
+
* Avoids the sqrt for performance-sensitive comparisons.
|
|
15
|
+
*/
|
|
16
|
+
declare function squaredEuclideanDistance(a: number[], b: number[]): number;
|
|
17
|
+
/**
|
|
18
|
+
* Euclidean (L2) distance between two dense vectors.
|
|
19
|
+
*/
|
|
20
|
+
declare function euclideanDistance(a: number[], b: number[]): number;
|
|
21
|
+
/**
|
|
22
|
+
* Manhattan (L1) distance between two dense vectors.
|
|
23
|
+
*/
|
|
24
|
+
declare function manhattanDistance(a: number[], b: number[]): number;
|
|
25
|
+
/**
|
|
26
|
+
* Mahalanobis distance of a point from a distribution described by
|
|
27
|
+
* per-dimension means and variances.
|
|
28
|
+
*
|
|
29
|
+
* This is the diagonal-covariance special case (dimensions are independent),
|
|
30
|
+
* which is what most embedding-space consumers need.
|
|
31
|
+
*
|
|
32
|
+
* d = sqrt( Σ (x_i - μ_i)² / max(σ²_i, ε) )
|
|
33
|
+
*/
|
|
34
|
+
declare function mahalanobisDistance(point: number[], means: number[], variances: number[], epsilon?: number): number;
|
|
35
|
+
/**
|
|
36
|
+
* L2-normalize a dense vector (unit vector in same direction).
|
|
37
|
+
* Returns the zero vector if the input has zero magnitude.
|
|
38
|
+
*/
|
|
39
|
+
declare function normalizeL2(vector: number[]): number[];
|
|
40
|
+
/**
|
|
41
|
+
* Cosine similarity between two sparse vectors represented as Map<string, number>.
|
|
42
|
+
*/
|
|
43
|
+
declare function cosineSimilaritySparse(a: Map<string, number>, b: Map<string, number>): number;
|
|
44
|
+
/**
|
|
45
|
+
* Jaccard similarity between two sets: |A ∩ B| / |A ∪ B|.
|
|
46
|
+
* Returns 0 for empty sets.
|
|
47
|
+
*/
|
|
48
|
+
declare function jaccardSimilarity<T>(a: Set<T>, b: Set<T>): number;
|
|
49
|
+
/**
|
|
50
|
+
* Overlap coefficient: |A ∩ B| / min(|A|, |B|).
|
|
51
|
+
* Returns 0 for empty sets.
|
|
52
|
+
*/
|
|
53
|
+
declare function overlapCoefficient<T>(a: Set<T>, b: Set<T>): number;
|
|
54
|
+
|
|
1
55
|
type GraphNodeInput<NodeId extends string = string> = NodeId | {
|
|
2
56
|
id: NodeId;
|
|
3
57
|
};
|
|
@@ -358,6 +412,83 @@ declare function minCostMaxFlow<NodeId extends string>(nodes: GraphNodeInput<Nod
|
|
|
358
412
|
declare function kMeansClustering(points: number[][], k: number, options?: KMeansOptions): KMeansResult;
|
|
359
413
|
declare function kMeansAuto(points: number[][], options?: KMeansAutoOptions): KMeansAutoResult;
|
|
360
414
|
declare function travelingSalesmanApprox<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: TravelingSalesmanOptions<NodeId>): TravelingSalesmanResult<NodeId>;
|
|
415
|
+
type LinkageMethod = 'single' | 'complete' | 'average' | 'ward';
|
|
416
|
+
interface DendrogramNode {
|
|
417
|
+
left: number;
|
|
418
|
+
right: number;
|
|
419
|
+
distance: number;
|
|
420
|
+
size: number;
|
|
421
|
+
}
|
|
422
|
+
interface HierarchicalClusterResult {
|
|
423
|
+
clusters: number[][];
|
|
424
|
+
assignments: number[];
|
|
425
|
+
dendrogram: DendrogramNode[];
|
|
426
|
+
silhouette: number | null;
|
|
427
|
+
}
|
|
428
|
+
declare function hierarchicalClustering(points: number[][], k: number, options?: {
|
|
429
|
+
linkage?: LinkageMethod;
|
|
430
|
+
distanceMetric?: 'euclidean' | 'cosine' | 'manhattan';
|
|
431
|
+
}): HierarchicalClusterResult;
|
|
432
|
+
interface DbscanResult {
|
|
433
|
+
clusters: number[][];
|
|
434
|
+
assignments: number[];
|
|
435
|
+
noise: number[];
|
|
436
|
+
clusterCount: number;
|
|
437
|
+
}
|
|
438
|
+
declare function dbscan(points: number[][], epsilon: number, minPoints: number, options?: {
|
|
439
|
+
distanceMetric?: 'euclidean' | 'cosine' | 'manhattan';
|
|
440
|
+
}): DbscanResult;
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Graph EDA — What Tukey Would Have Done With Graphs
|
|
444
|
+
*
|
|
445
|
+
* Treats graph structural properties as data series that deserve
|
|
446
|
+
* full exploratory data analysis treatment.
|
|
447
|
+
*/
|
|
448
|
+
|
|
449
|
+
interface GraphEdaSummary<NodeId extends string = string> {
|
|
450
|
+
nodeCount: number;
|
|
451
|
+
edgeCount: number;
|
|
452
|
+
density: number;
|
|
453
|
+
degreeDistribution: SeriesDescription;
|
|
454
|
+
inDegreeDistribution: SeriesDescription;
|
|
455
|
+
outDegreeDistribution: SeriesDescription;
|
|
456
|
+
clusteringCoefficients: Map<NodeId, number>;
|
|
457
|
+
globalClusteringCoefficient: number;
|
|
458
|
+
clusteringDistribution: SeriesDescription;
|
|
459
|
+
averagePathLength: number;
|
|
460
|
+
diameter: number;
|
|
461
|
+
reciprocity: number;
|
|
462
|
+
degreeAssortativity: number;
|
|
463
|
+
}
|
|
464
|
+
interface GraphOutlierResult<NodeId extends string = string> {
|
|
465
|
+
nodeId: NodeId;
|
|
466
|
+
score: number;
|
|
467
|
+
reason: string;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Compute the local clustering coefficient for each node.
|
|
471
|
+
* For undirected graphs: the fraction of pairs of neighbors that are connected.
|
|
472
|
+
* For directed graphs: uses the total number of directed triangles.
|
|
473
|
+
*/
|
|
474
|
+
declare function clusteringCoefficient<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: {
|
|
475
|
+
directed?: boolean;
|
|
476
|
+
}): Map<NodeId, number>;
|
|
477
|
+
/**
|
|
478
|
+
* Full exploratory data analysis of a graph's structural properties.
|
|
479
|
+
* Returns distributions as Series descriptions for full Tukey-style EDA.
|
|
480
|
+
*/
|
|
481
|
+
declare function graphEda<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: {
|
|
482
|
+
directed?: boolean;
|
|
483
|
+
samplePathLength?: number;
|
|
484
|
+
}): GraphEdaSummary<NodeId>;
|
|
485
|
+
/**
|
|
486
|
+
* Graph-based outlier detection: nodes with unusual structural signatures.
|
|
487
|
+
*/
|
|
488
|
+
declare function graphOutliers<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: {
|
|
489
|
+
method?: 'degree' | 'clustering' | 'combined';
|
|
490
|
+
threshold?: number;
|
|
491
|
+
}): GraphOutlierResult<NodeId>[];
|
|
361
492
|
|
|
362
493
|
interface GdsProjectOptions {
|
|
363
494
|
directed?: boolean;
|
|
@@ -548,6 +679,12 @@ interface SeriesDescription {
|
|
|
548
679
|
}
|
|
549
680
|
interface PointsDescription {
|
|
550
681
|
original: number[][];
|
|
682
|
+
centroid: number[];
|
|
683
|
+
variances: number[];
|
|
684
|
+
correlationMatrix: number[][];
|
|
685
|
+
mahalanobisDistances: number[];
|
|
686
|
+
outlierCount: number;
|
|
687
|
+
dimensionSummaries: SeriesDescription[];
|
|
551
688
|
}
|
|
552
689
|
declare function randomInteger(max?: number): number;
|
|
553
690
|
declare function randomSeries(count?: number, max?: number): number[];
|
|
@@ -566,6 +703,12 @@ declare class Series {
|
|
|
566
703
|
private getMedian;
|
|
567
704
|
mean(): number;
|
|
568
705
|
private getMean;
|
|
706
|
+
variance(): number;
|
|
707
|
+
stddev(): number;
|
|
708
|
+
ema(alpha: number): number[];
|
|
709
|
+
zscore(): number[];
|
|
710
|
+
skewness(): number;
|
|
711
|
+
kurtosis(): number;
|
|
569
712
|
mode(): ModeResult;
|
|
570
713
|
private getMode;
|
|
571
714
|
extremes(): number[];
|
|
@@ -637,6 +780,16 @@ declare class Points {
|
|
|
637
780
|
private dimension;
|
|
638
781
|
private count;
|
|
639
782
|
constructor(options?: PointsOptions | number);
|
|
783
|
+
centroid(): number[];
|
|
784
|
+
variances(): number[];
|
|
785
|
+
standardDeviations(): number[];
|
|
786
|
+
covarianceMatrix(): number[][];
|
|
787
|
+
correlationMatrix(): number[][];
|
|
788
|
+
mahalanobis(point: number[]): number;
|
|
789
|
+
mahalanobisAll(): number[];
|
|
790
|
+
outliersByMahalanobis(threshold?: number): number[][];
|
|
791
|
+
normalizeL2(): Points;
|
|
792
|
+
normalizeZscore(): Points;
|
|
640
793
|
describe(): PointsDescription;
|
|
641
794
|
}
|
|
642
795
|
/**
|
|
@@ -659,4 +812,4 @@ declare class Twokeys {
|
|
|
659
812
|
static randomPoints: typeof randomPoints;
|
|
660
813
|
}
|
|
661
814
|
|
|
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 };
|
|
815
|
+
export { type AStarOptions, type AStarResult, type AllPairsShortestPathsOptions, type AllPairsShortestPathsResult, type ArticulationBridgeResult, type BetweennessCentralityRecord, type BinnedResult, type ClosenessCentralityMode, type ClosenessCentralityOptions, type ClosenessCentralityRecord, type CommunityDetectionResult, type DbscanResult, type DegreeCentralityRecord, type DendrogramNode, 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 GraphEdaSummary, type GraphEdge, type GraphNeighbor, type GraphNodeInput, type GraphOutlierResult, type HierarchicalClusterResult, 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 LinkageMethod, 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, clusteringCoefficient, cosineSimilarity, cosineSimilaritySparse, createGraphCatalog, dbscan, Twokeys as default, degreeCentrality, euclideanDistance, gds, graphEda, graphOutliers, hierarchicalClustering, jaccardSimilarity, kMeansAuto, kMeansClustering, kNearestNeighbors, labelPropagationCommunities, linkPrediction, louvainCommunities, mahalanobisDistance, manhattanDistance, maximumFlow, minCostMaxFlow, minimumSpanningTree, nodeSimilarity, normalizeL2, overlapCoefficient, pageRank, predictLinks, shortestPath, squaredEuclideanDistance, stronglyConnectedComponents, topologicalSort, travelingSalesmanApprox, weaklyConnectedComponents, yenKShortestPaths };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vector Distance & Similarity Functions
|
|
3
|
+
*
|
|
4
|
+
* Standalone functions for vector math — zero dependencies.
|
|
5
|
+
* These are the workhorses that Points, graph algorithms, and consumers all use.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Cosine similarity between two dense vectors.
|
|
9
|
+
* Returns a value in [-1, 1] where 1 means identical direction.
|
|
10
|
+
*/
|
|
11
|
+
declare function cosineSimilarity(a: number[], b: number[]): number;
|
|
12
|
+
/**
|
|
13
|
+
* Squared Euclidean distance between two dense vectors.
|
|
14
|
+
* Avoids the sqrt for performance-sensitive comparisons.
|
|
15
|
+
*/
|
|
16
|
+
declare function squaredEuclideanDistance(a: number[], b: number[]): number;
|
|
17
|
+
/**
|
|
18
|
+
* Euclidean (L2) distance between two dense vectors.
|
|
19
|
+
*/
|
|
20
|
+
declare function euclideanDistance(a: number[], b: number[]): number;
|
|
21
|
+
/**
|
|
22
|
+
* Manhattan (L1) distance between two dense vectors.
|
|
23
|
+
*/
|
|
24
|
+
declare function manhattanDistance(a: number[], b: number[]): number;
|
|
25
|
+
/**
|
|
26
|
+
* Mahalanobis distance of a point from a distribution described by
|
|
27
|
+
* per-dimension means and variances.
|
|
28
|
+
*
|
|
29
|
+
* This is the diagonal-covariance special case (dimensions are independent),
|
|
30
|
+
* which is what most embedding-space consumers need.
|
|
31
|
+
*
|
|
32
|
+
* d = sqrt( Σ (x_i - μ_i)² / max(σ²_i, ε) )
|
|
33
|
+
*/
|
|
34
|
+
declare function mahalanobisDistance(point: number[], means: number[], variances: number[], epsilon?: number): number;
|
|
35
|
+
/**
|
|
36
|
+
* L2-normalize a dense vector (unit vector in same direction).
|
|
37
|
+
* Returns the zero vector if the input has zero magnitude.
|
|
38
|
+
*/
|
|
39
|
+
declare function normalizeL2(vector: number[]): number[];
|
|
40
|
+
/**
|
|
41
|
+
* Cosine similarity between two sparse vectors represented as Map<string, number>.
|
|
42
|
+
*/
|
|
43
|
+
declare function cosineSimilaritySparse(a: Map<string, number>, b: Map<string, number>): number;
|
|
44
|
+
/**
|
|
45
|
+
* Jaccard similarity between two sets: |A ∩ B| / |A ∪ B|.
|
|
46
|
+
* Returns 0 for empty sets.
|
|
47
|
+
*/
|
|
48
|
+
declare function jaccardSimilarity<T>(a: Set<T>, b: Set<T>): number;
|
|
49
|
+
/**
|
|
50
|
+
* Overlap coefficient: |A ∩ B| / min(|A|, |B|).
|
|
51
|
+
* Returns 0 for empty sets.
|
|
52
|
+
*/
|
|
53
|
+
declare function overlapCoefficient<T>(a: Set<T>, b: Set<T>): number;
|
|
54
|
+
|
|
1
55
|
type GraphNodeInput<NodeId extends string = string> = NodeId | {
|
|
2
56
|
id: NodeId;
|
|
3
57
|
};
|
|
@@ -358,6 +412,83 @@ declare function minCostMaxFlow<NodeId extends string>(nodes: GraphNodeInput<Nod
|
|
|
358
412
|
declare function kMeansClustering(points: number[][], k: number, options?: KMeansOptions): KMeansResult;
|
|
359
413
|
declare function kMeansAuto(points: number[][], options?: KMeansAutoOptions): KMeansAutoResult;
|
|
360
414
|
declare function travelingSalesmanApprox<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: TravelingSalesmanOptions<NodeId>): TravelingSalesmanResult<NodeId>;
|
|
415
|
+
type LinkageMethod = 'single' | 'complete' | 'average' | 'ward';
|
|
416
|
+
interface DendrogramNode {
|
|
417
|
+
left: number;
|
|
418
|
+
right: number;
|
|
419
|
+
distance: number;
|
|
420
|
+
size: number;
|
|
421
|
+
}
|
|
422
|
+
interface HierarchicalClusterResult {
|
|
423
|
+
clusters: number[][];
|
|
424
|
+
assignments: number[];
|
|
425
|
+
dendrogram: DendrogramNode[];
|
|
426
|
+
silhouette: number | null;
|
|
427
|
+
}
|
|
428
|
+
declare function hierarchicalClustering(points: number[][], k: number, options?: {
|
|
429
|
+
linkage?: LinkageMethod;
|
|
430
|
+
distanceMetric?: 'euclidean' | 'cosine' | 'manhattan';
|
|
431
|
+
}): HierarchicalClusterResult;
|
|
432
|
+
interface DbscanResult {
|
|
433
|
+
clusters: number[][];
|
|
434
|
+
assignments: number[];
|
|
435
|
+
noise: number[];
|
|
436
|
+
clusterCount: number;
|
|
437
|
+
}
|
|
438
|
+
declare function dbscan(points: number[][], epsilon: number, minPoints: number, options?: {
|
|
439
|
+
distanceMetric?: 'euclidean' | 'cosine' | 'manhattan';
|
|
440
|
+
}): DbscanResult;
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Graph EDA — What Tukey Would Have Done With Graphs
|
|
444
|
+
*
|
|
445
|
+
* Treats graph structural properties as data series that deserve
|
|
446
|
+
* full exploratory data analysis treatment.
|
|
447
|
+
*/
|
|
448
|
+
|
|
449
|
+
interface GraphEdaSummary<NodeId extends string = string> {
|
|
450
|
+
nodeCount: number;
|
|
451
|
+
edgeCount: number;
|
|
452
|
+
density: number;
|
|
453
|
+
degreeDistribution: SeriesDescription;
|
|
454
|
+
inDegreeDistribution: SeriesDescription;
|
|
455
|
+
outDegreeDistribution: SeriesDescription;
|
|
456
|
+
clusteringCoefficients: Map<NodeId, number>;
|
|
457
|
+
globalClusteringCoefficient: number;
|
|
458
|
+
clusteringDistribution: SeriesDescription;
|
|
459
|
+
averagePathLength: number;
|
|
460
|
+
diameter: number;
|
|
461
|
+
reciprocity: number;
|
|
462
|
+
degreeAssortativity: number;
|
|
463
|
+
}
|
|
464
|
+
interface GraphOutlierResult<NodeId extends string = string> {
|
|
465
|
+
nodeId: NodeId;
|
|
466
|
+
score: number;
|
|
467
|
+
reason: string;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Compute the local clustering coefficient for each node.
|
|
471
|
+
* For undirected graphs: the fraction of pairs of neighbors that are connected.
|
|
472
|
+
* For directed graphs: uses the total number of directed triangles.
|
|
473
|
+
*/
|
|
474
|
+
declare function clusteringCoefficient<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: {
|
|
475
|
+
directed?: boolean;
|
|
476
|
+
}): Map<NodeId, number>;
|
|
477
|
+
/**
|
|
478
|
+
* Full exploratory data analysis of a graph's structural properties.
|
|
479
|
+
* Returns distributions as Series descriptions for full Tukey-style EDA.
|
|
480
|
+
*/
|
|
481
|
+
declare function graphEda<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: {
|
|
482
|
+
directed?: boolean;
|
|
483
|
+
samplePathLength?: number;
|
|
484
|
+
}): GraphEdaSummary<NodeId>;
|
|
485
|
+
/**
|
|
486
|
+
* Graph-based outlier detection: nodes with unusual structural signatures.
|
|
487
|
+
*/
|
|
488
|
+
declare function graphOutliers<NodeId extends string>(nodes: GraphNodeInput<NodeId>[], edges: GraphEdge<NodeId>[], options?: {
|
|
489
|
+
method?: 'degree' | 'clustering' | 'combined';
|
|
490
|
+
threshold?: number;
|
|
491
|
+
}): GraphOutlierResult<NodeId>[];
|
|
361
492
|
|
|
362
493
|
interface GdsProjectOptions {
|
|
363
494
|
directed?: boolean;
|
|
@@ -548,6 +679,12 @@ interface SeriesDescription {
|
|
|
548
679
|
}
|
|
549
680
|
interface PointsDescription {
|
|
550
681
|
original: number[][];
|
|
682
|
+
centroid: number[];
|
|
683
|
+
variances: number[];
|
|
684
|
+
correlationMatrix: number[][];
|
|
685
|
+
mahalanobisDistances: number[];
|
|
686
|
+
outlierCount: number;
|
|
687
|
+
dimensionSummaries: SeriesDescription[];
|
|
551
688
|
}
|
|
552
689
|
declare function randomInteger(max?: number): number;
|
|
553
690
|
declare function randomSeries(count?: number, max?: number): number[];
|
|
@@ -566,6 +703,12 @@ declare class Series {
|
|
|
566
703
|
private getMedian;
|
|
567
704
|
mean(): number;
|
|
568
705
|
private getMean;
|
|
706
|
+
variance(): number;
|
|
707
|
+
stddev(): number;
|
|
708
|
+
ema(alpha: number): number[];
|
|
709
|
+
zscore(): number[];
|
|
710
|
+
skewness(): number;
|
|
711
|
+
kurtosis(): number;
|
|
569
712
|
mode(): ModeResult;
|
|
570
713
|
private getMode;
|
|
571
714
|
extremes(): number[];
|
|
@@ -637,6 +780,16 @@ declare class Points {
|
|
|
637
780
|
private dimension;
|
|
638
781
|
private count;
|
|
639
782
|
constructor(options?: PointsOptions | number);
|
|
783
|
+
centroid(): number[];
|
|
784
|
+
variances(): number[];
|
|
785
|
+
standardDeviations(): number[];
|
|
786
|
+
covarianceMatrix(): number[][];
|
|
787
|
+
correlationMatrix(): number[][];
|
|
788
|
+
mahalanobis(point: number[]): number;
|
|
789
|
+
mahalanobisAll(): number[];
|
|
790
|
+
outliersByMahalanobis(threshold?: number): number[][];
|
|
791
|
+
normalizeL2(): Points;
|
|
792
|
+
normalizeZscore(): Points;
|
|
640
793
|
describe(): PointsDescription;
|
|
641
794
|
}
|
|
642
795
|
/**
|
|
@@ -659,4 +812,4 @@ declare class Twokeys {
|
|
|
659
812
|
static randomPoints: typeof randomPoints;
|
|
660
813
|
}
|
|
661
814
|
|
|
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 };
|
|
815
|
+
export { type AStarOptions, type AStarResult, type AllPairsShortestPathsOptions, type AllPairsShortestPathsResult, type ArticulationBridgeResult, type BetweennessCentralityRecord, type BinnedResult, type ClosenessCentralityMode, type ClosenessCentralityOptions, type ClosenessCentralityRecord, type CommunityDetectionResult, type DbscanResult, type DegreeCentralityRecord, type DendrogramNode, 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 GraphEdaSummary, type GraphEdge, type GraphNeighbor, type GraphNodeInput, type GraphOutlierResult, type HierarchicalClusterResult, 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 LinkageMethod, 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, clusteringCoefficient, cosineSimilarity, cosineSimilaritySparse, createGraphCatalog, dbscan, Twokeys as default, degreeCentrality, euclideanDistance, gds, graphEda, graphOutliers, hierarchicalClustering, jaccardSimilarity, kMeansAuto, kMeansClustering, kNearestNeighbors, labelPropagationCommunities, linkPrediction, louvainCommunities, mahalanobisDistance, manhattanDistance, maximumFlow, minCostMaxFlow, minimumSpanningTree, nodeSimilarity, normalizeL2, overlapCoefficient, pageRank, predictLinks, shortestPath, squaredEuclideanDistance, stronglyConnectedComponents, topologicalSort, travelingSalesmanApprox, weaklyConnectedComponents, yenKShortestPaths };
|