# amineladrem/lp-solver-for-bipartite-graph-matching architecture

> Architecture diagram of the GitHub repository amineladrem/lp-solver-for-bipartite-graph-matching, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amineladrem/lp-solver-for-bipartite-graph-matching
- Repository: https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching

## Overview

1. **Repository split: two independent subsystems**
   This repo is organized around two separate deliverables: a **benchmarking pipeline** for maximum-cardinality bipartite matching solvers, and a **client-side web visualizer** that explains the problem and algorithms interactively. The README explicitly states these parts do not depend on each other.

2. **Benchmarking pipeline: end-to-end experiment flow**
   The experiment side in `mcbp-experiment/` is a batch workflow: generate random bipartite graphs, run multiple solvers, validate outputs, then plot runtime/memory/result summaries. The canonical entry point is the notebook `run_full_benchmark.ipynb`, which orchestrates the full sequence rather than requiring manual script-by-script execution.

3. **Experiment data model and artifact flow**
   The benchmark pipeline produces and consumes three main artifact types:
   - `graphs/`: generated graph instances, stored as `.graph` files
   - `results/results.csv`: consolidated solver measurements and statuses
   - `figures/`: PDF plots derived from the CSV results  
   This creates a one-way flow from instance generation to solver execution to analysis/visualization.

4. **Solver execution boundary: Python orchestration, mixed backends**
   The Python layer in `mcbp-experiment/python/` appears to be the orchestration and wrapper layer, while the actual solver implementations are split between Python and C++. The solver set includes:
   - Gurobi LP
   - HiGHS LP
   - SciPy `linprog`
   - LEMON Hopcroft-Karp  
   The C++ sources under `src/` correspond to native solver binaries/wrappers, with CMake used to build them.

5. **Benchmark infrastructure and external dependencies**
   The experiment subsystem depends on heavyweight solver libraries and licenses where applicable. Gurobi requires a valid license, and HiGHS/LEMON need their respective native libraries. The workflow is designed to skip solvers if dependencies are unavailable, which affects how the benchmark matrix is populated.

6. **Graph generation and validation as distinct stages**
   The Python scripts include dedicated responsibilities: generating random graphs, running experiments, validating solver results, and plotting outputs. This indicates a pipeline where correctness is checked separately from performance measurement, so the results CSV likely contains both metrics and solver status/error information.

7. **Visualization outputs encode experimental dimensions**
   The `figures/` directory contains plots organized by graph size and density, suggesting the benchmark varies at least two parameters: number of vertices and edge density. This is important for architecture because the analysis layer is parameterized around experimental sweeps, not a single benchmark case.

8. **Web visualizer: fully client-side application**
   `mcbp-visualizer/` is a standalone Next.js/React/TypeScript app styled with Tailwind. It is explicitly browser-only and does not call the Python/C++ benchmark code. This boundary matters: the visualizer is educational and self-contained, not a front-end for the benchmark backend.

9. **Visualizer internal structure: UI, state, and algorithm modules**
   The visualizer is split into:
   - `app/`: Next.js page/layout entry points
   - `components/`: panels, controls, tables, explanations, visualization canvas
   - `hooks/`: animation/player behavior
   - `lib/`: graph model, app state, layout, utilities, and algorithm logic
   - `types/`: shared type definitions  
   This shows a typical client architecture where rendering and interaction are separated from algorithm/data logic.

10. **Algorithm explanation layer in the browser**
   The visualizer includes algorithm modules for **Hopcroft-Karp** and **LP** in `lib/algorithms/`, but the README notes the LP controls are educational: the browser computes the final matching using Hopcroft-Karp. So the LP formulation is presented as a teaching tool, while the actual interactive result computation is combinatorial.

11. **UI interaction model**
   The visualizer’s components indicate a step-by-step educational flow: controls drive an animation player, the visualization updates graph state, and an explanation panel narrates the current algorithm step. A comparison table and algorithm-specific panels suggest the app is designed to contrast LP reasoning with matching algorithm behavior.

12. **Core architectural boundary to capture in a diagram**
   A good architecture diagram should show two disconnected worlds:
   - **Benchmark world**: notebook → Python orchestration → native/Python solvers → results CSV → plots
   - **Visualizer world**: browser app → local algorithm/state modules → rendered explanation/animation  
   There is no runtime bridge between them; they share a problem domain, not execution or data services.

Main entry points: [`mcbp-experiment/src`](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/tree/main/mcbp-experiment/src) (Native solvers), [`mcbp-experiment/python/solvers`](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/tree/main/mcbp-experiment/python/solvers) (Solver wrappers), [`mcbp-visualizer/components`](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/tree/main/mcbp-visualizer/components) (UI panels), [`mcbp-experiment/python/run_experiments.py`](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/python/run_experiments.py) (Run experiments)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_benchmark["Benchmark pipeline"]
  node_bench_notebook["Full benchmark<br/>notebook orchestrator"]
  node_bench_generate["Generate graphs<br/>python stage<br/>[generate_graphs.py]"]
  node_bench_run["Run experiments<br/>python stage<br/>[run_experiments.py]"]
  node_bench_validate["Validate results<br/>python stage"]
  node_bench_plot["Plot results<br/>python stage<br/>[plot_results.py]"]
  node_bench_graphs[("Graph set<br/>artifact store")]
  node_bench_results["Results CSV<br/>benchmark data<br/>[results.csv]"]
  node_bench_figures[("Figures<br/>analysis outputs")]
  node_bench_python_solvers["Solver wrappers<br/>python adapters"]
  node_bench_gurobi_py["Gurobi LP<br/>python solver<br/>[gurobi_lp.py]"]
  node_bench_highs_py["HiGHS LP<br/>python solver<br/>[highs_lp.py]"]
  node_bench_scipy_py["SciPy LP<br/>python solver<br/>[scipy_lp.py]"]
  node_bench_lemon_py["LEMON HK<br/>python solver<br/>[lemon_hk.py]"]
  node_bench_native_lp["Native solvers<br/>C++ binaries"]
  node_bench_gurobi_cpp["Gurobi C++<br/>native solver<br/>[gurobi_lp.cpp]"]
  node_bench_highs_cpp["HiGHS C++<br/>native solver<br/>[highs_lp.cpp]"]
  node_bench_lemon_cpp["LEMON C++<br/>native solver<br/>[lemon_hk.cpp]"]
end

subgraph group_visualizer["Web visualizer"]
  node_viz_app["App shell<br/>Next.js app"]
  node_viz_ui["UI panels<br/>React components"]
  node_viz_anim["Animation hook<br/>interaction hook"]
  node_viz_state["State model<br/>client state"]
  node_viz_hk["Hopcroft-Karp<br/>algorithm module<br/>[hopcroftKarp.ts]"]
  node_viz_lp["LP model<br/>algorithm module<br/>[lp.ts]"]
end

node_bench_notebook -->|"orchestrates"| node_bench_generate
node_bench_generate -->|"writes"| node_bench_graphs
node_bench_notebook -->|"orchestrates"| node_bench_run
node_bench_graphs -->|"input"| node_bench_run
node_bench_run -->|"dispatches to"| node_bench_python_solvers
node_bench_python_solvers -->|"includes"| node_bench_gurobi_py
node_bench_python_solvers -->|"includes"| node_bench_highs_py
node_bench_python_solvers -->|"includes"| node_bench_scipy_py
node_bench_python_solvers -->|"includes"| node_bench_lemon_py
node_bench_gurobi_py -.->|"may call"| node_bench_native_lp
node_bench_highs_py -.->|"may call"| node_bench_native_lp
node_bench_lemon_py -.->|"may call"| node_bench_native_lp
node_bench_native_lp -->|"builds"| node_bench_gurobi_cpp
node_bench_native_lp -->|"builds"| node_bench_highs_cpp
node_bench_native_lp -->|"builds"| node_bench_lemon_cpp
node_bench_run -->|"writes"| node_bench_results
node_bench_validate -->|"updates"| node_bench_results
node_bench_results -->|"input"| node_bench_plot
node_bench_plot -->|"writes"| node_bench_figures
node_viz_app -->|"renders"| node_viz_ui
node_viz_ui -->|"drives"| node_viz_anim
node_viz_ui -->|"uses"| node_viz_state
node_viz_anim -->|"updates"| node_viz_state
node_viz_state -->|"computes via"| node_viz_hk
node_viz_state -->|"explains via"| node_viz_lp
node_viz_ui -->|"visualizes"| node_viz_hk
node_viz_ui -->|"visualizes"| node_viz_lp

click node_bench_notebook "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/run_full_benchmark.ipynb"
click node_bench_generate "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/python/generate_graphs.py"
click node_bench_run "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/python/run_experiments.py"
click node_bench_validate "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/python/validate_results.py"
click node_bench_plot "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/python/plot_results.py"
click node_bench_graphs "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/tree/main/mcbp-experiment/graphs"
click node_bench_results "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/results/results.csv"
click node_bench_figures "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/tree/main/mcbp-experiment/figures"
click node_bench_python_solvers "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/tree/main/mcbp-experiment/python/solvers"
click node_bench_gurobi_py "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/python/solvers/gurobi_lp.py"
click node_bench_highs_py "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/python/solvers/highs_lp.py"
click node_bench_scipy_py "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/python/solvers/scipy_lp.py"
click node_bench_lemon_py "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/python/solvers/lemon_hk.py"
click node_bench_native_lp "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/tree/main/mcbp-experiment/src"
click node_bench_gurobi_cpp "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/src/gurobi_lp.cpp"
click node_bench_highs_cpp "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/src/highs_lp.cpp"
click node_bench_lemon_cpp "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/src/lemon_hk.cpp"
click node_viz_app "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/tree/main/mcbp-visualizer/app"
click node_viz_ui "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/tree/main/mcbp-visualizer/components"
click node_viz_anim "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-visualizer/hooks/useAnimationPlayer.ts"
click node_viz_state "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/tree/main/mcbp-visualizer/lib"
click node_viz_hk "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-visualizer/lib/algorithms/hopcroftKarp.ts"
click node_viz_lp "https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-visualizer/lib/algorithms/lp.ts"

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_bench_notebook,node_bench_generate,node_bench_run,node_bench_validate,node_bench_plot,node_bench_graphs,node_bench_results,node_bench_figures,node_bench_python_solvers,node_bench_gurobi_py,node_bench_highs_py,node_bench_scipy_py,node_bench_lemon_py,node_bench_native_lp,node_bench_gurobi_cpp,node_bench_highs_cpp,node_bench_lemon_cpp toneBlue
class node_viz_app,node_viz_ui,node_viz_anim,node_viz_state,node_viz_hk,node_viz_lp toneAmber
```

## Components

### Benchmark pipeline

Notebook-driven experiment workflow for generating graphs, running solvers, validating outputs, and producing plots.

- [Full benchmark](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/run_full_benchmark.ipynb): notebook orchestrator · Canonical entry point that runs the end-to-end experiment sequence. · `mcbp-experiment/run_full_benchmark.ipynb`
- [Generate graphs](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/python/generate_graphs.py): python stage · Creates random bipartite graph instances for the benchmark sweep. · `mcbp-experiment/python/generate_graphs.py`
- [Run experiments](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/python/run_experiments.py): python stage · Coordinates solver execution across generated instances and collects measurements. · `mcbp-experiment/python/run_experiments.py`
- [Validate results](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/python/validate_results.py): python stage · Checks solver outputs and records correctness or failure status. · `mcbp-experiment/python/validate_results.py`
- [Plot results](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/python/plot_results.py): python stage · Transforms consolidated CSV measurements into PDF figures. · `mcbp-experiment/python/plot_results.py`
- [Graph set](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/tree/main/mcbp-experiment/graphs): artifact store · Generated graph instances stored as .graph files. · `mcbp-experiment/graphs`
- [Results CSV](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/results/results.csv): benchmark data · Consolidated solver metrics, statuses, and experiment metadata. · `mcbp-experiment/results/results.csv`
- [Figures](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/tree/main/mcbp-experiment/figures): analysis outputs · Runtime, memory, and landscape plots derived from benchmark results. · `mcbp-experiment/figures`
- [Solver wrappers](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/tree/main/mcbp-experiment/python/solvers): python adapters · Python-side solver interfaces and shared execution helpers. · `mcbp-experiment/python/solvers`
- [Gurobi LP](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/python/solvers/gurobi_lp.py): python solver · Python wrapper for the Gurobi-based LP formulation. · `mcbp-experiment/python/solvers/gurobi_lp.py`
- [HiGHS LP](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/python/solvers/highs_lp.py): python solver · Python wrapper for the HiGHS-based LP formulation. · `mcbp-experiment/python/solvers/highs_lp.py`
- [SciPy LP](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/python/solvers/scipy_lp.py): python solver · Python wrapper for the SciPy linprog-based LP formulation. · `mcbp-experiment/python/solvers/scipy_lp.py`
- [LEMON HK](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/python/solvers/lemon_hk.py): python solver · Python wrapper for the LEMON Hopcroft-Karp solver. · `mcbp-experiment/python/solvers/lemon_hk.py`
- [Native solvers](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/tree/main/mcbp-experiment/src): C++ binaries · C++ implementations and wrappers built with CMake for solver backends. · `mcbp-experiment/src`
- [Gurobi C++](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/src/gurobi_lp.cpp): native solver · C++ implementation for the Gurobi-backed LP solver. · `mcbp-experiment/src/gurobi_lp.cpp`
- [HiGHS C++](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/src/highs_lp.cpp): native solver · C++ implementation for the HiGHS-backed LP solver. · `mcbp-experiment/src/highs_lp.cpp`
- [LEMON C++](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-experiment/src/lemon_hk.cpp): native solver · C++ implementation for the Hopcroft-Karp solver backend. · `mcbp-experiment/src/lemon_hk.cpp`

### Web visualizer

Client-side Next.js app for explaining bipartite matching algorithms interactively.

- [App shell](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/tree/main/mcbp-visualizer/app): Next.js app · Browser entry points and global styling for the visualizer. · `mcbp-visualizer/app`
- [UI panels](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/tree/main/mcbp-visualizer/components): React components · Controls, algorithm panels, explanations, table, and visualization canvas. · `mcbp-visualizer/components`
- [Animation hook](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-visualizer/hooks/useAnimationPlayer.ts): interaction hook · Manages step-by-step playback and timing for the educational flow. · `mcbp-visualizer/hooks/useAnimationPlayer.ts`
- [State model](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/tree/main/mcbp-visualizer/lib): client state · Shared graph/app state, layout, utilities, and type definitions. · `mcbp-visualizer/lib`
- [Hopcroft-Karp](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-visualizer/lib/algorithms/hopcroftKarp.ts): algorithm module · Client-side combinatorial matching logic used for the interactive result computation. · `mcbp-visualizer/lib/algorithms/hopcroftKarp.ts`
- [LP model](https://github.com/amineladrem/lp-solver-for-bipartite-graph-matching/blob/main/mcbp-visualizer/lib/algorithms/lp.ts): algorithm module · Educational LP formulation module shown in the visualizer UI. · `mcbp-visualizer/lib/algorithms/lp.ts`

## Connections

- Full benchmark → Generate graphs: orchestrates · The notebook drives the graph-generation stage.
- Generate graphs → Graph set: writes · Generated instances are persisted as graph files.
- Full benchmark → Run experiments: orchestrates · The notebook triggers solver execution over generated instances.
- Graph set → Run experiments: input · Experiment runs consume generated graph instances.
- Run experiments → Solver wrappers: dispatches to · The experiment runner invokes solver adapters.
- Solver wrappers → Gurobi LP: includes · Gurobi adapter.
- Solver wrappers → HiGHS LP: includes · HiGHS adapter.
- Solver wrappers → SciPy LP: includes · SciPy adapter.
- Solver wrappers → LEMON HK: includes · LEMON adapter.
- Gurobi LP → Native solvers: may call · Gurobi can also be backed by native code paths.
- HiGHS LP → Native solvers: may call · HiGHS can also be backed by native code paths.
- LEMON HK → Native solvers: may call · LEMON solver uses native implementation support.
- Native solvers → Gurobi C++: builds · C++ Gurobi solver implementation.
- Native solvers → HiGHS C++: builds · C++ HiGHS solver implementation.
- Native solvers → LEMON C++: builds · C++ Hopcroft-Karp implementation.
- Run experiments → Results CSV: writes · Solver measurements and statuses are consolidated into CSV.
- Validate results → Results CSV: updates · Validation adds correctness/failure information to benchmark results.
- Results CSV → Plot results: input · Plots are derived from the consolidated results CSV.
- Plot results → Figures: writes · Analysis outputs are emitted as PDF figures.
- App shell → UI panels: renders · The app shell composes the interactive UI panels.
- UI panels → Animation hook: drives · Controls and panels interact with the playback hook.
- UI panels → State model: uses · UI components read and update shared app state.
- Animation hook → State model: updates · Animation state advances the graph and explanation flow.
- State model → Hopcroft-Karp: computes via · Interactive matching steps rely on Hopcroft-Karp logic.
- State model → LP model: explains via · LP formulation is used as an educational model in the browser.
- UI panels → Hopcroft-Karp: visualizes · Algorithm panels surface Hopcroft-Karp behavior.
- UI panels → LP model: visualizes · LP panels explain the formulation and its relation to matching.
