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

Function insert

pattern/graph/__init__.py:1087–1104  ·  view source on GitHub ↗

Inserts the given node between node a and node b. If A, B, C are nodes and A->B, if we then insert C: A->C, C->B.

(graph, node, a, b)

Source from the content-addressed store, hash-verified

1085 unlink(graph, node)
1086
1087def insert(graph, node, a, b):
1088 """ Inserts the given node between node a and node b.
1089 If A, B, C are nodes and A->B, if we then insert C: A->C, C->B.
1090 """
1091 if not isinstance(node, Node):
1092 node = graph[node]
1093 if not isinstance(a, Node):
1094 a = graph[a]
1095 if not isinstance(b, Node):
1096 b = graph[b]
1097 for e in graph.edges:
1098 if e.node1 == a and e.node2 == b:
1099 graph._add_edge_copy(e, node1=a, node2=node)
1100 graph._add_edge_copy(e, node1=node, node2=b)
1101 if e.node1 == b and e.node2 == a:
1102 graph._add_edge_copy(e, node1=b, node2=node)
1103 graph._add_edge_copy(e, node1=node, node2=a)
1104 unlink(graph, a, b)
1105
1106#--- HTML CANVAS GRAPH RENDERER --------------------------------------------------------------------
1107

Callers

nothing calls this directly

Calls 2

unlinkFunction · 0.85
_add_edge_copyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…