Skip to content

Commit dde9ef5

Browse files
committed
feat(traversal): add node discovery iteration tracking to salience-prioritised
Track when each node is first discovered during expansion for analysis of exploration patterns and temporal ordering of node discovery.
1 parent 0e2e4a6 commit dde9ef5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/algorithms/traversal/salience-prioritised-expansion.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ export class SaliencePrioritisedExpansion<T> implements GraphExpander<T> {
6565
/** Track which seed pairs have connected */
6666
private readonly connectedPairs = new Set<string>();
6767

68+
/** Tracks when each node was first discovered (iteration number) */
69+
private readonly nodeDiscoveryIteration = new Map<string, number>();
70+
6871
/**
6972
* Create a new salience-prioritised expansion.
7073
*
@@ -98,6 +101,9 @@ export class SaliencePrioritisedExpansion<T> implements GraphExpander<T> {
98101
});
99102

100103
this.nodeToFrontierIndex.set(seed, index);
104+
105+
// Seeds are discovered at iteration 0
106+
this.nodeDiscoveryIteration.set(seed, 0);
101107
}
102108
}
103109

@@ -178,6 +184,11 @@ export class SaliencePrioritisedExpansion<T> implements GraphExpander<T> {
178184
activeState.parents.set(targetId, { parent: node, edge: relationshipType });
179185
this.nodeToFrontierIndex.set(targetId, activeIndex);
180186

187+
// Track first discovery iteration (only if not already discovered)
188+
if (!this.nodeDiscoveryIteration.has(targetId)) {
189+
this.nodeDiscoveryIteration.set(targetId, this.stats.iterations);
190+
}
191+
181192
// Add to frontier with salience priority
182193
const neighborSalience = this.nodeSalience.get(targetId) ?? 0;
183194
const priority = neighborSalience * 1000 - this.expander.calculatePriority(targetId);
@@ -225,6 +236,7 @@ export class SaliencePrioritisedExpansion<T> implements GraphExpander<T> {
225236
sampledEdges,
226237
visitedPerFrontier,
227238
stats: this.stats,
239+
nodeDiscoveryIteration: this.nodeDiscoveryIteration,
228240
};
229241
}
230242

0 commit comments

Comments
 (0)