test_intersection.py 819 B

12345678910111213141516171819202122232425262728
  1. import pytest
  2. import networkx as nx
  3. class TestIntersectionGraph:
  4. def test_random_intersection_graph(self):
  5. G = nx.uniform_random_intersection_graph(10, 5, 0.5)
  6. assert len(G) == 10
  7. def test_k_random_intersection_graph(self):
  8. G = nx.k_random_intersection_graph(10, 5, 2)
  9. assert len(G) == 10
  10. def test_k_random_intersection_graph_seeded(self):
  11. G = nx.k_random_intersection_graph(10, 5, 2, seed=1234)
  12. assert len(G) == 10
  13. def test_general_random_intersection_graph(self):
  14. G = nx.general_random_intersection_graph(10, 5, [0.1, 0.2, 0.2, 0.1, 0.1])
  15. assert len(G) == 10
  16. pytest.raises(
  17. ValueError,
  18. nx.general_random_intersection_graph,
  19. 10,
  20. 5,
  21. [0.1, 0.2, 0.2, 0.1],
  22. )