Getting started

Jupyter notebook version of this page can be downloaded here.

Installation

We have not reached a stable version yet, but the latest version requiring at least Python 3.10 can be installed by

pip install pyrigi

Alternatively, one can clone/download the package from this GitHub repository. Installation for development is done via Poetry.

Usage

Once the package is installed, the basic classes can be imported as follows:

from pyrigi import Graph, Framework

We can specify a graph by its list of edges.

G = Graph([(0,1), (1,2), (2,3), (0,3)])
G
Graph with vertices [0, 1, 2, 3] and edges [[0, 1], [0, 3], [1, 2], [2, 3]]
G.plot()
../_images/8c56257982de6b1e0bf4acdf95e44c3a36e738b41479f314f9312d4d47c98451.png

Having graph G, we can construct a framework.

F = Framework(G, {0:[0,0], 1:[1,0], 2:[1,'1/2 * sqrt(5)'], 3:[1/2,'4/3']})
F
Framework in 2-dimensional space consisting of:
Graph with vertices [0, 1, 2, 3] and edges [[0, 1], [0, 3], [1, 2], [2, 3]]
Realization {0:(0, 0), 1:(1, 0), 2:(1, sqrt(5)/2), 3:(0.500000000000000, 4/3)}

Notice that in order to keep the coordinates symbolic, they must be entered as strings (or SymPy expressions).

F.plot()
../_images/6ee6babb4c7df7b151d04cf5ad64bd7251cc015cd498ebdd07ee0c00baf5cee8.png

Positions of vertices can be read using square brackets:

F[2]
\[\begin{split}\displaystyle \left[\begin{matrix}1\\\frac{\sqrt{5}}{2}\end{matrix}\right]\end{split}\]

There are also some predefined graphs and frameworks, see graphDB and frameworkDB (also this tutorial)

import pyrigi.frameworkDB as frameworks
TP_flex = frameworks.ThreePrism('parallel')
TP_flex.plot()
../_images/10fc4eb167f3d5aa571e0e2b6e9ae899d8556fcfab61b077a137ead37795a6ca.png

Rigidity properties

Various rigidity properties can be checked by calling class methods, some examples are below.

Infinitesimal rigidity

TP_flex.is_inf_rigid()
False
TP_flex.rigidity_matrix()
\[\begin{split}\displaystyle \left[\begin{array}{cccccccccccc}-2 & 0 & 2 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\-1 & -2 & 0 & 0 & 1 & 2 & 0 & 0 & 0 & 0 & 0 & 0\\0 & -6 & 0 & 0 & 0 & 0 & 0 & 6 & 0 & 0 & 0 & 0\\0 & 0 & 1 & -2 & -1 & 2 & 0 & 0 & 0 & 0 & 0 & 0\\0 & 0 & 0 & -6 & 0 & 0 & 0 & 0 & 0 & 6 & 0 & 0\\0 & 0 & 0 & 0 & 0 & -2 & 0 & 0 & 0 & 0 & 0 & 2\\0 & 0 & 0 & 0 & 0 & 0 & -2 & 0 & 2 & 0 & 0 & 0\\0 & 0 & 0 & 0 & 0 & 0 & -1 & 2 & 0 & 0 & 1 & -2\\0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 2 & -1 & -2\end{array}\right]\end{split}\]
TP_flex.nontrivial_inf_flexes()
[Matrix([
 [1],
 [0],
 [1],
 [0],
 [1],
 [0],
 [0],
 [0],
 [0],
 [0],
 [0],
 [0]])]

Generic rigidity

G_TP = TP_flex.graph()
G_TP.is_rigid()
True
G_TP.is_rigid(dim=1)
True
G_TP.is_rigid(dim=3, combinatorial=False)
False
G_TP.is_globally_rigid()
False
G_TP.is_globally_rigid(dim=1)
True
G_TP.is_redundantly_rigid()
False

Graph drawer

A graph can be also drawn using mouse: when executed in JupyterLab, the following code displays a canvas.

from pyrigi import GraphDrawer
Drawer = GraphDrawer()

At any moment, the currently drawn graph can be retrieved and used further.

Drawer.graph()
Graph with vertices [] and edges []