Kumar-laxmi / Algorithms

A Repository for algorithms in C, C++, Python and Java
Apache License 2.0
315 stars 365 forks source link

Add of Hungarian algorithm #1520

Closed Aarsh30 closed 5 months ago

Aarsh30 commented 1 year ago

The Hungarian algorithm is a method used to solve the assignment problem, which involves finding the best assignment of a set of tasks to a set of agents.

Here's a simplified explanation of the algorithm:

  1. Create a matrix that represents the cost or benefit of assigning each task to each agent. Each row represents a task, and each column represents an agent. Fill in the matrix with the corresponding costs or benefits.
  2. Identify the smallest value in each row of the matrix and subtract that value from all the other values in the same row. Do the same for each column by identifying the smallest value and subtracting it from the other values in the column.
  3. Draw lines through the matrix to cover all zeros. Aim to cover as many zeros as possible using the minimum number of lines.
  4. If the number of lines drawn is equal to the number of rows or columns, the optimal solution is found. If not, proceed to the next step.
  5. Find the smallest uncovered value in the matrix. Subtract this value from all uncovered values, and add it to all values covered by two lines.
  6. Go back to step 3 and repeat until an optimal solution is found.
  7. Once an optimal solution is reached, the assignments can be determined by looking at the matrix. Each assigned task will have a value of 0 in its assigned agent's column.
  8. The Hungarian algorithm guarantees finding the optimal solution for the assignment problem. It is efficient and can handle large problem sizes, making it widely used in various fields such as operations research and logistics.

I would be implementing this algorithm in 4 languages so @Kumar-laxmi can you assigned me

harshitaaa8 commented 1 year ago

I can implement this algorithm in c, c++, java, python languages. please assign me this issue under SSOC'23

Aarsh30 commented 1 year ago

@Kumar-laxmi still i haven't assigned this issues

Aarsh30 commented 1 year ago

@Kumar-laxmi can you look at this and assign me so i can make pr

github-actions[bot] commented 5 months ago

Stale issue message