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:

57519175624279236348
985648111582016573
3273769492544594795
918271249768578382
758837606905468095
736989881655487314
67364590502113916877
55536552734997788131
60882081331643819516
33173362879192118949

Subtract row minima

We subtract the row minimum from each row:

3428685239195604025(-23)
95261788551713540(-3)
2869729088500554391(-4)
84120542061507675(-7)
708332551850417590(-5)
0292828194841667(-7)
542332773780785564(-13)
2422342142186647500(-31)
44724651702765790(-16)
226225176808107838(-11)

Subtract column minima

We subtract the column minimum from each column:

342766473819560025
95159737551713140
286870858750055391
84018041061503675
708230500850413590
0280778094841267
542230723680781564
2421321641186647100
44712601602765390
225204675808103838
(-1)(-2)(-5)(-1)(-40)

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

342766473819560025  x
95159737551713140
286870858750055391
84018041061503675  x
708230500850413590  x
0280778094841267  x
542230723680781564
2421321641186647100
44712601602765390  x
225204675808103838  x
xx

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:

342766473819570026
94058726541712130
276769848649054291
84018041062503676
708230500851413591
0280778094941268
532129713570771464
232031154017664690
44712601602865391
225204675808203839

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

342766473819570026  x
94058726541712130  x
276769848649054291
84018041062503676  x
708230500851413591  x
0280778094941268  x
532129713570771464
232031154017664690  x
44712601602865391  x
225204675808203839  x
x

Create additional zeros

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

342766473819590026
94058726541912130
256567828447052089
84018041064503676
708230500853413591
0280778095141268
511927693350751262
232031154017684690
44712601603065391
225204675808403839

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

342766473819590026
94058726541912130  x
256567828447052089
84018041064503676  x
708230500853413591  x
0280778095141268  x
511927693350751262
232031154017684690  x
44712601603065391  x
225204675808403839
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:

292261423314590021
94058726542417180
206062777942052084
84018041069554176
708230500858464091
0280778095646318
461422642800751257
2320311540177351140
44712601603570441
170154170758403834

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

292261423314590021
94058726542417180
206062777942052084
84018041069554176  x
708230500858464091  x
0280778095646318  x
461422642800751257
2320311540177351140
44712601603570441
170154170758403834
xxxxxx

Create additional zeros

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

272259403114590021
92056704542417180
186060757742052084
84218041271574378
7084305008710484293
030077801158483310
441420622600751257
2120291338177351140
42710581403570441
150133968758403834

Cover all zeros with a minimum number of lines

There are 10 lines required to cover all zeros:

272259403114590021  x
92056704542417180  x
186060757742052084  x
84218041271574378  x
7084305008710484293  x
030077801158483310  x
441420622600751257  x
2120291338177351140  x
42710581403570441  x
150133968758403834  x

The optimal assignment

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

272259403114590021
92056704542417180
186060757742052084
84218041271574378
7084305008710484293
030077801158483310
441420622600751257
2120291338177351140
42710581403570441
150133968758403834

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

57519175624279236348
985648111582016573
3273769492544594795
918271249768578382
758837606905468095
736989881655487314
67364590502113916877
55536552734997788131
60882081331643819516
33173362879192118949

The optimal value equals 180.