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. More detailed installation instructions depending on your operating system can be found here.

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/4b1810cab39ae470dad22a9a2835cff8e90f2ed92237889c2f65eaa89ff6e60f.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/ea512400210dde9c48cc675416b928a1854372d63fac4c742f5d623cc84b5167.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/bc24ac204571b6b75ee263f645b34d975e0d420f1b2209921eca3b10432bca55.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 []