Пример #1
0
 def test_undirected_weighted_star(self):
     G = nx.Graph()
     G.add_edge(1, 2, weight=1)
     G.add_edge(1, 3, weight=2)
     centrality = nx.local_reaching_centrality(G, 1, weight='weight',
                                               normalized=False)
     assert_equal(centrality, 1.5)
Пример #2
0
 def test_undirected_weighted_star(self):
     G = nx.Graph()
     G.add_weighted_edges_from([(1, 2, 1), (1, 3, 2)])
     centrality = nx.local_reaching_centrality(G,
                                               1,
                                               normalized=False,
                                               weight='weight')
     assert_equal(centrality, 1.5)
Пример #3
0
 def test_undirected_weighted_star(self):
     G = nx.Graph()
     G.add_edge(1, 2, weight=1)
     G.add_edge(1, 3, weight=2)
     centrality = nx.local_reaching_centrality(G,
                                               1,
                                               weight='weight',
                                               normalized=False)
     assert_equal(centrality, 1.5)
Пример #4
0
 def test_negatively_weighted(self):
     with pytest.raises(nx.NetworkXError):
         G = nx.Graph()
         G.add_weighted_edges_from([(0, 1, -2), (1, 2, +1)])
         nx.local_reaching_centrality(G, 0, weight='weight')
Пример #5
0
 def test_non_positive_weights(self):
     with pytest.raises(nx.NetworkXError):
         G = nx.DiGraph()
         G.add_weighted_edges_from([(0, 1, 0)])
         nx.local_reaching_centrality(G, 0, weight='weight')
Пример #6
0
 def test_non_positive_weights(self):
     G = nx.DiGraph()
     G.add_weighted_edges_from([(0, 1, 0)])
     nx.local_reaching_centrality(G, 0, weight='weight')
Пример #7
0
 def test_undirected_weighted_star(self):
     G = nx.Graph()
     G.add_weighted_edges_from([(1, 2, 1), (1, 3, 2)])
     centrality = nx.local_reaching_centrality(G, 1, normalized=False, weight='weight')
     assert_equal(centrality, 1.5)
Пример #8
0
 def test_negatively_weighted(self):
     G = nx.Graph()
     G.add_weighted_edges_from([(0, 1, -2), (1, 2, +1)])
     nx.local_reaching_centrality(G, 0, weight='weight')
Пример #9
0
 def test_non_positive_weights(self):
     G = nx.DiGraph()
     G.add_weighted_edges_from([(0, 1, 0)])
     nx.local_reaching_centrality(G, 0, weight='weight')
Пример #10
0
 def test_undirected_unweighted_star(self):
     G = nx.star_graph(2)
     centrality = nx.local_reaching_centrality(G, 1, normalized=False)
     assert_equal(centrality, 0.75)
Пример #11
0
 def test_negatively_weighted(self):
     G = nx.Graph()
     G.add_weighted_edges_from([(0, 1, -2), (1, 2, +1)])
     nx.local_reaching_centrality(G, 0, weight='weight')
Пример #12
0
 def test_undirected_unweighted_star(self):
     G = nx.star_graph(2)
     centrality = nx.local_reaching_centrality(G, 1, normalized=False)
     assert_equal(centrality, 0.75)