graphwise 1.4.3 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__test__/fixtures/index.d.ts +1 -0
- package/dist/__test__/fixtures/index.d.ts.map +1 -1
- package/dist/__test__/fixtures/metrics.d.ts +86 -0
- package/dist/__test__/fixtures/metrics.d.ts.map +1 -0
- package/dist/__test__/fixtures/metrics.unit.test.d.ts +7 -0
- package/dist/__test__/fixtures/metrics.unit.test.d.ts.map +1 -0
- package/dist/expansion/dfs-priority.d.ts +23 -0
- package/dist/expansion/dfs-priority.d.ts.map +1 -0
- package/dist/expansion/dfs-priority.unit.test.d.ts +2 -0
- package/dist/expansion/dfs-priority.unit.test.d.ts.map +1 -0
- package/dist/expansion/index.d.ts +3 -0
- package/dist/expansion/index.d.ts.map +1 -1
- package/dist/expansion/k-hop.d.ts +26 -0
- package/dist/expansion/k-hop.d.ts.map +1 -0
- package/dist/expansion/k-hop.unit.test.d.ts +2 -0
- package/dist/expansion/k-hop.unit.test.d.ts.map +1 -0
- package/dist/expansion/random-walk.d.ts +35 -0
- package/dist/expansion/random-walk.d.ts.map +1 -0
- package/dist/expansion/random-walk.unit.test.d.ts +2 -0
- package/dist/expansion/random-walk.unit.test.d.ts.map +1 -0
- package/dist/index/index.cjs +716 -5
- package/dist/index/index.cjs.map +1 -1
- package/dist/index/index.js +707 -6
- package/dist/index/index.js.map +1 -1
- package/dist/ranking/baselines/hitting-time.d.ts +27 -0
- package/dist/ranking/baselines/hitting-time.d.ts.map +1 -0
- package/dist/ranking/baselines/hitting-time.unit.test.d.ts +2 -0
- package/dist/ranking/baselines/hitting-time.unit.test.d.ts.map +1 -0
- package/dist/ranking/baselines/index.d.ts +1 -0
- package/dist/ranking/baselines/index.d.ts.map +1 -1
- package/dist/ranking/mi/cosine.d.ts +13 -0
- package/dist/ranking/mi/cosine.d.ts.map +1 -0
- package/dist/ranking/mi/cosine.unit.test.d.ts +2 -0
- package/dist/ranking/mi/cosine.unit.test.d.ts.map +1 -0
- package/dist/ranking/mi/hub-promoted.d.ts +13 -0
- package/dist/ranking/mi/hub-promoted.d.ts.map +1 -0
- package/dist/ranking/mi/hub-promoted.unit.test.d.ts +2 -0
- package/dist/ranking/mi/hub-promoted.unit.test.d.ts.map +1 -0
- package/dist/ranking/mi/index.d.ts +5 -0
- package/dist/ranking/mi/index.d.ts.map +1 -1
- package/dist/ranking/mi/overlap-coefficient.d.ts +13 -0
- package/dist/ranking/mi/overlap-coefficient.d.ts.map +1 -0
- package/dist/ranking/mi/overlap-coefficient.unit.test.d.ts +2 -0
- package/dist/ranking/mi/overlap-coefficient.unit.test.d.ts.map +1 -0
- package/dist/ranking/mi/resource-allocation.d.ts +13 -0
- package/dist/ranking/mi/resource-allocation.d.ts.map +1 -0
- package/dist/ranking/mi/resource-allocation.unit.test.d.ts +2 -0
- package/dist/ranking/mi/resource-allocation.unit.test.d.ts.map +1 -0
- package/dist/ranking/mi/sorensen.d.ts +13 -0
- package/dist/ranking/mi/sorensen.d.ts.map +1 -0
- package/dist/ranking/mi/sorensen.unit.test.d.ts +2 -0
- package/dist/ranking/mi/sorensen.unit.test.d.ts.map +1 -0
- package/dist/ranking/mi/types.d.ts +1 -1
- package/dist/ranking/mi/types.d.ts.map +1 -1
- package/dist/schemas/graph.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/__test__/fixtures/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/__test__/fixtures/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { NodeId, NodeData, EdgeData, ReadableGraph } from '../../graph';
|
|
2
|
+
import { ExpansionResult } from '../../expansion/types';
|
|
3
|
+
import { PARSEResult } from '../../ranking/parse';
|
|
4
|
+
/**
|
|
5
|
+
* Fraction of visited nodes whose degree is below the 90th percentile of all
|
|
6
|
+
* sampled node degrees. A high ratio indicates the algorithm successfully
|
|
7
|
+
* defers high-degree hubs in favour of lower-degree nodes.
|
|
8
|
+
*/
|
|
9
|
+
export declare function hubDeferralRatio<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, result: ExpansionResult): number;
|
|
10
|
+
/**
|
|
11
|
+
* Count of distinct intermediate nodes (i.e. excluding endpoints) across all
|
|
12
|
+
* discovered paths. Higher values indicate broader path diversity.
|
|
13
|
+
*/
|
|
14
|
+
export declare function pathDiversity(result: ExpansionResult): number;
|
|
15
|
+
/**
|
|
16
|
+
* Ratio of sampled edges to sampled nodes. Reflects how densely the sampled
|
|
17
|
+
* subgraph is connected (higher = more edges per node).
|
|
18
|
+
*/
|
|
19
|
+
export declare function subgraphDensity(result: ExpansionResult): number;
|
|
20
|
+
/**
|
|
21
|
+
* Ratio of discovered paths to total nodes visited. Measures how efficiently
|
|
22
|
+
* the expansion produced useful paths relative to exploration cost.
|
|
23
|
+
*/
|
|
24
|
+
export declare function coverageEfficiency(result: ExpansionResult): number;
|
|
25
|
+
/**
|
|
26
|
+
* Ratio of total iterations to paths discovered. Measures how many
|
|
27
|
+
* iterations were required per path. Returns Infinity when no paths
|
|
28
|
+
* were found (expansion terminated without connecting seeds).
|
|
29
|
+
*/
|
|
30
|
+
export declare function firstPathLatency(result: ExpansionResult): number;
|
|
31
|
+
/**
|
|
32
|
+
* Number of distinct node types present in the sampled node set.
|
|
33
|
+
* Nodes without a `type` property are counted as a single unnamed type.
|
|
34
|
+
*/
|
|
35
|
+
export declare function typeCoverage<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, result: ExpansionResult): number;
|
|
36
|
+
/**
|
|
37
|
+
* Number of connected components that contain at least one path node,
|
|
38
|
+
* determined via union-find over the sampled edge set. Higher values
|
|
39
|
+
* indicate paths spanning structurally distant regions of the graph.
|
|
40
|
+
*/
|
|
41
|
+
export declare function communitySpan(result: ExpansionResult): number;
|
|
42
|
+
/**
|
|
43
|
+
* Spearman rank correlation coefficient between two rankings (arrays of node
|
|
44
|
+
* IDs ordered from highest to lowest). Returns a value in [-1, 1] where 1
|
|
45
|
+
* means identical order and -1 means perfectly reversed.
|
|
46
|
+
*
|
|
47
|
+
* Only nodes present in both rankings are considered.
|
|
48
|
+
*/
|
|
49
|
+
export declare function spearmanRho(rankingA: readonly NodeId[], rankingB: readonly NodeId[]): number;
|
|
50
|
+
/**
|
|
51
|
+
* Kendall tau rank correlation coefficient between two rankings. Returns a
|
|
52
|
+
* value in [-1, 1] where 1 means identical and -1 means fully reversed.
|
|
53
|
+
*
|
|
54
|
+
* Only nodes present in both rankings are considered.
|
|
55
|
+
*/
|
|
56
|
+
export declare function kendallTau(rankingA: readonly NodeId[], rankingB: readonly NodeId[]): number;
|
|
57
|
+
/**
|
|
58
|
+
* Ratio of weak-link path salience to consistent-path salience. Values below
|
|
59
|
+
* 1 indicate the consistent path scores higher (expected behaviour); values
|
|
60
|
+
* above 1 indicate the weak-link path is incorrectly ranked higher.
|
|
61
|
+
*
|
|
62
|
+
* @param consistent - Mean salience of paths expected to rank highest
|
|
63
|
+
* @param weakLink - Mean salience of paths expected to rank lower
|
|
64
|
+
*/
|
|
65
|
+
export declare function weakLinkSensitivity(consistent: number, weakLink: number): number;
|
|
66
|
+
/**
|
|
67
|
+
* Sample variance of salience scores across all ranked paths. Returns 0 when
|
|
68
|
+
* all paths have identical scores (no discriminative power).
|
|
69
|
+
*/
|
|
70
|
+
export declare function scoreVariance(parseResult: PARSEResult): number;
|
|
71
|
+
/**
|
|
72
|
+
* Pearson correlation between path length (number of edges) and salience
|
|
73
|
+
* score. Values near 0 indicate length-unbiased ranking; strong positive or
|
|
74
|
+
* negative values indicate length bias.
|
|
75
|
+
*/
|
|
76
|
+
export declare function lengthBias(parseResult: PARSEResult): number;
|
|
77
|
+
/**
|
|
78
|
+
* Ratio of hub path salience to peripheral path salience. Values below 1
|
|
79
|
+
* indicate hub paths score lower (hub penalty is working); values at or above
|
|
80
|
+
* 1 indicate no penalty.
|
|
81
|
+
*
|
|
82
|
+
* @param peripheral - Mean salience of paths through low-degree nodes
|
|
83
|
+
* @param hub - Mean salience of paths through high-degree hub nodes
|
|
84
|
+
*/
|
|
85
|
+
export declare function hubPenaltyStrength(peripheral: number, hub: number): number;
|
|
86
|
+
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../src/__test__/fixtures/metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAMvD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EACtE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,MAAM,EAAE,eAAe,GACrB,MAAM,CAaR;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAa7D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAM/D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAMlE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAKhE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EAClE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,MAAM,EAAE,eAAe,GACrB,MAAM,CASR;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CA4C7D;AAMD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAC1B,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,QAAQ,EAAE,SAAS,MAAM,EAAE,GACzB,MAAM,CA+BR;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACzB,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,QAAQ,EAAE,SAAS,MAAM,EAAE,GACzB,MAAM,CAsCR;AAMD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAClC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACd,MAAM,CAKR;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAS9D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CA+B3D;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAK1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.unit.test.d.ts","sourceRoot":"","sources":["../../../src/__test__/fixtures/metrics.unit.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NodeData, EdgeData, ReadableGraph } from '../graph';
|
|
2
|
+
import { Seed, ExpansionResult, ExpansionConfig, PriorityContext } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* DFS priority function: negative iteration produces LIFO ordering.
|
|
5
|
+
*
|
|
6
|
+
* Lower priority values are expanded first, so negating the iteration
|
|
7
|
+
* counter ensures the most recently enqueued node is always next.
|
|
8
|
+
*/
|
|
9
|
+
export declare function dfsPriorityFn<N extends NodeData, E extends EdgeData>(_nodeId: string, context: PriorityContext<N, E>): number;
|
|
10
|
+
/**
|
|
11
|
+
* Run DFS-priority expansion (LIFO discovery order).
|
|
12
|
+
*
|
|
13
|
+
* Uses the BASE framework with a negative-iteration priority function,
|
|
14
|
+
* which causes the most recently discovered node to be expanded first —
|
|
15
|
+
* equivalent to depth-first search behaviour.
|
|
16
|
+
*
|
|
17
|
+
* @param graph - Source graph
|
|
18
|
+
* @param seeds - Seed nodes for expansion
|
|
19
|
+
* @param config - Expansion configuration
|
|
20
|
+
* @returns Expansion result with discovered paths
|
|
21
|
+
*/
|
|
22
|
+
export declare function dfsPriority<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, seeds: readonly Seed[], config?: ExpansionConfig<N, E>): ExpansionResult;
|
|
23
|
+
//# sourceMappingURL=dfs-priority.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dfs-priority.d.ts","sourceRoot":"","sources":["../../src/expansion/dfs-priority.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,KAAK,EACX,IAAI,EACJ,eAAe,EACf,eAAe,EACf,eAAe,EACf,MAAM,SAAS,CAAC;AAGjB;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EACnE,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAC5B,MAAM,CAER;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EACjE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAC5B,eAAe,CAKjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dfs-priority.unit.test.d.ts","sourceRoot":"","sources":["../../src/expansion/dfs-priority.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -24,4 +24,7 @@ export * from './flux';
|
|
|
24
24
|
export * from './standard-bfs';
|
|
25
25
|
export * from './frontier-balanced';
|
|
26
26
|
export * from './random-priority';
|
|
27
|
+
export * from './dfs-priority';
|
|
28
|
+
export * from './k-hop';
|
|
29
|
+
export * from './random-walk';
|
|
27
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/expansion/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/expansion/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { NodeData, EdgeData, ReadableGraph } from '../graph';
|
|
2
|
+
import { Seed, ExpansionResult, ExpansionConfig } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for k-hop expansion.
|
|
5
|
+
*/
|
|
6
|
+
export interface KHopConfig<N extends NodeData = NodeData, E extends EdgeData = EdgeData> extends ExpansionConfig<N, E> {
|
|
7
|
+
/**
|
|
8
|
+
* Maximum number of hops from any seed node.
|
|
9
|
+
* Defaults to 2.
|
|
10
|
+
*/
|
|
11
|
+
readonly k?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Run k-hop expansion (fixed-depth BFS).
|
|
15
|
+
*
|
|
16
|
+
* Explores all nodes reachable within exactly k hops of any seed using
|
|
17
|
+
* breadth-first search. Paths between seeds are detected when a node
|
|
18
|
+
* is reached by frontiers from two different seeds.
|
|
19
|
+
*
|
|
20
|
+
* @param graph - Source graph
|
|
21
|
+
* @param seeds - Seed nodes for expansion
|
|
22
|
+
* @param config - K-hop configuration (k defaults to 2)
|
|
23
|
+
* @returns Expansion result with discovered paths
|
|
24
|
+
*/
|
|
25
|
+
export declare function kHop<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, seeds: readonly Seed[], config?: KHopConfig<N, E>): ExpansionResult;
|
|
26
|
+
//# sourceMappingURL=k-hop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"k-hop.d.ts","sourceRoot":"","sources":["../../src/expansion/k-hop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAU,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,KAAK,EACX,IAAI,EACJ,eAAe,EAGf,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,UAAU,CAC1B,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7B,CAAC,SAAS,QAAQ,GAAG,QAAQ,CAC5B,SAAQ,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EAC1D,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GACvB,eAAe,CA4JjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"k-hop.unit.test.d.ts","sourceRoot":"","sources":["../../src/expansion/k-hop.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { NodeData, EdgeData, ReadableGraph } from '../graph';
|
|
2
|
+
import { Seed, ExpansionResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for random-walk-with-restart expansion.
|
|
5
|
+
*/
|
|
6
|
+
export interface RandomWalkConfig {
|
|
7
|
+
/** Probability of restarting a walk from its seed node (default: 0.15). */
|
|
8
|
+
readonly restartProbability?: number;
|
|
9
|
+
/** Number of walks to perform per seed node (default: 10). */
|
|
10
|
+
readonly walks?: number;
|
|
11
|
+
/** Maximum steps per walk (default: 20). */
|
|
12
|
+
readonly walkLength?: number;
|
|
13
|
+
/** Random seed for deterministic reproducibility (default: 0). */
|
|
14
|
+
readonly seed?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Run random-walk-with-restart expansion.
|
|
18
|
+
*
|
|
19
|
+
* For each seed, performs `walks` independent random walks of up to
|
|
20
|
+
* `walkLength` steps. At each step the walk either restarts (with
|
|
21
|
+
* probability `restartProbability`) or moves to a uniformly sampled
|
|
22
|
+
* neighbour. All visited nodes and traversed edges are collected.
|
|
23
|
+
*
|
|
24
|
+
* Inter-seed paths are detected when a walk reaches a node that was
|
|
25
|
+
* previously reached by a walk originating from a different seed.
|
|
26
|
+
* The recorded path contains only the two seed endpoints rather than
|
|
27
|
+
* the full walk trajectory, consistent with the ExpansionPath contract.
|
|
28
|
+
*
|
|
29
|
+
* @param graph - Source graph
|
|
30
|
+
* @param seeds - Seed nodes for expansion
|
|
31
|
+
* @param config - Random walk configuration
|
|
32
|
+
* @returns Expansion result with discovered paths
|
|
33
|
+
*/
|
|
34
|
+
export declare function randomWalk<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, seeds: readonly Seed[], config?: RandomWalkConfig): ExpansionResult;
|
|
35
|
+
//# sourceMappingURL=random-walk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"random-walk.d.ts","sourceRoot":"","sources":["../../src/expansion/random-walk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAU,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,KAAK,EACX,IAAI,EACJ,eAAe,EAGf,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,2EAA2E;IAC3E,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,4CAA4C;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,kEAAkE;IAClE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACvB;AAqBD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EAChE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,MAAM,CAAC,EAAE,gBAAgB,GACvB,eAAe,CAwJjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"random-walk.unit.test.d.ts","sourceRoot":"","sources":["../../src/expansion/random-walk.unit.test.ts"],"names":[],"mappings":""}
|