HungarianAlgorithm 2.3.3

dotnet add package HungarianAlgorithm --version 2.3.3                
NuGet\Install-Package HungarianAlgorithm -Version 2.3.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HungarianAlgorithm" Version="2.3.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HungarianAlgorithm --version 2.3.3                
#r "nuget: HungarianAlgorithm, 2.3.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install HungarianAlgorithm as a Cake Addin
#addin nuget:?package=HungarianAlgorithm&version=2.3.3

// Install HungarianAlgorithm as a Cake Tool
#tool nuget:?package=HungarianAlgorithm&version=2.3.3                

Hungarian Algorithm

Build status NuGet NuGet

The Hungarian algorithm is a combinatorial optimization method, that solves the assignment problem in polynomial time, and which anticipated later primal-dual methods. In other words, based on a matrix of possible combinations of costs, the algorithm returns an ordered collcetion of matches, having the lowest combined cost, thus being the most optimal assignment.


The Algorithm

The example below, shows how to use and apply the algorithm.
It defines a two-dimensional array, passes it to algorithm, and recieves a result of an array of matched columns for each row (x) passed.

int[,] costs = new int[x,y]();
int[] result = HungarianAlgorithm.FindAssignments(costs);

Example Usage

Let's say you want to solve this example from Wikipedia where you need to know which is the lowest-cost way to assign cleaning tasks.

In this example, there are three workers and three tasks.

Worker Clean Bathroom Sweep Floors Wash Windows
Alice 8 4 7
Bob 5 2 3
Carol 9 4 8

The lowest total cost is 15. This is the case where:

  • Alice cleans the bathroom (8)
  • Bob washes the windows (3)
  • Carol sweeps the floors (4)

The expected result of FindAssignments is that it returns the positions of 8,3,and 4.

To input this scenario into FindAssignments, the array would look like this:

int[,] costs = {{8, 4, 7}, 
                {5, 2, 3},
                {9, 4, 8}};

Pass this 2D array to FindAssignments like this:

int[] solutionIndexes = HungarianAlgorithm.FindAssignments(costs);

The resulting array will hold the indexes of the items that combine for the lowest total cost.

In this example, result would be [0,2,1];

This is because:

  • in first costs sub-array (representing Alice), 8 is in element 0.
  • in second costs sub-array (representing Bob), 3 is in element 2.
  • in third costs sub-array (representing Carol), 4 is in element 1.

Original source-code posted by Alex Regueiro in 2010 (Link)

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on HungarianAlgorithm:

Package Downloads
SortCS

SortCS is a 'Multiple Object Tracker'

SharpSoft.Math

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.3.3 129 12/10/2024
2.3.2 616 8/29/2024
2.3.1 905 5/26/2024

- Updated NuGets.