OrientedPlanarDiagram#
- class OrientedPlanarDiagram(incoming_diagram_data=None, **attr)#
Bases:
PlanarDiagram
- __init__(incoming_diagram_data=None, **attr)#
Initialize a planar diagram.
If no data is provided, an empty diagram is created. Otherwise, the diagram is initialized using the provided data.
- Parameters:
incoming_diagram_data (Optional[Any]) – Initial data to construct the diagram (currently not implemented).
attr – Additional attributes such as name, framing, etc.
Methods
__init__
([incoming_diagram_data])Initialize a planar diagram.
add_crossing
(crossing_for_adding, **attr)Add or update a crossing in the diagram.
add_crossings_from
(crossings_for_adding, **attr)Add or update a bunch (iterable) of crossings and update the crossings attributes.
add_node
(node_for_adding, create_using[, degree])Add a node to the diagram.
add_nodes_from
(nodes_for_adding[, create_using])Add or update a list of nodes to the diagram.
add_vertex
(vertex_for_adding[, degree])Add or update a crossing and update the crossing attributes.
add_vertices_from
(vertices_for_adding, **attr)Add or update a crossing and update the crossing attributes.
add_virtual_crossing
(crossing_for_adding, **attr)Add or update a crossing and update the crossing attributes.
Add or update a crossing and update the crossing attributes.
clear
()Remove all data from the diagram, resetting it to an empty state.
convert_node
(node_for_converting, node_type)Convert node type, e.g. from vertex to crossing.
convert_nodes
(node_for_converting, node_type)copy
([copy_using])Return a shallow copy of the diagram.
degree
(node)endpoint_from_pair
(endpoint_pair)Returns the Endpoint instance of the pair (node, position).
is_framed
()is_oriented
()permute_node
(node, permutation)Permute the endpoints of the node of knot k.
relabel_nodes
(mapping)Relabels the nodes, can be a partial map
remove_arc
(arc_for_removing)remove_arcs_from
(arcs_for_removing)remove_endpoint
(endpoint_for_removal)remove_endpoints_from
(endpoints_for_removal)remove_node
(node_for_removing[, ...])Remove the node.
remove_nodes_from
(nodes_for_removal[, ...])set_arc
(arc_for_setting, **attr)Set the arc (v_endpoint, u_endpoint), which equals setting the two endpoints adj(u_endpoint) = v_endpoint and vice-versa.
set_arcs_from
(arcs_for_adding, **attr)Set the list of arcs.
set_endpoint
(endpoint_for_setting, ...[, ...])Set the endpoint to the adjacent endpoint and update the endpoint attributes.
twin
(endpoint)Return the opposite endpoint (twin) of an endpoint.
Attributes
Return a view of the diagram's arcs, represented as pairs of endpoints.
Return a view of all crossings in the diagram.
Return a view of the diagram's endpoints.
Return a view of the diagram's faces (regions enclosed by arcs), which are given as tuples of endpoints.
Blackboard framing number of planar diagram.
Name identifier of planar diagram.
Return a view of the diagram's nodes, providing adjacency information.
number_of_arcs
number_of_crossings
number_of_endpoints
number_of_nodes
number_of_vertices
number_of_virtual_crossings
Node object holding the adjacencies of each crossing.
Return a view of all virtual crossings in the diagram.
- add_crossing(crossing_for_adding, **attr)#
Add or update a crossing in the diagram.
- Parameters:
crossing_for_adding (Hashable) – The crossing to add or update.
attr – Additional attributes for the crossing (color, weight, …)
- add_crossings_from(crossings_for_adding, **attr)#
Add or update a bunch (iterable) of crossings and update the crossings attributes. Crossings can be any hashable objects.
- add_node(node_for_adding, create_using: type, degree=None, **attr)#
Add a node to the diagram.
- Parameters:
node_for_adding (Hashable) – A hashable object representing the node.
create_using (type) – The node type (e.g., Vertex, Crossing).
degree (Optional[int]) – The degree of the node (optional).
attr – Additional attributes to store for the node.
- add_nodes_from(nodes_for_adding, create_using=None, **attr)#
Add or update a list of nodes to the diagram.
- Parameters:
nodes_for_adding (List[Hashable]) – A list/set/tuple of hashable objects representing the nodes.
create_using (type) – The node type (e.g., Vertex, Crossing).
attr – Additional attributes to store for the node.
- add_vertex(vertex_for_adding, degree=None, **attr)#
Add or update a crossing and update the crossing attributes. A crossing can be any hashable object.
- add_vertices_from(vertices_for_adding, **attr)#
Add or update a crossing and update the crossing attributes. A crossing can be any hashable object.
- add_virtual_crossing(crossing_for_adding, **attr)#
Add or update a crossing and update the crossing attributes. A crossing can be any hashable object.
- add_virtual_crossings_from(crossings_for_adding, **attr)#
Add or update a crossing and update the crossing attributes. A crossing can be any hashable object.
- property arcs#
Return a view of the diagram’s arcs, represented as pairs of endpoints.
- clear()#
Remove all data from the diagram, resetting it to an empty state.
- convert_node(node_for_converting, node_type: type)#
Convert node type, e.g. from vertex to crossing
- copy(copy_using=None, **attr)#
Return a shallow copy of the diagram.
- Parameters:
copy_using – The class type of the new diagram (defaults to the same type as self).
Serves for converting e.g. oriented to unoriented diagrams. :type copy_using: Optional[type] :return: A new instance of the planar diagram with the same structure and attributes (shallow copy). :rtype: PlanarDiagram
- property crossings#
Return a view of all crossings in the diagram.
- Returns:
A filtered node view containing only crossings.
- Return type:
- endpoint_from_pair(endpoint_pair)#
Returns the Endpoint instance of the pair (node, position).
- Parameters:
endpoint_pair – a pair (node, position)
- Returns:
Endpoint instance
- property endpoints#
Return a view of the diagram’s endpoints.
- property faces#
Return a view of the diagram’s faces (regions enclosed by arcs), which are given as tuples of endpoints.
- property framing#
Blackboard framing number of planar diagram.
- property name#
Name identifier of planar diagram.
- property nodes#
Return a view of the diagram’s nodes, providing adjacency information.
- permute_node(node, permutation)#
Permute the endpoints of the node of knot k. For example, if p = {0: 0, 1: 2, 2: 3, 3: 1} (or p = [0,2,2,1]), and if node has endpoints [a, b, c, d] (ccw) then the new endpoints will be [a, d, b, c]. :param node: node of which we permute its endpoints :param permutation: permutation given as a dict or list/tuple :return: TODO: are there problems regarding endpoint attributes? TODO: check if it works for loops (probably does not)
- relabel_nodes(mapping)#
Relabels the nodes, can be a partial map
- remove_node(node_for_removing, remove_incident_endpoints=True)#
Remove the node. :param node_for_removing: :param remove_incident_endpoints: use with care, if False, it breaks the planar structure :return: planar diagram without node
- set_arc(arc_for_setting, **attr)#
Set the arc (v_endpoint, u_endpoint), which equals setting the two endpoints adj(u_endpoint) = v_endpoint and vice-versa.
- set_arcs_from(arcs_for_adding, **attr)#
Set the list of arcs. Can also add arcs as a string, e.g. “a0b1,a1b0” in this case also vertices are added if the nodes do not yet exist.
- Parameters:
arcs_for_adding – a iterable of tuples (v_endpoint, u_endpoint) or a string like “a1b4,c2d3”.
- Returns:
None
- set_endpoint(endpoint_for_setting, adjacent_endpoint, create_using=<class 'knotpy.classes.endpoint.Endpoint'>, **attr)#
Set the endpoint to the adjacent endpoint and update the endpoint attributes.
- Parameters:
endpoint_for_setting – Endpoint object or tuple (crossing name, position)
adjacent_endpoint – overwrite the endpoint with adjacent_endpoint (Endpoint object or tuple (crossing name, position))
create_using – if the type is not Endpoint (or IngoingEndpoint or OutgoingEndpoint), the class should be given, be default Endpoint is assumed if endpoint_for_setting is given as a tuple. If an Endpoint instance is given instead of a class, the instance type is used with attributes copied.
attr – additional attributes of the (adjacent) endpoint
- Returns:
None
- twin(endpoint) Endpoint #
Return the opposite endpoint (twin) of an endpoint. Both endpoints form an arc.
- Parameters:
endpoint – Endpoint instance or pair (node, position)
- Returns:
twin endpoint instance
- property vertices#
Node object holding the adjacencies of each crossing.
- property virtual_crossings#
Return a view of all virtual crossings in the diagram.
- Returns:
A filtered node view containing only virtual crossings.
- Return type: