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:

13682310445334
32568365331999
6901739604714
24416411683918
13512618324449
7315183877246
2612397650386

Subtract row minima

We subtract the row minimum from each row:

358130344324(-10)
1337644614080(-19)
084113354418(-6)
133053057287(-11)
038135193136(-13)
668113106539(-7)
206337044320(-6)

Subtract column minima

We subtract the column minimum from each column:

35220344324
1331534614080
07803354418
132442057287
03225193136
66203106539
200227044320
(-6)(-11)

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

35220344324
1331534614080  x
07803354418  x
132442057287
03225193136  x
66203106539  x
200227044320  x
x

Create additional zeros

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

15000324122
1331534814080
07803554418
112240055265
03227193136
66203306539
200227244320

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

15000324122
1331534814080  x
07803554418
112240055265
03227193136
66203306539  x
200227244320  x
xxx

Create additional zeros

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

14500273617
1831585314080
07303549363
111740050210
02727142631
71253806539
250277744320

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

14500273617  x
1831585314080  x
07303549363  x
111740050210  x
02727142631  x
71253806539  x
250277744320  x

The optimal assignment

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

14500273617
1831585314080
07303549363
111740050210
02727142631
71253806539
250277744320

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

13682310445334
32568365331999
6901739604714
24416411683918
13512618324449
7315183877246
2612397650386

The optimal value equals 96.