OrientedSpatialGraph#

class OrientedSpatialGraph(**attr)#

Bases: SpatialGraph

__init__(**attr)#

Initialize a planar diagram. :param incoming_diagram_data: not implemented :param attr: graph attributes (name, framing, …)

Methods

__init__(**attr)

Initialize a planar diagram.

add_bivalent_vertex(...)

Add or update a bivalent node and update the node attributes.

add_bivalent_vertices(...)

Add or update a bunch (iterable) of bivalent nodes and update the node attributes.

add_crossing(crossing_for_adding, **attr)

Add or update a crossing and update the crossing attributes.

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 of type create_using with optional degree and attributes.

add_nodes_from(nodes_for_adding[, create_using])

Add or update a bunch (iterable) of nodes and update attributes.

add_vertex(vertex_for_adding[, degree])

Add or update a vertex.

add_vertices_from(vertices_for_adding, **attr)

Add or update a bunch (iterable) of crossings and update the crossings attributes.

clear()

Remove/clear all diagram data.

copy([copy_using])

Return shallow copy of the diagram.

degree(node)

get_endpoint(node, position)

Return the endpoint Endpoint(node, position)

get_endpoint_from_pair(endpoint_pair)

Returns the Endpoint instance of the pair (node, position).

is_oriented()

jump_over_node(endpoint)

param endpoint:

Endpoint instance or pair (node, position)

permute_node(node, permutation)

Permute the endpoints of the node of knot k.

py3_cmp(other[, compare_attr])

Compare diagrams.

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[, ...])

rename_nodes(mapping_dict)

rotate_node_ccw(node[, ccw_shift])

Permute the positions of endpoints of the node and take care of adjacent nodes.

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.

to_oriented_class()

to_unoriented_class()

twin(endpoint)

Return the opposite endpoint (twin) of an endpoint.

Attributes

arcs

Node object holding the adjacencies of each node.

bivalent_vertices

Node object holding the adjacencies of each node.

crossings

Node object holding the adjacencies of each node.

endpoints

Node object holding the adjacencies of each node.

faces

Node object holding the adjacencies of each node.

framing

Blackboard framing number of planar diagram.

name

Name identifier of planar diagram.

nodes

Node object holding the adjacencies of each node.

number_of_arcs

number_of_crossings

number_of_endpoints

number_of_nodes

number_of_vertices

vertices

Node object holding the adjacencies of each node.

add_bivalent_vertex(bivalent_vertex_for_adding, **attr)#

Add or update a bivalent node and update the node attributes. A node can be any hashable object.

add_bivalent_vertices(bivalent_nodes_for_adding, **attr)#

Add or update a bunch (iterable) of bivalent nodes and update the node attributes. Nodes can be any hashable objects.

add_crossing(crossing_for_adding, **attr)#

Add or update a crossing and update the crossing attributes. A crossing can be any hashable object.

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 of type create_using with optional degree and attributes.

Parameters:
  • node_for_adding – any hashable object

  • create_using – the node type

  • degree – optional degree of the node

  • attr

Returns:

None

add_nodes_from(nodes_for_adding, create_using=None, **attr)#

Add or update a bunch (iterable) of nodes and update attributes.

Parameters:
  • nodes_for_adding – an iterable of nodes, which can be any hashable object. If a dictionary of is given, where the values are Node classes, the newly added nodes will inherit the degree and attributes of nodes in the dict.

  • create_using – if nodes_for_adding does not consist of a dictionary of Node instances, the node type must be given in this parameter (e.g. Vertex, Crossing,…)

  • attr – the nodes attribute will be updated with these values.

Returns:

None

add_vertex(vertex_for_adding, degree=None, **attr)#

Add or update a vertex. A vertex can be any hashable object.

add_vertices_from(vertices_for_adding, **attr)#

Add or update a bunch (iterable) of crossings and update the crossings attributes. Crossings can be any hashable objects.

property arcs#

Node object holding the adjacencies of each node.

property bivalent_vertices#

Node object holding the adjacencies of each node.

clear()#

Remove/clear all diagram data.

copy(copy_using=None)#

Return shallow copy of the diagram. :param copy_using: the planar diagram type of the new diagram :return: shallow copy

property crossings#

Node object holding the adjacencies of each node.

property endpoints#

Node object holding the adjacencies of each node.

property faces#

Node object holding the adjacencies of each node.

property framing#

Blackboard framing number of planar diagram.

get_endpoint(node, position)#

Return the endpoint Endpoint(node, position)

get_endpoint_from_pair(endpoint_pair)#

Returns the Endpoint instance of the pair (node, position).

Parameters:

endpoint_pair – a pair (node, position)

Returns:

Endpoint instance

jump_over_node(endpoint)#
Parameters:

endpoint – Endpoint instance or pair (node, position)

Returns:

endpoint or None

property name#

Name identifier of planar diagram.

property nodes#

Node object holding the adjacencies of each node.

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)

py3_cmp(other, compare_attr=False)#

Compare diagrams. Replaces obsolete __cmp__ method.

Parameters:
  • other

  • compare_attr – do we compare also the node attributes (name, color, …)

Returns:

1 if self > other, -1 if self < other, and 0 otherwise.

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

rotate_node_ccw(node, ccw_shift=1)#

Permute the positions of endpoints of the node and take care of adjacent nodes. For example, if we rotate a 4-valent node by 90 degrees, the positions change from (0, 1, 2, 3) to (3, 0, 1, 2), so the permutation should be {0: 3, 1: 0, 2: 1, 3: 2}.

Parameters:
  • node – the node of which endpoints we permute

  • ccw_shift – a dict or list object

Returns:

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.

Parameters:

arcs_for_adding – a iterable of tuples (v_endpoint, u_endpoint)

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 endpoint are added

Returns:

None

twin(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 node.