# syzio/hungarian-go architecture

> Architecture diagram of the GitHub repository syzio/hungarian-go, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/syzio/hungarian-go
- Repository: https://github.com/syzio/hungarian-go

## Overview

Hungarian is a small Go library for solving assignment problems. A caller configures a solver, supplies a cost matrix, and receives a Result with assignments and cost. The runtime validates the matrix, prepares it for minimization and square dimensions as needed, runs the Kuhn–Munkres algorithm, and filters dummy and forbidden assignments. Result exposes mapping, string, and JSON representations. The sampled source supports these runtime relationships; no external services or persistent state are involved.

Main entry points: [`hungarian.go`](https://github.com/syzio/hungarian-go/blob/main/hungarian.go) (Hungarian solver), [`result.go`](https://github.com/syzio/hungarian-go/blob/main/result.go) (Result API), [`errors.go`](https://github.com/syzio/hungarian-go/blob/main/errors.go) (Error sentinels)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_caller(("Library caller"))
node_solver["Hungarian solver<br/>[hungarian.go]"]
node_validation["Matrix validation<br/>[hungarian.go]"]
node_preparation["Matrix preparation<br/>[hungarian.go]"]
node_algorithm["Kuhn–Munkres<br/>[hungarian.go]"]
node_result["Result API<br/>[result.go]"]
node_errors["Error sentinels<br/>[errors.go]"]

node_caller -->|"configures and submits matrix"| node_solver
node_solver -->|"validates"| node_validation
node_validation -->|"wraps invalid input"| node_errors
node_solver -->|"normalizes and pads"| node_preparation
node_solver -->|"runs"| node_algorithm
node_solver -->|"returns result"| node_result
node_solver -->|"wraps invalid mode"| node_errors
node_caller -->|"reads or marshals"| node_result

click node_solver "https://github.com/syzio/hungarian-go/blob/main/hungarian.go"
click node_validation "https://github.com/syzio/hungarian-go/blob/main/hungarian.go"
click node_preparation "https://github.com/syzio/hungarian-go/blob/main/hungarian.go"
click node_algorithm "https://github.com/syzio/hungarian-go/blob/main/hungarian.go"
click node_result "https://github.com/syzio/hungarian-go/blob/main/result.go"
click node_errors "https://github.com/syzio/hungarian-go/blob/main/errors.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_caller toneIndigo
class node_solver,node_validation,node_preparation,node_algorithm,node_errors toneTeal
class node_result toneMint
```

## Components

### Other components

- **Library caller**
- [Hungarian solver](https://github.com/syzio/hungarian-go/blob/main/hungarian.go): `hungarian.go`
- [Matrix validation](https://github.com/syzio/hungarian-go/blob/main/hungarian.go): `hungarian.go`
- [Matrix preparation](https://github.com/syzio/hungarian-go/blob/main/hungarian.go): `hungarian.go`
- [Kuhn–Munkres](https://github.com/syzio/hungarian-go/blob/main/hungarian.go): `hungarian.go`
- [Result API](https://github.com/syzio/hungarian-go/blob/main/result.go): `result.go`
- [Error sentinels](https://github.com/syzio/hungarian-go/blob/main/errors.go): `errors.go`

## Connections

- Library caller → Hungarian solver: configures and submits matrix
- Hungarian solver → Matrix validation: validates
- Matrix validation → Error sentinels: wraps invalid input
- Hungarian solver → Matrix preparation: normalizes and pads
- Hungarian solver → Kuhn–Munkres: runs
- Hungarian solver → Result API: returns result
- Hungarian solver → Error sentinels: wraps invalid mode
- Library caller → Result API: reads or marshals
