assignment_prob_hungarian.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:Visualization-of-popular-algorithms-in-Python 作者: MUSoC 项目源码 文件源码
def hungarian(B ,pos ,cost):
    n = len(cost)
    ret = 0; 
    max_match = 0 
    xy = [-1] * n
    yx = [-1] * n
    slack = [0] * n
    slackx = [0] * n
    lx, ly = init_labels(cost)
    augment(cost, max_match, xy, yx, lx, ly, slack, slackx)
    for x in range(n):
        if (x, chr(xy[x]+97)) in B.edges():
            nx.draw_networkx_edges(B, pos, edgelist = [(x, chr(xy[x]+97))], width = 2.5, alpha = 0.6, edge_color = 'r')



#takes input from the file and creates a weighted bipartite graph
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号