请输入您要查询的字词:

 

单词 FloydsAlgorithm
释义

Floyd’s algorithm


Floyd’s algorithmMathworldPlanetmath is also known as the all pairs shortest path algorithm. It will compute the shortest path between all possible pairs of vertices in a (possibly weighted) graph or digraphMathworldPlanetmath simultaneously in O(n3) time (where n is the number of vertices in the graph).

Algorithm Floyd(V)
Input: A weighted graph or digraph with vertices V
Output: A matrix cost of shortest paths and a matrix pred of predecessors in the shortest path

for (a,b)V2 do
         if adjacent(a,b) then

cost(a,b)weight(a,b)

pred(a,b)aelse

cost(a,b)

pred(a,b)null

for cV do
         for (a,b)V2 do

if cost(a,c)< and cost(c,b)< then

if cost(a,b)= or cost(a,c)+cost(c,b)<cost(a,b) then

cost(a,b)cost(a,c)+cost(c,b)

pred(a,b)pred(c,b)

随便看

 

数学辞典收录了18232条数学词条,基本涵盖了常用数学知识及数学英语单词词组的翻译及用法,是数学学习的有利工具。

 

Copyright © 2000-2023 Newdu.com.com All Rights Reserved
更新时间:2025/5/4 14:45:10