Algorithms

Dijkstra’s Shortest Path

priorityq.algorithms.dijkstra.shortest_path(source, target, neighbour_func, storage_class=None)[source]

Return the shortest path from the source to target.

Parameters
source - The source node from which the path is to be calculated target - The target node to which the path is to be calculated neighbour_func - A function that when given a node, returns an iterator of tuples where each tuple is an edge to another node along with the weight of the edge.
Keyword Arguments
storage_class - The Storage class that is to be used for the priority queue
which stores the nodes prioritized by their distance from the source. Default: prioirityq.storage.binheap.Storage
Returns
A tuple that contains a map of distances for each node from the source along with a map of each node to its parent.