给出邻接矩阵,例如:
if __name__ == "__main__":
matsize = 5 mat = [matsize * [math.inf] for i in range(matsize)]
mat[0][0] = 0
mat[0][1] = 2
mat[0][2] = 10
mat[1][1] = 0
mat[1][2] = 3
mat[1][3] = 12
mat[2][0] = 10
mat[2][1] = 3
mat[2][2] = 0
mat[2][4] = 1
mat[3][1] = 12
mat[3][3] = 0
mat[4][2] = 1
mat[4][3] = 1
mat[4][4] = 0
,并且必须将其转换为双矩阵:
def createBiMatrix(mat):
...
bimatrix = []
return bimatrix
这是关于floyd algotihm的,到目前为止我还是了解的,但是要完成练习的第二部分似乎更容易,我需要将其转换。
def createBiMatrix(mat):
"""it expects an adjacency matrix and returns a Bi-Matrix"""
bimatrix = []
pass
return bimatrix
如果有人给我一些小费,我会很感激