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:

2540633127378591817
29102968949056781696
50284539115870848582
682448132727962399
7664058263328905634
7016213756277531768
979803146407825639
8551161349174543212
724780894943948781
2918974326819747488

Subtract row minima

We subtract the row minimum from each row:

173255231929051109(-8)
190195884804668686(-10)
3917342804759737471(-11)
660427930705942197(-2)
7003452202722845028(-6)
6814193554075511566(-2)
777782944387605437(-2)
8349141147154341190(-2)
714679884833847770(-1)
2808873316718737387(-1)

Subtract column minima

We subtract the column minimum from each column:

10324112192905149
12054784804668086
3217201704759736871
590286830705941597
6302041202722844428
61145245407551966
077641844387604837
76490047154341130
644665774833847710
2107462316718736787
(-7)(-14)(-11)(-6)

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

10324112192905149  x
12054784804668086  x
3217201704759736871  x
590286830705941597
6302041202722844428
61145245407551966  x
077641844387604837  x
76490047154341130  x
644665774833847710  x
2107462316718736787
x

Create additional zeros

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

10374112192905149
12554784804668086
3222201704759736871
540236325650891092
5801536152217793923
61195245407551966
082641844387604837
76540047154341130
645165774833847710
1606957266213686282

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

10374112192905149
12554784804668086  x
3222201704759736871  x
540236325650891092
5801536152217793923
61195245407551966  x
082641844387604837  x
76540047154341130  x
645165774833847710  x
1606957266213686282
xx

Create additional zeros

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

637378152504705
12954784805068086
3226201704763736871
50019592161085688
5401132111817753519
61235245407951966
086641844388004837
76580047154741130
645565774834247710
1206553225813645878

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

637378152504705
12954784805068086
3226201704763736871  x
50019592161085688
5401132111817753519
61235245407951966  x
086641844388004837  x
76580047154741130  x
645565774834247710  x
1206553225813645878
xxx

Create additional zeros

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

137323102004200
7904279755063081
3231201704768737371
45014541656080683
49062761317703514
612852454084511466
091641844388505337
76630047155241180
646065774834747760
706048175313595873

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

137323102004200  x
7904279755063081  x
3231201704768737371  x
45014541656080683  x
49062761317703514
612852454084511466  x
091641844388505337  x
76630047155241180  x
646065774834747760  x
706048175313595873
x

Create additional zeros

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

143323102004200
71504279755063081
3237201704768737371
45614541656080683
430021071164298
613452454084511466
097641844388505337
76690047155241180
646665774834747760
10544211477535267

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

143323102004200
71504279755063081
3237201704768737371
45614541656080683
430021071164298
613452454084511466  x
097641844388505337  x
76690047155241180  x
646665774834747760
10544211477535267
xxxxxx

Create additional zeros

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

043322101904100
61504179745062081
3137201604668727371
44614531655079683
420020061163298
613562455085511567
098651845388605438
76701048155341191
636665764824746760
00544111467525267

Cover all zeros with a minimum number of lines

There are 10 lines required to cover all zeros:

043322101904100  x
61504179745062081  x
3137201604668727371  x
44614531655079683  x
420020061163298  x
613562455085511567  x
098651845388605438  x
76701048155341191  x
636665764824746760  x
00544111467525267  x

The optimal assignment

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

043322101904100
61504179745062081
3137201604668727371
44614531655079683
420020061163298
613562455085511567
098651845388605438
76701048155341191
636665764824746760
00544111467525267

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

2540633127378591817
29102968949056781696
50284539115870848582
682448132727962399
7664058263328905634
7016213756277531768
979803146407825639
8551161349174543212
724780894943948781
2918974326819747488

The optimal value equals 118.