HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Computing the Maximum in an MxM Matrix

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
themaximummxmmatrixcomputing

Problem

I have an MxN matrix where each element contains a positive numeric value.

I need to find those elements in the matrix that add up to the "maximum value". The caveat is that each row and column can be used at most once in calculating the total.

I have a brute force algorithm for doing this bit it's ugly. I was wondering if there is a well-known algorithm for accomplishing this.

Solution

Your problem is known as maximum weighted bipartite matching or the assignment problem, and has efficient algorithms such as the Hungarian algorithm.

Context

StackExchange Computer Science Q#56998, answer score: 7

Revisions (0)

No revisions yet.