import { Graph } from '../graph/graph'; import { Path } from '../types/algorithm-results'; import { GraphError } from '../types/errors'; import { Edge, Node } from '../types/graph'; import { Option } from '../types/option'; import { Result } from '../types/result'; import { WeightFunction } from '../types/weight-function'; /** * Dijkstra's shortest path algorithm. * * Finds the shortest path between two nodes in a weighted graph. * Uses a min-heap priority queue for efficient selection of next node to process. * * Time Complexity: O((V + E) log V) where V = vertices, E = edges * Space Complexity: O(V) for distances, predecessors, and priority queue * * **Important**: Does not work with negative edge weights. Use Bellman-Ford for graphs * with negative weights. * @param graph - The graph to search * @param startId - ID of the start node * @param endId - ID of the end node * @param weightFn - Optional function to extract weight from edges/nodes. Defaults to edge.weight ?? 1 * @param weightFunction * @returns Result containing Option or error * - Ok(Some(path)) if path exists * - Ok(None) if no path exists (disconnected) * - Err(NegativeWeightError) if negative weights detected * - Err(InvalidInputError) if start/end nodes not found * @example * ```typescript * const graph = new Graph(true); * graph.addNode({ id: 'A', type: 'test', elevation: 100 }); * graph.addNode({ id: 'B', type: 'test', elevation: 200 }); * graph.addEdge({ id: 'E1', source: 'A', target: 'B', type: 'edge', weight: 5 }); * * // Use default edge weights * const result1 = dijkstra(graph, 'A', 'B'); * * // Use custom edge attribute * const result2 = dijkstra(graph, 'A', 'B', (edge) => edge.customCost); * * // Use node elevation difference * const result3 = dijkstra(graph, 'A', 'B', (edge, source, target) => * Math.abs(source.elevation - target.elevation) * ); * ``` */ export declare const dijkstra: (graph: Graph, startId: string, endId: string, weightFunction?: WeightFunction) => Result>, GraphError>; //# sourceMappingURL=dijkstra.d.ts.map