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

This is the original cost matrix:

3 | 77 | 53 | 47 |

63 | 88 | 35 | 27 |

87 | 63 | 21 | 30 |

98 | 9 | 13 | 43 |

**Subtract row minima**

We subtract the row minimum from each row:

0 | 74 | 50 | 44 | (-3) |

36 | 61 | 8 | 0 | (-27) |

66 | 42 | 0 | 9 | (-21) |

89 | 0 | 4 | 34 | (-9) |

**Subtract column minima**

Because each column contains a zero, subtracting column minima has no effect.

**Cover all zeros with a minimum number of lines**

There are 4 lines required to cover all zeros:

0 | 74 | 50 | 44 | x |

36 | 61 | 8 | 0 | x |

66 | 42 | 0 | 9 | x |

89 | 0 | 4 | 34 | x |

**The optimal assignment**

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

0 | 74 | 50 | 44 |

36 | 61 | 8 | 0 |

66 | 42 | 0 | 9 |

89 | 0 | 4 | 34 |

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

3 | 77 | 53 | 47 |

63 | 88 | 35 | 27 |

87 | 63 | 21 | 30 |

98 | 9 | 13 | 43 |

The optimal value equals 60.

HungarianAlgorithm.com © 2013-2017