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)
| 1085 | unlink(graph, node) |
| 1086 | |
| 1087 | def 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…