sanity_check#

sanity_check(k)#

Perform a series of sanity checks on a given knot object k to validate its structure and properties.

This function performs consistency checks on the structural elements of a knot object, including nodes, endpoints, arcs, faces, and certain mathematical properties like the Euler characteristic. It ensures that the topology of the knot is well-defined and satisfies required constraints.

Parameters:
k: An instance of a knot object. This object is expected to have the properties and methods

required for the checks, such as nodes, endpoints, arcs, faces, degree, and twin.

Returns:

bool: True if all consistency checks pass.

Raises:
ValueError: If any of the checks fail, such as when:
  • Endpoint nodes are not in the set of nodes.

  • Endpoint positions are not valid for the given node degrees.

  • Nodes have unassigned (None) endpoints.

  • Duplicate endpoints are found.

  • The number of endpoints does not match twice the number of arcs.

  • Endpoints do not have valid twins.

  • Euler characteristic is not satisfied.

  • Faces are inconsistent, such as when nodes or endpoints are improperly represented in faces.