test_utils.py 706 B

12345678910111213141516171819202122232425262728
  1. """Unit tests for the :mod:`networkx.algorithms.community.utils` module.
  2. """
  3. import networkx as nx
  4. def test_is_partition():
  5. G = nx.empty_graph(3)
  6. assert nx.community.is_partition(G, [{0, 1}, {2}])
  7. assert nx.community.is_partition(G, ({0, 1}, {2}))
  8. assert nx.community.is_partition(G, ([0, 1], [2]))
  9. assert nx.community.is_partition(G, [[0, 1], [2]])
  10. def test_not_covering():
  11. G = nx.empty_graph(3)
  12. assert not nx.community.is_partition(G, [{0}, {1}])
  13. def test_not_disjoint():
  14. G = nx.empty_graph(3)
  15. assert not nx.community.is_partition(G, [{0, 1}, {1, 2}])
  16. def test_not_node():
  17. G = nx.empty_graph(3)
  18. assert not nx.community.is_partition(G, [{0, 1}, {3}])