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):

Size: 3x3 4x4 5x5 6x6 7x7 8x8 9x9 10x10

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

This is the original cost matrix:

51174075070
12268521639
93119310414
4977472191
15832753672
918444356347

Subtract row minima

We subtract the row minimum from each row:

44103304363(-7)
10248301437(-2)
897896370(-4)
4876371090(-1)
05731743571(-1)
5649902812(-35)

Subtract column minima

We subtract the column minimum from each column:

4433004363
10178001437
890866370
4869071090
05028743571
5642602812
(-7)(-3)

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

4433004363
10178001437
890866370  x
4869071090  x
05028743571  x
5642602812
x

Create additional zeros

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

4102704060
7147701134
890869370
4869074090
05028773571
533930259

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

4102704060  x
7147701134
890869370  x
4869074090  x
05028773571  x
533930259
x

Create additional zeros

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

4102734060
411740831
8908612370
4869077090
05028803571
503600226

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

4102734060  x
411740831  x
8908612370  x
4869077090  x
05028803571  x
503600226  x

The optimal assignment

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

4102734060
411740831
8908612370
4869077090
05028803571
503600226

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

51174075070
12268521639
93119310414
4977472191
15832753672
918444356347

The optimal value equals 69.