subgraph test
This commit is contained in:
@@ -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"}
|
||||
|
||||
Reference in New Issue
Block a user