PHP code example of elgigi / hungarian-algorithm
1. Go to this page and download the library: Download elgigi/hungarian-algorithm library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
elgigi / hungarian-algorithm example snippets
// Define the score matrix as n arrays consisting of n numerical values
$array = [
[1, ··· ,1],
···
[3, ··· ,0],
];
// Create a new Hungarian problem using the score matrix as input
$hungarian = new Hungarian($array);
// Solve the problem using the Hungarian algorithm and get the solution as an array with the row and column as key and value, respectively
$allocation = $hungarian->solve();