How syzio/hungarian-php works
This small PHP library solves a caller-supplied assignment matrix with the Hungarian algorithm and returns an immutable result object. The main workflow validates the matrix, prepares it for the selected mode and shape, computes an optimal matching, then removes dummy or forbidden assignments. The README also documents rectangular matrices, forbidden cells, and result accessors/serialization. The graph follows the sampled implementation; it omits tests and delivery tooling.
Main entry points: Hungarian.php Hungarian solver · Mode.php Solve mode · Result.php Assignment result · InvalidMatrixException.php Invalid matrix error
Components 8
Other components
- Library caller
- Solve mode
src/Mode.php - Hungarian solver
src/Hungarian.php - Matrix validation
src/Hungarian.php - Matrix preparation
src/Hungarian.php - Munkres algorithm
src/Hungarian.php - Assignment result
src/Result.php - Invalid matrix error
src/InvalidMatrixException.php
Connections 9
- Library caller → Hungarian solver: submits matrix
- Library caller → Solve mode: selects mode
- Solve mode → Hungarian solver: configures
- Hungarian solver → Matrix validation: validates
- Matrix validation → Invalid matrix error: throws
- Hungarian solver → Matrix preparation: prepares matrix
- Hungarian solver → Munkres algorithm: runs matching
- Hungarian solver → Assignment result: constructs result
- Assignment result → Library caller: returns assignments