Skip to content

Commit 5e73979

Browse files
committed
chore(graph-expansion): update package exports
Update main index exports for new structure: - Remove GraphAdapter export (moved to algorithms) - Export ReadableGraph, GraphExpander, Neighbor types - Export BFS, DFS, BidirectionalBFS algorithms - Export ego-network extraction functions
1 parent 1b17795 commit 5e73979

File tree

1 file changed

+83
-2
lines changed

1 file changed

+83
-2
lines changed

packages/graph-expansion/src/index.ts

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,89 @@
33
*
44
* Generic system for expanding graphs by loading neighbors and exploring
55
* graph neighborhoods regardless of the underlying graph data structure.
6+
*
7+
* ## Core Features
8+
*
9+
* - **Generic Interfaces**: Works with any graph implementation through ReadableGraph
10+
* - **Dynamic Expansion**: GraphExpander interface for lazy-loading from APIs/databases
11+
* - **Traversal Algorithms**: BFS, DFS, bidirectional BFS with degree-based prioritization
12+
* - **Extraction Methods**: k-hop ego network extraction
13+
* - **Zero Coupling**: No dependencies on specific graph implementations
14+
*
15+
* ## Usage
16+
*
17+
* ```typescript
18+
* import { bfs, dfs, extractEgoNetwork, GraphAdapter } from '@bibgraph/graph-expansion';
19+
* import { Graph } from '@bibgraph/algorithms';
20+
*
21+
* // Use with algorithms Graph class
22+
* const graph = new Graph<MyNode, MyEdge>(true);
23+
* // ... add nodes and edges ...
24+
* const adapter = new GraphAdapter(graph);
25+
*
26+
* // BFS traversal
27+
* const bfsResult = bfs(adapter, 'startNodeId');
28+
*
29+
* // DFS traversal
30+
* const dfsResult = dfs(adapter, 'startNodeId');
31+
*
32+
* // Ego network extraction
33+
* const egoNetwork = extractEgoNetwork(adapter, {
34+
* radius: 2,
35+
* seedNodes: ['nodeId'],
36+
* });
37+
*
38+
* // Dynamic expansion with GraphExpander
39+
* import { BidirectionalBFS } from '@bibgraph/graph-expansion';
40+
*
41+
* const bfs = new BidirectionalBFS(
42+
* expander,
43+
* 'nodeA',
44+
* 'nodeB',
45+
* { targetPaths: 5, maxIterations: 10 }
46+
* );
47+
*
48+
* const result = await bfs.search();
49+
* ```
50+
*
51+
* ## Custom Graph Implementations
52+
*
53+
* ```typescript
54+
* import { ReadableGraph, bfs } from '@bibgraph/graph-expansion';
55+
*
56+
* class MyDatabaseGraph implements ReadableGraph<MyNode, MyEdge> {
57+
* hasNode(id: string): boolean { ... }
58+
* getNode(id: string): MyNode | null { ... }
59+
* getNeighbors(id: string): string[] { ... }
60+
* getAllNodes(): MyNode[] { ... }
61+
* isDirected(): boolean { ... }
62+
* getOutgoingEdges?(id: string): MyEdge[] { ... }
63+
* }
64+
*
65+
* const result = bfs(new MyDatabaseGraph(), 'startNodeId');
66+
* ```
667
*/
768

8-
// Re-exports will be added here as the package develops
69+
// Interfaces
70+
export type { GraphExpander, Neighbor } from './interfaces/graph-expander';
71+
export type { ReadableGraph, NodeBase, EdgeBase } from './interfaces/readable-graph';
72+
73+
// Traversal algorithms
74+
export { bfs } from './traversal/bfs';
75+
export type { TraversalResult } from './traversal/bfs';
76+
export { dfs } from './traversal/dfs';
77+
export type { DFSTraversalResult } from './traversal/dfs';
78+
export { BidirectionalBFS } from './traversal/bidirectional-bfs';
79+
export type { BidirectionalBFSOptions, BidirectionalBFSResult } from './traversal/bidirectional-bfs';
80+
export { PriorityQueue } from './traversal/priority-queue';
981

10-
export {};
82+
// Extraction algorithms
83+
export {
84+
extractEgoNetwork,
85+
extractMultiSourceEgoNetwork,
86+
} from './extraction/ego-network';
87+
export type {
88+
EgoNetworkOptions,
89+
ExtractionError,
90+
InducedSubgraph,
91+
} from './extraction/ego-network';

0 commit comments

Comments
 (0)