sanity_check#
- sanity_check(k)#
Perform a consistency check on the planar diagram k.
This function verifies the structural integrity of the planar diagram by checking for issues such as None endpoints, repeated endpoints, mismatched endpoint counts, and incorrect twin assignments (twins are pairs of endpoints of the same arc connecting two nodes).
- Parameters:
k (PlanarDiagram) – The planar diagram to check.
- Raises:
ValueError – If any of the following conditions are met: - A node has an endpoint set to None. - An endpoint appears more than once. - The number of endpoints does not match twice the number of arcs. - Not all nodes have associated endpoints. - An endpoint’s twin does not correctly reference back to the original.
- Returns:
True if all checks pass.
- Return type:
bool