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:

22717541285794883558
80542159276618525393
5215971577163923985
8158615343687715076
44407731458715203861
28805676463124288620
70845576824765216730
7218704316445967861
8219208661476413826
81131770228949405

Subtract row minima

We subtract the row minimum from each row:

049531963572661336(-22)
62363419480343575(-18)
0165466526658873480(-5)
7552554737081654470(-6)
292562163072052346(-15)
8603656261148660(-20)
496334556126440469(-21)
6713653811390917356(-5)
7613148055410353220(-6)
5801467198646372(-3)

Subtract column minima

We subtract the column minimum from each column:

0415350357266036
62283273480342275
085452466658872180
7544553331081653170
29176222472051046
8523642201148530
495534415526440339
67565245390916056
765146649410351920
500061198646242
(-8)(-14)(-6)(-13)

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

0415350357266036  x
62283273480342275
085452466658872180  x
7544553331081653170  x
29176222472051046
8523642201148530  x
495534415526440339  x
67565245390916056
765146649410351920
500061198646242  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:

0415350357466036
60261251460322073
085452466660872180
7544553331083653170
2715600227003844
8523642201168530
495534415526460339
65363223370895854
743126447390331718
500061198846242

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

0415350357466036  x
60261251460322073
085452466660872180  x
7544553331083653170  x
2715600227003844  x
8523642201168530  x
495534415526460339  x
65363223370895854
743126447390331718
500061198846242  x
x

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:

0415350357566036
59250240450311972
085452466661872180
7544553331084653170
2715600227013844
8523642201178530
495534415526470339
64262212360885753
732116346380321617
500061198946242

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

0415350357566036  x
59250240450311972  x
085452466661872180  x
7544553331084653170  x
2715600227013844  x
8523642201178530  x
495534415526470339  x
64262212360885753
732116346380321617
500061198946242  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:

0415350357766036
59250240452311972
085452466663872180
7544553331086653170
2715600227033844
8523642201198530
495534415526490339
62060190340865551
71096144360301415
500061199146242

Cover all zeros with a minimum number of lines

There are 10 lines required to cover all zeros:

0415350357766036  x
59250240452311972  x
085452466663872180  x
7544553331086653170  x
2715600227033844  x
8523642201198530  x
495534415526490339  x
62060190340865551  x
71096144360301415  x
500061199146242  x

The optimal assignment

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

0415350357766036
59250240452311972
085452466663872180
7544553331086653170
2715600227033844
8523642201198530
495534415526490339
62060190340865551
71096144360301415
500061199146242

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

22717541285794883558
80542159276618525393
5215971577163923985
8158615343687715076
44407731458715203861
28805676463124288620
70845576824765216730
7218704316445967861
8219208661476413826
81131770228949405

The optimal value equals 172.