## Visualization of Permutation Groups


```python
import numpy as np
import sympy as sp
import sympy.combinatorics as cmb
import matplotlib.pyplot as plt
import matplotlib.cm as cmap
import matplotlib_inline
import networkx as nx
from IPython.display import display,Math
matplotlib_inline.backend_inline.set_matplotlib_formats('svg')
```


```python
def get_color(idx):
    color_names = list(cmap.colors.TABLEAU_COLORS.keys())
    return color_names[idx % len(color_names)]

def draw_perm(P, ax, color='k', font_color='w'):
    g = nx.MultiDiGraph()
    g.add_nodes_from(range(P.size))
    for i in range(P.size):
        g.add_edge(i, P(i))
    nx.draw_circular(g, ax=ax, \
                     with_labels=True, \
                     node_color=color, \
                     font_color=font_color, \
                     font_size=8, \
                     node_size=150, \
                     node_shape='o', \
                     connectionstyle='arc3,rad=0.0')

def draw_perm_group(PG):
    fig = plt.figure(figsize=(10,10),dpi=100)
    fig.set_tight_layout(True)
    axes = fig.subplots(5,5).flatten()
    for i in range(len(axes)):
        if i < len(PG):
            draw_perm(PG[i], axes[i], get_color(i), 'w')
        else:
            axes[i].set_visible(False)
    plt.draw()
```

---
### $S_4$ - Symmetric group order 4


```python
S4 = list(cmb.generators.symmetric(4))
draw_perm_group(S4)
```


    

    


---
### $A_4$ - Alternating group order 4


```python
A4 = list(cmb.generators.alternating(4))
draw_perm_group(A4)
```


    

    


---
### $D_6$ - Dihedral group order 6


```python
D6 = list(cmb.generators.dihedral(6))
draw_perm_group(D6)
```


    

    


---
### $C_8$ - Cyclic group order 8


```python
C8 = list(cmb.generators.cyclic(8))
draw_perm_group(C8)
```


    

    


8de27e67047ea2499d18ae7ba8f0993b11f1b990
ipynb
Jupyter Notebook
permutation-groups.ipynb
afedotov/scipy-notebooks
de30a4e826a027618b3e07e072adaa007305ff3e
Unlicense
permutation-groups.ipynb
afedotov/scipy-notebooks
de30a4e826a027618b3e07e072adaa007305ff3e
Unlicense
permutation-groups.ipynb
afedotov/scipy-notebooks
de30a4e826a027618b3e07e072adaa007305ff3e
Unlicense
Qwen/Qwen-72B
1. YES
2. YES