Cidr4 merge algorithm #5

Merged
PavelPatsey merged 91 commits from CIDR4_merge_algorithm into main 2025-01-27 22:05:39 +03:00
Showing only changes of commit 75d400f52e - Show all commits
+14
View File
@@ -0,0 +1,14 @@
```python
def find_subnets(nodes: list[Node]) -> list[tuple[Node, Node]]:
subnets = []
for i, (a, b) in enumerate(zip(nodes, nodes[1:])):
parent_node, dip = merge_two_nodes(a, b)
if parent_node == a or parent_node == b:
subnets.append((a, b))
return subnets
def ensure_no_subnets(nodes: list[Node]):
if subnets := find_subnets(nodes):
raise Cidr4MergerError(f"There are subnets! {subnets=}")
```