freeze#

freeze(k, inplace=True)#

Freeze a planar diagram so it cannot be modified.

Freezing monkey-patches mutating methods on the instance to a dummy method that raises RuntimeError. The diagram’s data stays intact.

Parameters:
Returns:

PlanarDiagram – The frozen diagram (k or its copy).

Return type:

PlanarDiagram

Examples

>>> from knotpy.classes.planardiagram import PlanarDiagram
>>> d = PlanarDiagram()
>>> d.add_vertices_from(["a", "b"])
>>> freeze(d)
PlanarDiagram(...)
>>> d.is_frozen()
True
>>> d.add_vertex("c")
Traceback (most recent call last):
    ...
RuntimeError: Frozen diagrams cannot be modified