Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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')
Exemplo n.º 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')
Exemplo n.º 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')
Exemplo n.º 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)
Exemplo n.º 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')
Exemplo n.º 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')
Exemplo n.º 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)
Exemplo n.º 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')
Exemplo n.º 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)