ioftools / networkxMiCe / networkxmaster / networkx / algorithms / tests / test_hybrid.py @ 5cef0f13
History  View  Annotate  Download (843 Bytes)
1 
from nose.tools import * 

2 
import networkx as nx 
3  
4  
5 
def test_2d_grid_graph(): 
6 
# FC article claims 2d grid graph of size n is (3,3)connected

7 
# and (5,9)connected, but I don't think it is (5,9)connected

8 
G = nx.grid_2d_graph(8, 8, periodic=True) 
9 
assert_true(nx.is_kl_connected(G, 3, 3)) 
10 
assert_false(nx.is_kl_connected(G, 5, 9)) 
11 
(H, graphOK) = nx.kl_connected_subgraph(G, 5, 9, same_as_graph=True) 
12 
assert_false(graphOK) 
13  
14  
15 
def test_small_graph(): 
16 
G = nx.Graph() 
17 
G.add_edge(1, 2) 
18 
G.add_edge(1, 3) 
19 
G.add_edge(2, 3) 
20 
assert_true(nx.is_kl_connected(G, 2, 2)) 
21 
H = nx.kl_connected_subgraph(G, 2, 2) 
22 
(H, graphOK) = nx.kl_connected_subgraph(G, 2, 2, 
23 
low_memory=True,

24 
same_as_graph=True)

25 
assert_true(graphOK) 