Hierarchy

  • Dijkstra

Constructors

Methods

  • Finds shortest distances from a start node to all other nodes

    Parameters

    • graph: WeightedGraph

      weighted graph as adjacency list

    • start: string

      starting node

    Returns {
        [key: string]: number;
    }

    object mapping each node to its shortest distance from start

    • [key: string]: number
  • Finds the shortest path between two nodes using Dijkstra's algorithm

    Parameters

    • graph: WeightedGraph

      weighted graph as adjacency list

    • start: string

      starting node

    • end: string

      ending node

    Returns null | PathResult

    object containing the shortest path and its distance, or null if no path exists

Generated using TypeDoc