diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2020-03-16 18:52:12 +0100 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2020-03-16 18:52:12 +0100 |
| commit | d1e994652f6efcdb7b077c8df46903713c60fc66 (patch) | |
| tree | 510fff99c9d9bd1061377b351ead3e74134e9488 /test/core/graph.py | |
| parent | fef944b65f6d3d6db65e62e85480f90887b64f8f (diff) | |
| download | miasm-d1e994652f6efcdb7b077c8df46903713c60fc66.tar.gz miasm-d1e994652f6efcdb7b077c8df46903713c60fc66.zip | |
Graph: add weakly connected components
Diffstat (limited to 'test/core/graph.py')
| -rw-r--r-- | test/core/graph.py | 22 |
1 files changed, 22 insertions, 0 deletions
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])] |