distanceTo

fun distanceTo(node: T): Double

Retrieves the distance to the specified node from the starting node of the most recent search operation (BFS, Dijkstra).

If the graph is weighted, the weighted distance is returned. If the graph is unweighted, the distance is calculated as the number of edges.

Return

The distance to the specified node.

Parameters

node

The target node whose distance is to be retrieved.

Throws

IllegalStateException

If neither BFS nor Dijkstra has been executed yet.