/usr/lib/python3/dist-packages/networkx/generators/tests/test_stochastic.py is in python3-networkx 1.11-2.
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 | from nose.tools import assert_true, assert_equal, raises
import networkx as nx
def test_stochastic():
G=nx.DiGraph()
G.add_edge(0,1)
G.add_edge(0,2)
S=nx.stochastic_graph(G)
assert_true(nx.is_isomorphic(G,S))
assert_equal(sorted(S.edges(data=True)),
[(0, 1, {'weight': 0.5}),
(0, 2, {'weight': 0.5})])
S=nx.stochastic_graph(G,copy=True)
assert_equal(sorted(S.edges(data=True)),
[(0, 1, {'weight': 0.5}),
(0, 2, {'weight': 0.5})])
def test_stochastic_ints():
G=nx.DiGraph()
G.add_edge(0,1,weight=1)
G.add_edge(0,2,weight=1)
S=nx.stochastic_graph(G)
assert_equal(sorted(S.edges(data=True)),
[(0, 1, {'weight': 0.5}),
(0, 2, {'weight': 0.5})])
@raises(nx.NetworkXNotImplemented)
def test_stochastic_graph_input():
S = nx.stochastic_graph(nx.Graph())
@raises(nx.NetworkXNotImplemented)
def test_stochastic_multigraph_input():
S = nx.stochastic_graph(nx.MultiGraph())
|