def CreateGraph():
G = nx.Graph()
f = open('input.txt')
n = int(f.readline())
wtMatrix = []
for i in range(n):
list1 = map(int, (f.readline()).split())
wtMatrix.append(list1)
# Adds egdes along with their weights to the graph
for i in range(n) :
for j in range(n)[i:] :
if wtMatrix[i][j] > 0 :
G.add_edge(i, j, length = wtMatrix[i][j])
return G
# draws the graph and displays the weights on the edges
kruskals_quick_union.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录