|
3 | 3 | * |
4 | 4 | * Generic system for expanding graphs by loading neighbors and exploring |
5 | 5 | * 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 | + * ``` |
6 | 67 | */ |
7 | 68 |
|
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'; |
9 | 81 |
|
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