distance To
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
Illegal State Exception
If neither BFS nor Dijkstra has been executed yet.