How to Use the Hungarian Algorithm

Arrange your information in a matrix with the "people" on the left and the "activity" along the top, with the "cost" for each pair in the middle. , Ensure that the matrix is square by the addition of dummy rows/columns if necessary., Reduce the rows...

13 Steps 1 min read Medium

Step-by-Step Guide

  1. Step 1: Arrange your information in a matrix with the "people" on the left and the "activity" along the top

    Conventionally, each element in the dummy row/column is the same as the largest number in the matrix.,,, (If the number of lines is equal to the number of rows then go to step 9), If an element is covered twice, add the minimum element to it twice.,, If the number of lines covering the zero elements is not equal to the number of rows, return to step
    6.,, This shows who should do which activity, and adding the costs will give the total minimum cost.
  2. Step 2: with the "cost" for each pair in the middle.

  3. Step 3: Ensure that the matrix is square by the addition of dummy rows/columns if necessary.

  4. Step 4: Reduce the rows by subtracting the minimum value of each row from that row.

  5. Step 5: If there are columns without a zero

  6. Step 6: reduce the columns by subtracting the minimum value of each column from that column.

  7. Step 7: Cover the zero elements with the minimum number of lines it is possible to cover them with.

  8. Step 8: Add the minimum uncovered element to every covered element.

  9. Step 9: Subtract the minimum element from every element in the matrix.

  10. Step 10: This example had to be reduced once more Cover the zero elements again.

  11. Step 11: Select a matching by choosing a set of zeros so that each row or column has only one selected.

  12. Step 12: Notice that D has not been used Apply the matching to the original matrix

  13. Step 13: disregarding dummy rows.

Detailed Guide

Conventionally, each element in the dummy row/column is the same as the largest number in the matrix.,,, (If the number of lines is equal to the number of rows then go to step 9), If an element is covered twice, add the minimum element to it twice.,, If the number of lines covering the zero elements is not equal to the number of rows, return to step
6.,, This shows who should do which activity, and adding the costs will give the total minimum cost.

About the Author

J

Julie Simmons

Writer and educator with a focus on practical crafts knowledge.

37 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: