File: test_hybrid.py

package info (click to toggle)
python-networkx 1.9%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,052 kB
  • ctags: 3,986
  • sloc: python: 52,132; makefile: 176
file content (24 lines) | stat: -rw-r--r-- 811 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from nose.tools import *
import networkx as nx

def test_2d_grid_graph():
    # FC article claims 2d grid graph of size n is (3,3)-connected 
    # and (5,9)-connected, but I don't think it is (5,9)-connected
    G=nx.grid_2d_graph(8,8,periodic=True)
    assert_true(nx.is_kl_connected(G,3,3))
    assert_false(nx.is_kl_connected(G,5,9))
    (H,graphOK)=nx.kl_connected_subgraph(G,5,9,same_as_graph=True)
    assert_false(graphOK)

def test_small_graph():
    G=nx.Graph()
    G.add_edge(1,2)
    G.add_edge(1,3)
    G.add_edge(2,3)
    assert_true(nx.is_kl_connected(G,2,2))
    H=nx.kl_connected_subgraph(G,2,2)
    (H,graphOK)=nx.kl_connected_subgraph(G,2,2,
                                         low_memory=True,
                                         same_as_graph=True)
    assert_true(graphOK)