Guest User

Floyd algorithm, in function, time = 5 sec

a guest
Aug 20th, 2012
1,305
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2. random.seed(179)
  3.  
  4. def f(A, N):
  5.     for k in range(N):
  6.         for i in range(N):
  7.             for j in range(N):
  8.                 A[i][j] = min(A[i][j], A[i][k] + A[k][j])
  9.  
  10. N = 200
  11. f([ [random.randint(1, 10000) for i in range(N)] for j in range(N)], N)
RAW Paste Data