profile
viewpoint

Ask questionsNegative cost not accepted

I'm new to this and am trying to understand how to use this wrapper. I'm trying to run the examples from the c++ blossom5 algorithm, one of which is the graph in GRAPH1.TXT

6 9
0 1 3
0 3 10
0 4 7
1 2 -1
1 4 5
1 5 4
2 5 -7
3 4 0
4 5 4

Running this with the c++ version as ./blossim5 -e GRAPH1.TXT returns

perfect matching with 6 nodes and 9 edges
    starting init...done [0.000 secs]. 0 trees
    .
done [0.000 secs]. 0 grows, 0 expands, 0 shrinks
    expands: [0.000 secs], shrinks: [0.000 secs], dual updates: [0.000 secs]
cost = -4.0

So what I have in Julia is

using BlossomV

differences = [
	0 1 3
	0 3 10
	0 4 7
	1 2 -1
	1 4 5
	1 5 4
	2 5 -7
	3 4 0
	4 5 4
]

m = Matching(6)
for row in 1:size(differences,1)
	vertex1, vertex2, weight = differences[row,:]
	add_edge(m, vertex1, vertex2, weight)
end

solve(m)
for i in 1:6
	get_match(m,i)
end

But I get the error

ERROR: LoadError: Cost must be positive. Edge between 1 and 2 has cost -1.

Is this by design? Seems that a wrapper should perform exactly what the original one performs. Let me know if I'm missing something. Thanks!

mlewe/BlossomV.jl

Answer questions Bebotron

Sounds good, I'll go ahead and close this with the pending pull request https://github.com/mlewe/BlossomV.jl/pull/18.

useful!

Related questions

No questions were found.
source:https://uonfu.com/
Github User Rank List