Root system explorer via the combinatorial mutation game on graphs
Project description
Mutation Game
A Python library for exploring root systems through the combinatorial mutation game on graphs.
Given a graph (or a Dynkin diagram name like A3, D5, E8), the library computes the full root system via iterated mutations and visualizes the mutation graph.
Installation
pip install mutation-game
Or for development:
git clone git@github.com:andreacortis/mutation_game.git
cd mutation_game
uv sync
from mutation_game import MutationGame
game = MutationGame.from_dynkin("A3")
roots = game.calculate_roots()
print(f"A3 has {len(roots)} roots") # 12
fig = game.plot_root_orbits()
fig.savefig("a3_positive.png", bbox_inches="tight", dpi=150)
Features
- Dynkin diagram support -- create games from
A_n,D_n,E_6,E_7,E_8by name - Matrix-based mutations -- each mutation is a precomputed matrix multiply (
v' = M_k @ v) - Cartan matrix analysis -- eigenvalues, eigenvectors, and automatic finite-type detection via positive definiteness
- Root system computation -- full BFS enumeration with verified root counts for all ADE types
- Mutation path finding -- shortest path between any two roots via BFS on the mutation graph
- Path tables -- all-pairs shortest mutation paths in a formatted table
- Visualization -- side-by-side Dynkin diagram and mutation graph with color-coded simple roots
Finite-type detection
The library checks whether the Cartan matrix C = 2I - A is positive definite before attempting to enumerate roots. Infinite-type graphs are rejected early with a clear error:
cycle = MutationGame([[0,1,1],[1,0,1],[1,1,0]])
cycle.is_finite_type() # False
cycle.calculate_roots() # RuntimeError: Cartan matrix is not positive definite
Mutation path table
game = MutationGame.from_dynkin("A3")
game.print_mutation_path_table()
Source Target Mutations Len
-------------------------------------------
(0, 0, 1) (0, 1, 0) 1 -> 2 2
(0, 0, 1) (0, 1, 1) 1 1
(0, 0, 1) (1, 0, 0) 1 -> 2 -> 0 -> 1 4
(0, 0, 1) (1, 1, 0) 1 -> 2 -> 0 3
(0, 0, 1) (1, 1, 1) 1 -> 0 2
...
Each path is reversible: to go from B back to A, apply the same mutations in reverse order.
Tests
uv run pytest test_mutation.py -v
43 tests covering Dynkin construction, mutation rule, root counts for all ADE types, Cartan matrix properties, mutation paths, and plotting.
Documentation
Full documentation with mathematical background is available at mutation-game.readthedocs.io
To build locally:
cd docs
uv run sphinx-build -b html . _build/html
Dependencies
numpy-- linear algebra and matrix operationsnetworkx-- graph construction and layoutmatplotlib-- visualization
License
See LICENSE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mutation_game-0.1.2.tar.gz.
File metadata
- Download URL: mutation_game-0.1.2.tar.gz
- Upload date:
- Size: 2.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Pop!_OS","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c4a8ab4d2093c8a834e1e2a9c509e31c12585854175ef2c61ec797c2dbdec95
|
|
| MD5 |
a7bfcd3a1475df86d1161c0edc3acbde
|
|
| BLAKE2b-256 |
c34c2d99e22790c41ae68b980aba18b77a4944fd0702f1ed1dd8e5b4dc77f641
|
File details
Details for the file mutation_game-0.1.2-py3-none-any.whl.
File metadata
- Download URL: mutation_game-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Pop!_OS","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5c84719561596c215b38c26d7201761d19728f3b95527fd39339fe85693bbb5
|
|
| MD5 |
b6c5d1934f477571364682e3096cd0f5
|
|
| BLAKE2b-256 |
0218f0e2b70d2b45d09d2c832493761e0e3d4b25e9973ffa97c7600cdbb1bee6
|