pH14 / graphmatch

Optimal bipartite graph matching algorithm gem for Ruby.
5 stars 5 forks source link

Does not match when vertices have the same value #2

Open d5h opened 9 years ago

d5h commented 9 years ago

Hi,

Thanks for writing graphmatch! It's a very nice Ruby gem for solving a useful problem.

I noticed an issue however where graphmatch does not return matches when vertices on either side of the bipartite graph have the same value. For example:

left = [1]
right = [1]
edges = {1 => {1 => 0}}
Graphmatch.match(left, right, edges, search = :min_cost)
=> {:source=>1}

Theoretically this makes sense. However, it's a common case in practice.

Another related case is when vertices on the same side of the graph have the same value:

left = [1, 2]
right = [3, 3]
edges = {1 => {3 => 0},
               2 => {3 => 1}}
Graphmatch.match(left, right, edges, search = :min_cost)
=> {1=>3}

Again, this makes sense because the library is identifying vertices by their value, rather than vertices having a value.

There are workarounds, but it would be nice if the issue was fixed or documented. I spent a fair amount of time just figuring out what was happening.

Again, thanks!

raghvendra1501 commented 4 years ago

Hi @d5h , had you find anywork around, I have the exact same scenario and I want the result set as

left = [1, 2]
right = [3, 3]
edges = {1 => {3 => 0},
               2 => {3 => 1}}
Graphmatch.match(left, right, edges, search = :min_cost)
=> {1=>3}
// I want it to be {1=>3, 2=>3}