![]() |
Minimum Spanning Tree 0.1.0
Minimum spanning tree solver with graphical visualization
|
Minimum Spanning Tree Solver is a C++ project that solves the MST problem using a linear programming formulation via IBM CPLEX and visualizes results using CDT (Conforming Delaunay Triangulation).
This project implements an exact solver for the Minimum Spanning Tree (MST) problem using integer programming (IP). IBM CPLEX is used as the solver backend. Results are visualized with CDT in SVG format, overlaying the MST on a Delaunay triangulation.
We want to find a tree spanning all n nodes with minimal total edge cost.
Let x_ij = 1 if edge (i, j) is part of the MST, and 0 otherwise.
Objective: Minimize total cost:
Constraints:
Tree contains exactly n - 1 edges:
No cycles — subtour elimination:
Binary variables:
This is an exponential-size IP, but its LP relaxation has integral extreme points, allowing it to be solved efficiently for MST.
To apply the subtour elimination constraint, the solver enumerates all subsets of vertices with size ≥ 3 and < n. For each subset, a constraint is added that limits internal edges to at most |S| - 1.
Make sure to clone the repository with submodules:
If you've already cloned the repository without --recursive, run:
This ensures the CDT library is properly initialized.
CPLEX is automatically located if installed in a standard path.
Simply open the folder in VSCode with the CMake extension, choose x64-release preset and run.
Run the following commands to configure and build the project:
Use Developer PowerShell to ensure
cl.exeandCPLEXare in the environment.
Tests are located under minimum-spanning-tree/tests and cover:
To run tests via CLI:
Or run test_subsets.exe, test_common.exe directly from the build folder.
The solution is visualized using SVG:
Example output:
Total MST cost: 116.491
SVG visualization written to mst_visualization.svg
Documentation is auto-generated from docstring via Doxygen and hosted via GitHub Pages:
To generate locally:
This project is licensed under the [MIT License](LICENSE).