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)
| 1070 | unlink(graph, node1) |
| 1071 | |
| 1072 | def 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 | |
| 1087 | def insert(graph, node, a, b): |
| 1088 | """ Inserts the given node between node a and node b. |
nothing calls this directly
no test coverage detected