# Solve an assignment problem online

Fill in the cost matrix of an assignment problem and click on 'Solve'. The optimal assignment will be determined and a step by step explanation of the hungarian algorithm will be given.

Fill in the cost matrix (random cost matrix):

Don't show the steps of the Hungarian algorithm
Maximize the total cost

This is the original cost matrix:

 13 68 67 94 90 89 51 9 5 87 39 39 12 18 4 48

Subtract row minima

We subtract the row minimum from each row:

 0 55 54 81 (-13) 81 80 42 0 (-9) 0 82 34 34 (-5) 8 14 0 44 (-4)

Subtract column minima

We subtract the column minimum from each column:

 0 41 54 81 81 66 42 0 0 68 34 34 8 0 0 44 (-14)

Cover all zeros with a minimum number of lines

There are 3 lines required to cover all zeros:

 0 41 54 81 81 66 42 0 x 0 68 34 34 8 0 0 44 x x

The number of lines is smaller than 4. The smallest uncovered number is 34. We subtract this number from all uncovered elements and add it to all elements that are covered twice:

 0 7 20 47 115 66 42 0 0 34 0 0 42 0 0 44

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

 0 7 20 47 x 115 66 42 0 x 0 34 0 0 x 42 0 0 44 x

The optimal assignment

Because there are 4 lines required, the zeros cover an optimal assignment:

 0 7 20 47 115 66 42 0 0 34 0 0 42 0 0 44

This corresponds to the following optimal assignment in the original cost matrix:

 13 68 67 94 90 89 51 9 5 87 39 39 12 18 4 48

The optimal value equals 79.