test_hybrid.py 720 B

123456789101112131415161718192021222324
  1. import networkx as nx
  2. def test_2d_grid_graph():
  3. # FC article claims 2d grid graph of size n is (3,3)-connected
  4. # and (5,9)-connected, but I don't think it is (5,9)-connected
  5. G = nx.grid_2d_graph(8, 8, periodic=True)
  6. assert nx.is_kl_connected(G, 3, 3)
  7. assert not nx.is_kl_connected(G, 5, 9)
  8. (H, graphOK) = nx.kl_connected_subgraph(G, 5, 9, same_as_graph=True)
  9. assert not graphOK
  10. def test_small_graph():
  11. G = nx.Graph()
  12. G.add_edge(1, 2)
  13. G.add_edge(1, 3)
  14. G.add_edge(2, 3)
  15. assert nx.is_kl_connected(G, 2, 2)
  16. H = nx.kl_connected_subgraph(G, 2, 2)
  17. (H, graphOK) = nx.kl_connected_subgraph(
  18. G, 2, 2, low_memory=True, same_as_graph=True
  19. )
  20. assert graphOK