Node#
- class Node(incoming_node_data=None, degree=None, **attr)#
Bases:
ABCAbstract node that holds incident endpoints and attributes.
Endpoints are stored in CCW order in
_inc; individual subclasses (e.g.,Crossing,Vertex) may impose constraints on length/meaning.- Parameters:
incoming_node_data (Sequence[Any] | None)
degree (int | None)
attr (dict[str, Any])
- attr#
Node attributes (e.g., color, weight).
- Type:
dict[str, Any]
- _inc#
Incident endpoints in CCW order (endpoint objects).
- Type:
list[Any]
- __init__(incoming_node_data=None, degree=None, **attr)#
Initialize a node with optional incident endpoints and attributes.
- Parameters:
incoming_node_data (Sequence[Any] | None) – Existing sequence of incident endpoints; if shorter than
degree, it will be padded withNone.degree (int | None) – Desired degree (len of incident endpoints). If omitted, inferred from
incoming_node_data(or 0 if not provided).**attr (Any) – Node attributes to set.
- Raises:
ValueError – If
incoming_node_datais longer thandegree.- Return type:
None
Methods
__init__([incoming_node_data, degree])Initialize a node with optional incident endpoints and attributes.
append(item)Append an endpoint at the end.
degree()Return the node degree (number of incident endpoints).
Attributes
- attr: dict[str, Any]#
- append(item)#
Append an endpoint at the end.
- Parameters:
item (Any) – Endpoint to append.
- Return type:
None
- degree()#
Return the node degree (number of incident endpoints).
- Returns:
int – Degree.
- Return type:
int