How amineladrem/lp-solver-for-bipartite-graph-matching works
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: src Native solvers · solvers Solver wrappers · components UI panels · run_experiments.py Run experiments
Components 23
Benchmark pipeline
Notebook-driven experiment workflow for generating graphs, running solvers, validating outputs, and producing plots.
- Full benchmark · Canonical entry point that runs the end-to-end experiment sequence.
mcbp-experiment/run_full_benchmark.ipynb - Generate graphs · Creates random bipartite graph instances for the benchmark sweep.
mcbp-experiment/python/generate_graphs.py - Run experiments · Coordinates solver execution across generated instances and collects measurements.
mcbp-experiment/python/run_experiments.py - Validate results · Checks solver outputs and records correctness or failure status.
mcbp-experiment/python/validate_results.py - Plot results · Transforms consolidated CSV measurements into PDF figures.
mcbp-experiment/python/plot_results.py - Graph set · Generated graph instances stored as .graph files.
mcbp-experiment/graphs - Results CSV · Consolidated solver metrics, statuses, and experiment metadata.
mcbp-experiment/results/results.csv - Figures · Runtime, memory, and landscape plots derived from benchmark results.
mcbp-experiment/figures - Solver wrappers · Python-side solver interfaces and shared execution helpers.
mcbp-experiment/python/solvers - Gurobi LP · Python wrapper for the Gurobi-based LP formulation.
mcbp-experiment/python/solvers/gurobi_lp.py - HiGHS LP · Python wrapper for the HiGHS-based LP formulation.
mcbp-experiment/python/solvers/highs_lp.py - SciPy LP · Python wrapper for the SciPy linprog-based LP formulation.
mcbp-experiment/python/solvers/scipy_lp.py - LEMON HK · Python wrapper for the LEMON Hopcroft-Karp solver.
mcbp-experiment/python/solvers/lemon_hk.py - Native solvers · C++ implementations and wrappers built with CMake for solver backends.
mcbp-experiment/src - Gurobi C++ · C++ implementation for the Gurobi-backed LP solver.
mcbp-experiment/src/gurobi_lp.cpp - HiGHS C++ · C++ implementation for the HiGHS-backed LP solver.
mcbp-experiment/src/highs_lp.cpp - LEMON C++ · 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 · Browser entry points and global styling for the visualizer.
mcbp-visualizer/app - UI panels · Controls, algorithm panels, explanations, table, and visualization canvas.
mcbp-visualizer/components - Animation hook · Manages step-by-step playback and timing for the educational flow.
mcbp-visualizer/hooks/useAnimationPlayer.ts - State model · Shared graph/app state, layout, utilities, and type definitions.
mcbp-visualizer/lib - Hopcroft-Karp · Client-side combinatorial matching logic used for the interactive result computation.
mcbp-visualizer/lib/algorithms/hopcroftKarp.ts - LP model · Educational LP formulation module shown in the visualizer UI.
mcbp-visualizer/lib/algorithms/lp.ts
Connections 27
- 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.