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:

93116235437054579065
4575537041773724714
46825439595875887162
498915952067265810
4047654179441793615
1217803983993781281
741742102037776946
167818374960759317
86599719593496461972
5125991386661625947

Subtract row minima

We subtract the row minimum from each row:

8205124325943467954(-11)
4272506738740694411(-3)
743150201936493223(-39)
09487551166322546(-4)
31385632703580276(-9)
91477095369075978(-3)
71143971707473643(-3)
97111304253052240(-7)
674078040157727053(-19)
451993780055565341(-6)

Subtract column minima

We subtract the column minimum from each column:

8204024315943467954
4272396737740694411
74340191936493223
09476550166322546
31384532693580276
91466094369075978
71142871607473643
9710304153052240
674067039157727053
451982779055565341
(-11)(-1)

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

8204024315943467954  x
4272396737740694411  x
74340191936493223
09476550166322546  x
31384532693580276  x
91466094369075978
71142871607473643
9710304153052240  x
674067039157727053  x
451982779055565341
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:

8204028316343467954
4272397137780694411
33900151932452819
09476590206322546
31384536693980276
51062090368671574
67102471207069239
9710344157052240
674067439197727053
411578775051524937

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

8204028316343467954  x
4272397137780694411  x
33900151932452819  x
09476590206322546  x
31384536693980276  x
51062090368671574  x
67102471207069239
9710344157052240  x
674067439197727053  x
411578775051524937
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:

8204028316543467954
4272397137800694411
33900152132452819
09476590226322546
31384536694180276
51062090388671574
6582251006867037
9710344159052240
674067439217727053
391376573049504735

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

8204028316543467954  x
4272397137800694411  x
33900152132452819  x
09476590226322546  x
31384536694180276  x
51062090388671574  x
6582251006867037
9710344159052240  x
674067439217727053
391376573049504735
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:

8204028316943468354
4272397137840694811
33900152532453219
09476590266322586
31384536694580316
51062090428671974
614181606463033
9710344163052280
633663035217323049
35972169045464731

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

8204028316943468354  x
4272397137840694811  x
33900152532453219  x
09476590266322586  x
31384536694580316  x
51062090428671974
614181606463033
9710344163052280  x
633663035217323049
35972169045464731
xxx

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:

8204032317343468754
4272397537880695211
33904152932453619
09476630306322626
31384540694980356
1658086428267970
570141206059029
9710384167052320
593259031216919045
31568165041424727

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

8204032317343468754
4272397537880695211  x
33904152932453619  x
09476630306322626  x
31384540694980356  x
1658086428267970
570141206059029
9710384167052320  x
593259031216919045
31568165041424727
xxxx

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:

8103932307342458753
4273397637890695311
34005153032453719
09576640316322636
31394541695080366
0657085428166969
560131105958028
9720394168052330
583258030216818044
30567164040414726

Cover all zeros with a minimum number of lines

There are 10 lines required to cover all zeros:

8103932307342458753  x
4273397637890695311  x
34005153032453719  x
09576640316322636  x
31394541695080366  x
0657085428166969  x
560131105958028  x
9720394168052330  x
583258030216818044  x
30567164040414726  x

The optimal assignment

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

8103932307342458753
4273397637890695311
34005153032453719
09576640316322636
31394541695080366
0657085428166969
560131105958028
9720394168052330
583258030216818044
30567164040414726

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

93116235437054579065
4575537041773724714
46825439595875887162
498915952067265810
4047654179441793615
1217803983993781281
741742102037776946
167818374960759317
86599719593496461972
5125991386661625947

The optimal value equals 135.