Maximum_weight_matching changes the symmetry of the original weight matrix?

I noticed that the maximum_weight_matching function seems to alter the weight matrix utilized in the matching. When I try to use the original graph in future calculations, I’m getting errors because its adjacency matrix is apparently no longer symmetric. In the following example code, the first “issymetric” function returns true and the second returns false.

sources = [1:5;1:5]
destinations = rand(1:5,10)
weights = rand(1:10,10)
fake_graph = SimpleWeightedGraph(sources,destinations,weights)
match = maximum_weight_matching(SimpleGraph(fake_graph),Gurobi.Optimizer,fake_graph.weights)

Is there a way to use the maximum_weight_matching function without altering the original graph? The alternative I can think of is to make a copy of the original graph before the matching.

Hi @OliviaPhillips!
Indeed it’s a very annoying behavior, thanks for spotting it. It is probably due to GraphsMatching.jl/maximum_weight_matching.jl at 7d14c0b345eb701f86ff20236e26a8a050994932 · JuliaGraphs/GraphsMatching.jl · GitHub
As a quick fix, I would suggest making a copy of the weights matrix before passing it to the function. In the long run, GraphsMatching.jl will be replaced by GitHub - gdalle/GraphsOptim.jl: A package for graph-related optimization algorithms that rely on Linear Programming., but I need to find some time to get it up and running

Copying the weights first works great for now, thanks so much!