以下の内容はhttps://anton0825.hatenablog.com/entry/20110121/1295968769より取得しました。


プログラミングコンテストチャレンジブック演習「ワーシャルフロイド法」

今回のお題はこちら。

$costに各頂点間のコストをいれれば全点対最短路が計算できます。
実装が簡単なのがいいですな。

V = 10 #input
$cost[V][V] #input

def warshall_floyd
  for k in 0..(V - 1)
    for i in 0..(V - 1)
      for j in 0..(V - 1)
        $cost[i][j] = [$cost[i][j], $cost[i][k] + $cost[k][j]].min
      end
    end
  end
end

puts $cost



以上の内容はhttps://anton0825.hatenablog.com/entry/20110121/1295968769より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14