test_isolate.py 555 B

1234567891011121314151617181920212223242526
  1. """Unit tests for the :mod:`networkx.algorithms.isolates` module."""
  2. import networkx as nx
  3. def test_is_isolate():
  4. G = nx.Graph()
  5. G.add_edge(0, 1)
  6. G.add_node(2)
  7. assert not nx.is_isolate(G, 0)
  8. assert not nx.is_isolate(G, 1)
  9. assert nx.is_isolate(G, 2)
  10. def test_isolates():
  11. G = nx.Graph()
  12. G.add_edge(0, 1)
  13. G.add_nodes_from([2, 3])
  14. assert sorted(nx.isolates(G)) == [2, 3]
  15. def test_number_of_isolates():
  16. G = nx.Graph()
  17. G.add_edge(0, 1)
  18. G.add_nodes_from([2, 3])
  19. assert nx.number_of_isolates(G) == 2