Created
February 19, 2016 18:50
-
-
Save RobertTalbert/99e176d7ea40e77bfe05 to your computer and use it in GitHub Desktop.
SageMath implementation of Warshall's algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def warshall(M): | |
n = M.nrows() | |
W = M | |
for k in range(n): | |
for i in range(n): | |
for j in range(n): | |
W[i,j] = W[i,j] or (W[i,k] and W[k,j]) | |
return W |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is the only iteration gives the final result or should I have to repeat this process?