The assignment problem is one of the fundamental combinatorial optimization problems in the branch of optimization or operations research in mathematics. It consists of finding a maximum weight matching in a weighted bipartite graph.

In its most general form, the problem is as follows:

There are a number of agents and a number of tasks. Any agent can be assigned to perform any task, incurring some cost that may vary depending on the agent-task assignment. It is required to perform all tasks by assigning exactly one agent to each task and exactly one task to each agent in such a way that the total cost of the assignment is minimized.

If the numbers of agents and tasks are equal and the total cost of the assignment for all tasks is equal to the sum of the costs for each agent (or the sum of the costs for each task, which is the same thing in this case), then the problem is called the linear assignment problem. Commonly, when speaking of the assignment problem without any additional qualification, then the linear assignment problem is meant.

This API is based on this Hungarian Algorithm implementation.

**The complexity is N^3**.

**Example**

Say you have three workers: Jim, Steve, and Alan. You need to have one of them clean the bathroom, another sweep the floors, and the third wash the windows. What’s the best (minimum-cost) way to assign the jobs? First we need a matrix of the costs of the workers doing the jobs:

Clean bathroom | Sweep floors | Wash windows | |
---|---|---|---|

Jim | $3 | $3 | $3 |

Steve | $3 | $2 | $3 |

Alan | $3 | $3 | $2 |

**Input**

*Note: in the list you can include all the nodes (like in the example), or only those in one group of the bipartite graph (in the example this'd mean that it's enough to specify the Jim, Steve and Alan keys).***Output**

**assignment**: this is a Map<String, String>, in which each key is a node and its value is the name of the node it is assigned to**weight**: the total weight of the matches