This repository contains a small GUI and optimizer to reduce edge crossings (k-planarity) of a graph. The GUI is built with CustomTkinter + Matplotlib; the optimizer uses a simulated annealing approach.
- Operating System: Windows 10/11
- Python: 3.9+ (3.10 or newer recommended, tested on 3.11.4)
- Shell: Windows PowerShell
customtkinter # Modern GUI framework
matplotlib # Plotting and visualization
numpy # Numerical operations
packaging # Version handling
networkx # Graph algorithms
For high-performance CUDA acceleration:
- CUDA Toolkit: 12.6.20 or compatible
- GPU: NVIDIA GPU with compute capability 8.0+ (tested on RTX 4060)
- Compiler: Visual Studio 2022 with C++ build tools
- Additional Python Packages:
pybind11- Python-C++ bindingpytest- Testing frameworkcupy-cuda12x- CUDA array library (optional)
CUDA Installation Path (Windows default):
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6
- Python 3.9+ (3.10 or newer recommended)
- Windows PowerShell (these commands are written for PowerShell)
Create an isolated virtual environment named heilbron-43, activate it, and install dependencies:
# From the repo root
# If 'python' is available on PATH
python -m venv .\heilbron-43
.\heilbron-43\Scripts\Activate.ps1
# If 'python' is not found, create with the launcher and then activate
# py -3 -m venv .\heilbron-43
# .\heilbron-43\Scripts\Activate.ps1
python -m pip install --upgrade pip
pip install -r requirements.txtRun the unit tests to verify everything is working:
python -m unittest -vLaunch the GUI app:
python .\src\app.pyClose the app window to stop the optimizer thread cleanly.
- Example instances are under
live-2025-example-instances/. - A simple input example is provided in
sample.json. - The expected JSON format:
nodes: list of{ id, x, y }whereidis a zero-based integer index.edges: list of{ source, target }referencing node ids.- Optional:
width,heightto set canvas bounds (defaults are large).
- Execution policy blocking activation:
- If
Activate.ps1is blocked, temporarily relax the policy for the current session:Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass .\heilbron-43\Scripts\Activate.ps1
- If
- Tkinter availability:
- The official Python installer for Windows includes Tkinter by default. If
tkintererrors appear, reinstall Python using the official installer from python.org.
- The official Python installer for Windows includes Tkinter by default. If
deactivate
# To delete the venv folder entirely
Remove-Item -Recurse -Force .\heilbron-43src/app.py: GUI application (load JSON, visualize, drag nodes, run optimizer)src/solver.py: Simulated annealing solver (positions + energy updates)src/scorer.py: Vectorized crossing counting utilities (k and total crossings)tests/: Unittest suite for scorer and solverrequirements.txt: Python dependencies