Skip to content

shortest-path ​

Guide: /api/algorithms/graph/shortest-path

Signature ​

ts
shortestPath(graph, from, to, strategy);

Params: ​

NameTypeRequiredDefaultDescription
graphIGraph<T>+Given graph
fromT+Start of path
toT+End of path
strategyIGraphIterationStrategy<T>+BFS/Dijkstra

Returns: ​

Array<T> ​


Throws: ​

IsNotFoundException when start vertex does not exist ​

IsNotFoundException when end vertex does not exist ​

IllegalStateException when there is no path at all between two vertices ​

MIT Licensed