From d1e994652f6efcdb7b077c8df46903713c60fc66 Mon Sep 17 00:00:00 2001 From: Fabrice Desclaux Date: Mon, 16 Mar 2020 18:52:12 +0100 Subject: Graph: add weakly connected components --- test/core/graph.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test') diff --git a/test/core/graph.py b/test/core/graph.py index 3db5e523..ff27b780 100644 --- a/test/core/graph.py +++ b/test/core/graph.py @@ -286,3 +286,25 @@ assert sols[0] == {j1: 1, j2: 2, j3: 3} + + +# Test replace_node +graph = DiGraph() +graph.add_edge(1, 2) +graph.add_edge(2, 2) +graph.add_edge(2, 3) + +graph.replace_node(2, 4) +assert graph.nodes() == set([1, 3, 4]) +assert sorted(graph.edges()) == [(1, 4), (4, 3), (4, 4)] + + + +# Test compute_weakly_connected_components +graph = DiGraph() +graph.add_edge(1, 2) +graph.add_edge(2, 2) +graph.add_edge(3, 4) + +components = graph.compute_weakly_connected_components() +assert sorted(components) == [set([1, 2]), set([3, 4])] -- cgit 1.4.1