Skip to content

Commit c5fb0b2

Browse files
committed
refactor(graph-expansion): update BidirectionalBFS imports
Update BidirectionalBFS to import GraphExpander and Neighbor from centralized interfaces package.
1 parent cd77a4a commit c5fb0b2

File tree

1 file changed

+1
-51
lines changed

1 file changed

+1
-51
lines changed

packages/graph-expansion/src/traversal/bidirectional-bfs.ts

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,6 @@
1+
import { GraphExpander, type Neighbor } from '../interfaces/graph-expander';
12
import { PriorityQueue } from './priority-queue';
23

3-
/**
4-
* Neighbor relationship returned by GraphExpander.
5-
*/
6-
export interface Neighbor {
7-
targetId: string;
8-
relationshipType: string;
9-
}
10-
11-
/**
12-
* Interface for dynamic neighbor discovery during graph traversal.
13-
* Allows BFS to work with any data source (API, database, file system, etc.).
14-
*
15-
* @template T - Type of node data
16-
*/
17-
export interface GraphExpander<T> {
18-
/**
19-
* Get neighbors of a node, potentially fetching from external source.
20-
*
21-
* @param nodeId - Node whose neighbors to fetch
22-
* @returns Array of neighbor relationships
23-
*/
24-
getNeighbors(nodeId: string): Promise<Neighbor[]>;
25-
26-
/**
27-
* Get node degree for priority computation.
28-
* Used to prioritize low-degree (specific) nodes over high-degree (generic) nodes.
29-
*
30-
* @param nodeId - Node to get degree for
31-
* @returns Number of relationships (higher = lower priority)
32-
*/
33-
getDegree(nodeId: string): number;
34-
35-
/**
36-
* Get node data (may fetch from cache/API).
37-
*
38-
* @param nodeId - Node to retrieve
39-
* @returns Node data or null if not found
40-
*/
41-
getNode(nodeId: string): Promise<T | null>;
42-
43-
/**
44-
* Add an edge to the final graph output.
45-
* Called during node expansion to track discovered relationships.
46-
*
47-
* @param source - Source node ID
48-
* @param target - Target node ID
49-
* @param relationshipType - Type of relationship
50-
*/
51-
addEdge(source: string, target: string, relationshipType: string): void;
52-
}
53-
544
/**
555
* Configuration options for bidirectional BFS.
566
*/

0 commit comments

Comments
 (0)