Пример #1
0
 def test_k_factor2(self):
     g = gen.complete_graph(6)
     g_kf = reg.k_factor(g, 3)
     for edge in g_kf.edges():
         assert g.has_edge(edge[0], edge[1])
     for _, degree in g_kf.degree():
         assert degree == 3
Пример #2
0
 def test_k_factor1(self):
     g = gen.grid_2d_graph(4, 4)
     g_kf = reg.k_factor(g, 2)
     for edge in g_kf.edges():
         assert g.has_edge(edge[0], edge[1])
     for _, degree in g_kf.degree():
         assert degree == 2
Пример #3
0
 def test_k_factor5(self):
     g = gen.complete_graph(6)
     # small k to exercise SmallKGadget
     g_kf = reg.k_factor(g, 2)
     for edge in g_kf.edges():
         assert g.has_edge(edge[0], edge[1])
     for _, degree in g_kf.degree():
         assert degree == 2
Пример #4
0
 def test_k_factor_trivial(self):
     g = gen.cycle_graph(4)
     f = reg.k_factor(g, 2)
     assert g.edges == f.edges
Пример #5
0
 def test_k_factor4(self):
     g = gen.lattice.hexagonal_lattice_graph(4, 4)
     # Perfect matching doesn't exist for 4,4 hexagonal lattice graph
     with pytest.raises(nx.NetworkXUnfeasible):
         reg.k_factor(g, 2)
Пример #6
0
 def test_k_factor3(self):
     g = gen.grid_2d_graph(4, 4)
     with pytest.raises(nx.NetworkXUnfeasible):
         reg.k_factor(g, 3)