Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python warshall algorithm stackoverflow

def warshall(a):
    assert (len(row) == len(a) for row in a)
    n = len(a)
    for k in range(n):
        for i in range(n):
            for j in range(n):
                a[i][j] = a[i][j] or (a[i][k] and a[k][j])
    return a
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #warshall #algorithm #stackoverflow
ADD COMMENT
Topic
Name
2+4 =