endpoint#

Functions

ensure_arc(k, arc_like)

Convert various arc-like inputs into a frozenset of two Endpoints.

ensure_endpoint(k, ep_like)

Return an Endpoint for an endpoint-like input.

Classes

Endpoint(node, position, **attr)

Endpoint at a given node and position, with optional attributes.

IngoingEndpoint(node, position, **attr)

Oriented incoming endpoint.

OutgoingEndpoint(node, position, **attr)

Oriented outgoing endpoint.

class Endpoint(node, position, **attr)#

Bases: object

Endpoint at a given node and position, with optional attributes.

Endpoints are incidences of nodes in a planar diagram. Oriented variants are represented by subclasses IngoingEndpoint and OutgoingEndpoint.

Parameters:
  • node (Hashable)

  • position (int)

  • attr (dict[str, Any])

node#

Node identifier.

Type:

Hashable

position#

Position index at the node (counter-clockwise order).

Type:

int

attr#

Arbitrary endpoint attributes (e.g., colors).

Type:

dict[str, Any]

node: Hashable#
position: int#
attr: dict[str, Any]#
get(key, _Endpoint__default=None)#

Return an attribute value with a default.

Parameters:
  • key (str) – Attribute key.

  • __default – Default value if key is missing.

  • _Endpoint__default (Any)

Returns:

Any – Stored value or __default.

Return type:

Any

static reverse_type()#

Return the opposite endpoint type.

Returns:

type[Endpoint] – For base Endpoint, returns Endpoint itself.

Return type:

type[Endpoint]

static is_oriented()#

Return whether this endpoint type is oriented.

Returns:

boolFalse for base Endpoint.

Return type:

bool

class IngoingEndpoint(node, position, **attr)#

Bases: Endpoint

Oriented incoming endpoint.

Parameters:
  • node (Hashable)

  • position (int)

  • attr (dict[str, Any])

static reverse_type()#

Return the opposite endpoint type.

Returns:

type[OutgoingEndpoint] – The outgoing endpoint class.

Return type:

type[OutgoingEndpoint]

static is_oriented()#

Return whether the endpoint type is oriented.

Returns:

bool – Always True.

Return type:

bool

class OutgoingEndpoint(node, position, **attr)#

Bases: Endpoint

Oriented outgoing endpoint.

Parameters:
  • node (Hashable)

  • position (int)

  • attr (dict[str, Any])

static reverse_type()#

Return the opposite endpoint type.

Returns:

type[IngoingEndpoint] – The ingoing endpoint class.

Return type:

type[IngoingEndpoint]

static is_oriented()#

Return whether the endpoint type is oriented.

Returns:

bool – Always True.

Return type:

bool