I am trying to implement hungarian algorithm in my project, but I don't understand why it gives a endless loop...I have tried with an other bibartite graph and it works. So I want to know what's wrong with my graph G
from hungarian_algorithm import algorithm
G={
'agt2': {'Commentaire':200,'PhotoProfil': 8, 'PhotoSupp': 10, 'Prenom': 0},
'coco': {'Commentaire': 300, 'PhotoProfil': 200, 'PhotoSupp': 300, 'Prenom': 300}
}
res=algorithm.find_matching(G,matching_type='max',return_type='list')
print(res)
The graph is fine, it's probably a bug in the implementation of that package. As pointed out in my comment you can use
scipy.optimize.linear_sum_assignment
from SciPy instead.For example
prints