单选题:Why doesn't Floyd algorithm work if there are negative-cost cycl
Why doesn't Floyd algorithm work if there are negative-cost cycles?
A.Because Floyd didn't like negative numbers.
B.Because Floyd algorithm will terminate after finite steps, yet the shortest distance is negative infinity if there is a negative-cost cycle.
C.Because Floyd algorithm will fall into infinite loops.
D.Because a negative-cost cycle will result in a negative D[i][i], yet Floyd algorithm can only accept positive weights.
答案:B
A.Because Floyd didn't like negative numbers.
B.Because Floyd algorithm will terminate after finite steps, yet the shortest distance is negative infinity if there is a negative-cost cycle.
C.Because Floyd algorithm will fall into infinite loops.
D.Because a negative-cost cycle will result in a negative D[i][i], yet Floyd algorithm can only accept positive weights.
答案:B