Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while q:
- now = q[0]
- q.popleft()
- for i in range(0, (len(matrix[now]))):
- if (matrix[now][i] != 0):
- if used[i] == 0 or used[i] > used[now] + matrix[now][i]:
- q.append(i)
- used[i] = used[now] + matrix[now][i]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement