Skip to content

Commit 9416e77

Browse files
committed
refactor(algorithms): use graph-expansion BFS in path extraction
Update findPathWithBFS to use BFS from @bibgraph/graph-expansion via GraphAdapter wrapper.
1 parent 392594f commit 9416e77

File tree

1 file changed

+4
-2
lines changed
  • packages/algorithms/src/extraction

1 file changed

+4
-2
lines changed

packages/algorithms/src/extraction/path.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
* Provides shortest path finding and reachability subgraph extraction.
44
*/
55
import { Graph } from '../graph/graph';
6+
import { GraphAdapter } from '../graph-adapter';
7+
import { bfs } from '@bibgraph/graph-expansion';
68
import { dijkstra } from '../pathfinding/dijkstra';
7-
import { bfs } from '../traversal/bfs';
89
import type { Path } from '../types/algorithm-results';
910
import type { ExtractionError } from '../types/errors';
1011
import type { Edge,Node } from '../types/graph';
@@ -216,7 +217,8 @@ const checkIfWeighted = <N extends Node, E extends Edge>(graph: Graph<N, E>): bo
216217
* @internal
217218
*/
218219
const findPathWithBFS = <N extends Node, E extends Edge>(graph: Graph<N, E>, sourceId: string, targetId: string): Result<Option<Path<N, E>>, ExtractionError> => {
219-
const bfsResult = bfs(graph, sourceId);
220+
const adapter = new GraphAdapter(graph);
221+
const bfsResult = bfs(adapter, sourceId);
220222

221223
if (!bfsResult.ok) {
222224
// Convert traversal error to extraction error

0 commit comments

Comments
 (0)