def CreateGraph():
B = nx.DiGraph();
f = open('input.txt')
n = int(f.readline())
cost = []
for i in range(n):
list1 = map(int, (f.readline()).split())
cost.append(list1)
people = []
for i in range(n):
people.append(i)
job = []
for c in ascii_lowercase[:n]:
job.append(c)
B.add_nodes_from(people, bipartite=0) # Add the node attribute "bipartite"
B.add_nodes_from(job, bipartite=1)
for i in range(n) :
for c in ascii_lowercase[:n] :
if cost[i][ord(c)-97] > 0 :
B.add_edge(i, c, length = cost[i][ord(c)-97])
return B,cost
assignment_prob_hungarian.py 文件源码
python
阅读 74
收藏 0
点赞 0
评论 0
评论列表
文章目录