/usr/lib/python2.7/dist-packages/networkx/algorithms/components/tests/test_semiconnected.py is in python-networkx 1.11-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | from itertools import chain
import networkx as nx
from nose.tools import *
class TestIsSemiconnected(object):
def test_undirected(self):
assert_raises(nx.NetworkXNotImplemented, nx.is_semiconnected,
nx.Graph())
assert_raises(nx.NetworkXNotImplemented, nx.is_semiconnected,
nx.MultiGraph())
def test_empty(self):
assert_raises(nx.NetworkXPointlessConcept, nx.is_semiconnected,
nx.DiGraph())
assert_raises(nx.NetworkXPointlessConcept, nx.is_semiconnected,
nx.MultiDiGraph())
def test_single_node_graph(self):
G = nx.DiGraph()
G.add_node(0)
ok_(nx.is_semiconnected(G))
def test_path(self):
G = nx.path_graph(100, create_using=nx.DiGraph())
ok_(nx.is_semiconnected(G))
G.add_edge(100, 99)
ok_(not nx.is_semiconnected(G))
def test_cycle(self):
G = nx.cycle_graph(100, create_using=nx.DiGraph())
ok_(nx.is_semiconnected(G))
G = nx.path_graph(100, create_using=nx.DiGraph())
G.add_edge(0, 99)
ok_(nx.is_semiconnected(G))
def test_tree(self):
G = nx.DiGraph()
G.add_edges_from(chain.from_iterable([(i, 2 * i + 1), (i, 2 * i + 2)]
for i in range(100)))
ok_(not nx.is_semiconnected(G))
def test_dumbbell(self):
G = nx.cycle_graph(100, create_using=nx.DiGraph())
G.add_edges_from((i + 100, (i + 1) % 100 + 100) for i in range(100))
ok_(not nx.is_semiconnected(G)) # G is disconnected.
G.add_edge(100, 99)
ok_(nx.is_semiconnected(G))
def test_alternating_path(self):
G = nx.DiGraph(chain.from_iterable([(i, i - 1), (i, i + 1)]
for i in range(0, 100, 2)))
ok_(not nx.is_semiconnected(G))
|