コード例 #1
0
def test_non_randomness():
    try:
        import numpy.testing as npt
    except ImportError:
        raise SkipTest('numpy not available.')
    G = nx.karate_club_graph()
    npt.assert_almost_equal(nx.non_randomness(G, 2)[0], 11.7, decimal=2)
    npt.assert_almost_equal(nx.non_randomness(G)[0], 7.21,
                            decimal=2)  # infers 3 communities
コード例 #2
0
def test_non_randomness():
    G = nx.karate_club_graph()
    npt.assert_almost_equal(nx.non_randomness(G, 2)[0], 11.7, decimal=2)
    npt.assert_almost_equal(nx.non_randomness(G)[0], 7.21,
                            decimal=2)  # infers 3 communities
コード例 #3
0
def test_non_connected():
    G = nx.Graph()
    G.add_edge(1, 2)
    G.add_node(3)
    with pytest.raises(nx.NetworkXException):
        nx.non_randomness(G)
コード例 #4
0
def test_self_loops():
    G = nx.Graph()
    G.add_edge(1, 2)
    G.add_edge(1, 1)
    with pytest.raises(nx.NetworkXError):
        nx.non_randomness(G)
コード例 #5
0
def test_non_randomness(k, weight, expected):
    G = nx.karate_club_graph()
    np.testing.assert_almost_equal(nx.non_randomness(G, k, weight)[0],
                                   expected,
                                   decimal=2)