is_loop#

is_loop(k: PlanarDiagram, arc_or_endpoint) bool#

Determine whether the given arc or endpoint forms a loop in the planar diagram.

A loop is an arc that connects a node to itself. If given an endpoint, the function checks whether its twin belongs to the same node. If given an arc (set of two endpoints), it checks whether both endpoints belong to the same node. The difference between is_kink() is that kinks are defined at crossings and contain only the endpoint.

Args:

k (PlanarDiagram): The planar diagram. arc_or_endpoint (Union[Endpoint, set[Endpoint], frozenset[Endpoint]]):

The endpoint or arc to check.

Returns:

bool: True if the arc or endpoint forms a loop, False otherwise.

Raises:

TypeError: If arc_or_endpoint is not an Endpoint or a set of endpoints.