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:

686056787068554981
524683559581259020
108172123872621647
3285513174148891
40213051571316650
65643824372370321
914320417963349520
95097194819579978
94959594262879776

Subtract row minima

We subtract the row minimum from each row:

191172921196032(-49)
3226633575615700(-20)
071622286252637(-10)
288119133708487(-4)
3415244551710044(-6)
62613521342067018(-3)
7123021594314750(-20)
04188103910489069(-9)
85868603353788867(-9)

Subtract column minima

We subtract the column minimum from each column:

1907298126032
3215633562545700
060622155552637
28701903008487
344244538010044
62503521211367018
7112021463614750
0308810263489069
85758602046788867
(-11)(-13)(-7)

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

1907298126032  x
3215633562545700  x
060622155552637
28701903008487  x
344244538010044  x
62503521211367018  x
7112021463614750  x
0308810263489069
85758602046788867  x
x

Create additional zeros

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

2107298126032
3415633562545700
058600135350435
30701903008487
364244538010044
64503521211367018
7312021463614750
028868241468867
87758602046788867

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

2107298126032  x
3415633562545700  x
058600135350435
30701903008487  x
364244538010044  x
64503521211367018  x
7312021463614750  x
028868241468867
87758602046788867
xx

Create additional zeros

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

2207308126032
3515633662545700
057590125249334
317011003008487
374244638010044
65503522211367018
7412022463614750
027858230458766
87748501945778766

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

2207308126032  x
3515633662545700  x
057590125249334
317011003008487  x
374244638010044
65503522211367018
7412022463614750  x
027858230458766
87748501945778766
xxxx

Create additional zeros

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

2607348166432
3915634062585740
05355085245330
357011403408887
37020463406040
65463122171363014
7812026464014790
023818190418762
87708101545738762

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

2607348166432
3915634062585740  x
05355085245330
357011403408887  x
37020463406040
65463122171363014
7812026464014790  x
023818190418762
87708101545738762
xxxxx

Create additional zeros

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

2601342160426
4521634662645800
05349025239324
417612004009487
37014462800034
6546252211135708
8418032464614850
023758130358756
8770750945678756

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

2601342160426  x
4521634662645800  x
05349025239324  x
417612004009487  x
37014462800034  x
6546252211135708  x
8418032464614850  x
023758130358756  x
8770750945678756  x

The optimal assignment

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

2601342160426
4521634662645800
05349025239324
417612004009487
37014462800034
6546252211135708
8418032464614850
023758130358756
8770750945678756

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

686056787068554981
524683559581259020
108172123872621647
3285513174148891
40213051571316650
65643824372370321
914320417963349520
95097194819579978
94959594262879776

The optimal value equals 174.