I was testing your code on randomly generated complete bipartite graphs and got the following error which seemed to be thrown by line 352 in algorithm.py.
AttributeError: 'bool' object has no attribute 'vertices'
After doing some debugging, this seems to be do to the fact that a bool is put into the matching M around lines 472-473.
I used the following code to generate the instance which causes the issue:
import random
from algorithm import *
# n is the number of vertices on each side
# returns a dict of dicts giving the neighborhoods of the LHS with their weights
# weights are integers chosen uniformly at random in [min_weight,max_weight]
def random_complete_bipartite(n,min_weight,max_weight):
# the vertex names are 0 -> n-1 for the LHS and n -> 2n-1 for the RHS
lhs = list(range(n))
rhs = list(range(n,2*n))
G = {}
for v in lhs:
G[v] = {}
for w in rhs:
# choose the weight randomly
weight = random.randrange(min_weight,max_weight+1)
G[v][w] = weight
return G
random.seed(500)
n = 50
min_w = 0
max_w = 100
G = random_complete_bipartite(n,min_w,max_w)
print(find_matching(G,matching_type='max', return_type='total')
Note that it seems to work fine on smaller examples with around 10-20 nodes. I discovered the issue when I started to increase the number of nodes. Let me know if you have any questions.
Thanks,
Thomas
PS: if there are any issues with random generation the test instance that I get from running the code above is here:
Hi!
I was testing your code on randomly generated complete bipartite graphs and got the following error which seemed to be thrown by line 352 in algorithm.py.
After doing some debugging, this seems to be do to the fact that a
bool
is put into the matchingM
around lines 472-473.I used the following code to generate the instance which causes the issue:
Note that it seems to work fine on smaller examples with around 10-20 nodes. I discovered the issue when I started to increase the number of nodes. Let me know if you have any questions.
Thanks, Thomas
PS: if there are any issues with random generation the test instance that I get from running the code above is here: