Generic Rigidity¶
This module provides algorithms related to generic rigidity.
- pyrigi.graph._rigidity.generic.is_linked(graph, u, v, dim=2)[source]¶
Return whether a pair of vertices is
dim-linked.Lemma 2 is used for the check.
Definitions
- Parameters:
- Return type:
Examples
>>> H = Graph([[0, 1], [0, 2], [1, 3], [1, 5], [2, 3], [2, 6], [3, 5], [3, 7], [5, 7], [6, 7], [3, 6]]) >>> is_linked(H, 1,7) True >>> H = Graph([[0, 1], [0, 2], [1, 3], [2, 3]]) >>> is_linked(H, 0,3) False >>> is_linked(H, 1,3) True
Suggested Improvements
Implement also for other dimensions.
- pyrigi.graph._rigidity.generic.is_min_rigid(graph, dim=2, algorithm='default', use_precomputed_pebble_digraph=False, prob=0.0001)[source]¶
Return whether the graph is minimally
dim-rigid.Definitions
- Parameters:
graph (
Graph)dim (
int) – Dimension.algorithm (
str) –If
"graphic"(only ifdim=1), then the graphic matroid is used, namely, it is checked whether the graph is a tree.If
"sparsity"(only ifdim=2), then (2,3)-tightness and Theorem 1 are used.If
"randomized", a probabilistic check is performed. It may give false negatives (with probability at mostprob), but no false positives. See Theorem 4.If
"extension_sequence"(only ifdim=2), then the existence of a sequence of rigidity preserving extensions is checked, seehas_extension_sequence().If
"default", then"graphic"is used fordim=1and"sparsity"fordim=2and"randomized"fordim>=3.use_precomputed_pebble_digraph (
bool) – Only relevant ifalgorithm="sparsity". IfTrue, the pebble digraph present in the cache is used. IfFalse, recompute the pebble digraph. UseTrueonly if you are certain that the pebble game digraph is consistent with the graph.prob (
float) – Only relevant ifalgorithm="randomized". It determines the bound on the probability of the randomized algorithm to yield false negatives.
- Return type:
Examples
>>> G = Graph([(0,1), (1,2), (2,3), (3,0), (1,3)]) >>> is_min_rigid(G) True >>> G.add_edge(0,2) >>> is_min_rigid(G) False
Suggested Improvements
Implement
algorithm="numerical".
- pyrigi.graph._rigidity.generic.is_rigid(graph, dim=2, algorithm='default', use_precomputed_pebble_digraph=False, prob=0.0001)[source]¶
Return whether the graph is
dim-rigid.Definitions
- Parameters:
graph (
Graph)dim (
int) – Dimension.algorithm (
str) –If
"graphic"(only ifdim=1), then the graphic matroid is used, namely, it is checked whether the graph is connected.If
"sparsity"(only ifdim=2), then the existence of a spanning (2,3)-tight subgraph and Theorem 1 are used with the pebble game algorithm (Algorithm 2).If
"randomized", a probabilistic check is performed. It may give false negatives (with probability at mostprob), but no false positives. See Theorem 4.If
"numerical", a numerical check on the rigidity matrix rank is performed. SeeFramework.is_inf_rigid()for further details.If
"default", then"graphic"is used fordim=1and"sparsity"fordim=2and"randomized"fordim>=3.use_precomputed_pebble_digraph (
bool) – Only relevant ifalgorithm="sparsity". IfTrue, the pebble digraph present in the cache is used. IfFalse, recompute the pebble digraph. UseTrueonly if you are certain that the pebble game digraph is consistent with the graph.prob (
float) – Only relevant ifalgorithm="randomized". It determines the bound on the probability of the randomized algorithm to yield false negatives.
- Return type:
Examples
>>> from pyrigi import Graph >>> G = Graph([(0,1), (1,2), (2,3), (3,0)]) >>> is_rigid(G) False >>> G.add_edge(0,2) >>> is_rigid(G) True
- pyrigi.graph._rigidity.generic.max_rigid_dimension(graph, algorithm='randomized', prob=0.0001)[source]¶
Compute the maximum dimension in which the graph is generically rigid.
For checking rigidity, the function uses a randomized algorithm, see
is_rigid()for details.Definitions
- Parameters:
graph (
Graph)algorithm (
str) –If
"randomized", the rigidity of the graph is checked in each dimension usingis_rigid()withalgorithm="randomized". Since this is a randomized algorithm, false negatives are possible. However, the actual maximum rigid dimension is never lower than the output of this function.If
"numerical", the rigidity of the graph is checked in each dimension usingis_rigid()withalgorithm="numerical". With this choice of algorithm, we do not have the guarantee that is mentioned above on the maximum rigid dimension.prob (
float) –A bound on the probability for false negatives of the rigidity testing.
Warning: this is not the probability of wrong results in this function, but is just passed on to rigidity testing.
- Return type:
Examples
>>> import pyrigi.graphDB as graphs >>> G = graphs.Complete(3) >>> rigid_dim = max_rigid_dimension(G); rigid_dim oo >>> rigid_dim.is_infinite True
>>> import pyrigi.graphDB as graphs >>> G = graphs.Complete(4) >>> G.add_edges_from([(0,4),(1,4),(2,4)]) >>> max_rigid_dimension(G) 3
Notes
This is done by taking the dimension predicted by the Maxwell count as a starting point and iteratively reducing the dimension until generic rigidity is found. This method returns
sympy.oo(infinity) if and only if the graph is complete. It has the data typeInf.
- pyrigi.graph._rigidity.generic.rigid_components(graph, dim=2, algorithm='default', prob=0.0001)[source]¶
Return the list of the vertex sets of
dim-rigid components.Definitions
- Parameters:
graph (
Graph)dim (
int) – The dimension that is used for the rigidity check.algorithm (
str) –If
"graphic"(only ifdim=1), then the connected components are returned.If
"subgraphs-pebble"(only ifdim=2), then all subgraphs are checked usingis_rigid()withalgorithm="pebble".If
"pebble"(only ifdim=2), thenRd_closure()withalgorithm="pebble"is used.If
"randomized", all subgraphs are checked usingis_rigid()withalgorithm="randomized".If
"numerical", all subgraphs are checked usingis_rigid()withalgorithm="numerical".If
"default", then"graphic"is used fordim=1,"pebble"fordim=2, and"randomized"fordim>=3.prob (
float) –A bound on the probability for false negatives of the rigidity testing when
algorithm="randomized".Warning: this is not the probability of wrong results in this function, but is just passed on to rigidity testing.
- Return type:
Examples
>>> G = Graph([(0,1), (1,2), (2,3), (3,0)]) >>> rigid_components(G, algorithm="randomized") [[0, 1], [0, 3], [1, 2], [2, 3]]
>>> G = Graph([(0,1), (1,2), (2,3), (3,4), (4,5), (5,0), (0,2), (5,3)]) >>> is_rigid(G) False >>> rigid_components(G, algorithm="randomized") [[0, 5], [2, 3], [0, 1, 2], [3, 4, 5]]
Notes
If the graph itself is rigid, it is clearly maximal and is returned. Every edge is part of a rigid component. Isolated vertices form additional rigid components.
For the pebble game algorithm we use the fact that the
R2_closureconsists of edge disjoint cliques, so we only have to determine them.