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:

5295473419765577271
44847960604342604433
77652958118997336019
97813835489786525544
56936011178356553153
57369568165929441717
1329435948649684410
65819182837593489778
9080239841804584541
9730312263798059012

Subtract row minima

We subtract the row minimum from each row:

5194463318755476260(-1)
115146272710927110(-33)
665418470788622498(-11)
62463013625117209(-35)
458249067245442042(-11)
41207952043132811(-16)
42034503955059351(-9)
1733433435274504930(-48)
8272159033723703733(-8)
922526175874750857(-5)

Subtract column minima

We subtract the column minimum from each column:

4774433318655476250
7314327270927100
623415470688622488
58260013525117199
416246066245441942
3707652033132801
0031503945059341
1313403435174504830
7852129033623703633
88523175864750847
(-4)(-20)(-3)(-10)(-1)

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

4774433318655476250  x
7314327270927100  x
623415470688622488  x
58260013525117199  x
416246066245441942  x
3707652033132801  x
0031503945059341  x
1313403435174504830
7852129033623703633
88523175864750847
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:

4774433318655481250
7314327270932100
623415470688627488
58260013525122199
416246066245491942
3707652033133301
0031503945064341
88352930124004325
734778528573203128
83018125359700792

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

4774433318655481250  x
7314327270932100  x
623415470688627488  x
58260013525122199  x
416246066245491942  x
3707652033133301  x
0031503945064341  x
88352930124004325
734778528573203128
83018125359700792  x
x

Create additional zeros

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

4774433318655488250
7314327270939100
623415470688634488
58260013525129199
416246066245561942
3707652033134001
0031503945071341
1128222353303618
664007821502502421
83018125359707792

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

4774433318655488250  x
7314327270939100  x
623415470688634488  x
58260013525129199
416246066245561942
3707652033134001  x
0031503945071341  x
1128222353303618
664007821502502421
83018125359707792  x
xxx

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:

4774443418655489250
7314428270940100
623416480688635488
57250012515029188
406146056144561841
3707753033134101
0032513945072341
0028222243203517
653907820492402320
83019135359708792

Cover all zeros with a minimum number of lines

There are 10 lines required to cover all zeros:

4774443418655489250  x
7314428270940100  x
623416480688635488  x
57250012515029188  x
406146056144561841  x
3707753033134101  x
0032513945072341  x
0028222243203517  x
653907820492402320  x
83019135359708792  x

The optimal assignment

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

4774443418655489250
7314428270940100
623416480688635488
57250012515029188
406146056144561841
3707753033134101
0032513945072341
0028222243203517
653907820492402320
83019135359708792

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

5295473419765577271
44847960604342604433
77652958118997336019
97813835489786525544
56936011178356553153
57369568165929441717
1329435948649684410
65819182837593489778
9080239841804584541
9730312263798059012

The optimal value equals 233.