# cluster algebra calculator

This library provides a calculator for cluster algebras. 
Especially it is useful for calculating algebraic relations and visualizing quivers

## requirements

- python >= 3.8
- sympy
- pandas

## Installation

```bash
pip install cluster_algebra
```

## Usage

```
from cluster_algebra import *

q = Quiver(vertices=range(14), 
	clusters=[(1, 13), (2, 13), (2, 12), (2, 11), (2, 10), (3, 10), (4, 10), (5, 10), (5, 9), (6, 9), (6, 8)], 
	laminations=[
	# [(0, 8)], 
	# [(4, 12)]
], is_principal=True)
```

Create a quiver (with vertices from 0 to 13) and make triangulations as clusters. When adding laminations, you can use indices (first 0 means the frozen edge 0-1, second 8 means frozen edge 8-9). If is_principal is True, same number of principal laminations will be added **before than you added manually**. 

After creating a quiver instance, you can 
- flip some variables, 
```
q.flip(edge=(3, 10))
# or
q.flip(index=3)
```
- get exchange matrix, 
```
q.get_exchange_matrix()
```
- express target variable, 
```
from IPython.display import display, Math

q2 = q.express_target()

for rel in q2.relations:
    display(Math(rel._repr_latex_()))

for rel in q2.expressions:
    display(Math(rel._repr_latex_()))
```
- plotting polygon with Plotter
```
from math import pi

p = Plotter()

p.plot_quiver(q, rotation=pi, lamination_label_pos=0.7)
```