subgraph test

This commit is contained in:
John Lancaster
2026-02-21 15:09:38 -06:00
parent b2b90555c2
commit 88a4064a71
2 changed files with 35 additions and 7 deletions

View File

@@ -12,6 +12,10 @@ class TestDAGInit:
g = DAG()
assert len(g) == 0
def test_reverse(self) -> None:
g = DAG()
assert len(g.reverse) == 0
def test_default_callbacks_none(self) -> None:
g = DAG()
assert g.on_add is None
@@ -310,3 +314,17 @@ class TestDAGComplexScenarios:
assert 2 in g[1]
assert 4 in g[2]
assert len(g) == 3
def test_subgraphs(self) -> None:
g = DAG[str]()
g["A"] += "B"
g["B"] += "C"
g["B"] += "D"
g["D"] += "E"
g["E"] += "F"
assert len(g) == 5
sub = g.subgraph("D")
assert len(sub) == 2
assert set(sub["D"]) == {"E"}
assert set(sub["E"]) == {"F"}