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()
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()
Positions of vertices can be read using square brackets:
F[2]
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()
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()
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 []