MCPcopy Index your code
hub / github.com/clips/pattern / cut

Function cut

pattern/graph/__init__.py:1072–1085  ·  view source on GitHub ↗

Unlinks the given node, but keeps edges intact by connecting the surrounding nodes. If A, B, C, D are nodes and A->B, B->C, B->D, if we then cut B: A->C, A->D.

(graph, node)

Source from the content-addressed store, hash-verified

1070 unlink(graph, node1)
1071
1072def cut(graph, node):
1073 """ Unlinks the given node, but keeps edges intact by connecting the surrounding nodes.
1074 If A, B, C, D are nodes and A->B, B->C, B->D, if we then cut B: A->C, A->D.
1075 """
1076 if not isinstance(node, Node):
1077 node = graph[node]
1078 for e in graph.edges:
1079 if node in (e.node1, e.node2):
1080 for n in node.links:
1081 if e.node1 == node and e.node2 != n:
1082 graph._add_edge_copy(e, node1=n, node2=e.node2)
1083 if e.node2 == node and e.node1 != n:
1084 graph._add_edge_copy(e, node1=e.node1, node2=n)
1085 unlink(graph, node)
1086
1087def insert(graph, node, a, b):
1088 """ Inserts the given node between node a and node b.

Callers

nothing calls this directly

Calls 2

unlinkFunction · 0.85
_add_edge_copyMethod · 0.80

Tested by

no test coverage detected