📜  warshall 算法传递闭包计算器 - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:09.585000             🧑  作者: Mango

代码示例1
def transitiveClosure (matrix):
    result = ""
    length = len(matrix)
    for k in range(0, length):
        for row in range(0, length):
            for col in range(0, length):
                matrix[row] [col] = matrix[row][col] or (matrix[row][k] and matrix[k][col])
        result += ("\n W" + str(k) +" is: \n" + str(matrix).replace("]," , "] \n") + "\n")
    result += ("\n Transitive closure is \n" + str(matrix).replace("]," , "]\n"))
    print result
    return result