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)
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)
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')
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')
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')
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')
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)