題目
思路:
- 要找的點是可到達的點的距離在 threshold 裡的那些點,所以要找的是最短距離,因為只要最短距離可以在 threshold 內,那它就是可到達的點
- 用 Floyd-Warshall’s algorithm 找到所有點之間的最小距離
k是i到j之間的任意點。比較i->j經過所有k的距離,最小的即為i->j的最短距離。- Question:
if the path isi -> 2 -> 1 -> jand the iteration considerk == 1first. But thedist[i][1]not yet populated and still have value offloat('inf'). It will have the actual value untilk == 2.