Exemplo n.º 1
0
 def test_K4_normalized(self):
     "Approximate current-flow betweenness centrality: K4 normalized"
     G = networkx.complete_graph(4)
     b = networkx.current_flow_betweenness_centrality(G, normalized=True)
     epsilon = 0.1
     ba = approximate_cfbc(G, normalized=True, epsilon=0.5 * epsilon)
     for n in sorted(G):
         assert_allclose(b[n], ba[n], atol=epsilon)
 def test_K4(self):
     "Approximate current-flow betweenness centrality: K4"
     G = nx.complete_graph(4)
     b = nx.current_flow_betweenness_centrality(G, normalized=False)
     epsilon = 0.1
     ba = approximate_cfbc(G, normalized=False, epsilon=0.5 * epsilon)
     for n in sorted(G):
         np.testing.assert_allclose(b[n], ba[n], atol=epsilon * len(G)**2)
 def test_grid(self):
     "Approximate current-flow betweenness centrality: 2d grid"
     G = nx.grid_2d_graph(4, 4)
     b = nx.current_flow_betweenness_centrality(G, normalized=True)
     epsilon = 0.1
     ba = approximate_cfbc(G, normalized=True, epsilon=0.5 * epsilon)
     for n in sorted(G):
         np.testing.assert_allclose(b[n], ba[n], atol=epsilon)
 def test_grid(self):
     "Approximate current-flow betweenness centrality: 2d grid"
     G=nx.grid_2d_graph(4,4)
     b=nx.current_flow_betweenness_centrality(G,normalized=True)
     epsilon=0.1
     ba = approximate_cfbc(G,normalized=True, epsilon=0.5*epsilon)
     for n in sorted(G):
         assert_allclose(b[n],ba[n],atol=epsilon)
 def test_K4(self):
     "Approximate current-flow betweenness centrality: K4"
     G=nx.complete_graph(4)
     b=nx.current_flow_betweenness_centrality(G,normalized=False)
     epsilon=0.1
     ba = approximate_cfbc(G,normalized=False, epsilon=0.5*epsilon)
     for n in sorted(G):
         assert_allclose(b[n],ba[n],atol=epsilon*len(G)**2)
 def test_K4_normalized(self):
     "Approximate current-flow betweenness centrality: K4 normalized"
     G=networkx.complete_graph(4)
     b=networkx.current_flow_betweenness_centrality(G,normalized=True)
     epsilon=0.1
     ba = approximate_cfbc(G,normalized=True, epsilon=epsilon)
     for n in sorted(G):
         assert_allclose(b[n],ba[n],atol=epsilon)
 def test_star(self):
     "Approximate current-flow betweenness centrality: star"
     G = nx.Graph()
     nx.add_star(G, ["a", "b", "c", "d"])
     b = nx.current_flow_betweenness_centrality(G, normalized=True)
     epsilon = 0.1
     ba = approximate_cfbc(G, normalized=True, epsilon=0.5 * epsilon)
     for n in sorted(G):
         np.testing.assert_allclose(b[n], ba[n], atol=epsilon)
 def test_star(self):
     "Approximate current-flow betweenness centrality: star"
     G=nx.Graph()
     nx.add_star(G, ['a', 'b', 'c', 'd'])
     b=nx.current_flow_betweenness_centrality(G,normalized=True)
     epsilon=0.1
     ba = approximate_cfbc(G,normalized=True, epsilon=0.5*epsilon)
     for n in sorted(G):
         assert_allclose(b[n],ba[n],atol=epsilon)
Exemplo n.º 9
0
 def test_star(self):
     "Approximate current-flow betweenness centrality: star"
     G = networkx.Graph()
     G.add_star(['a', 'b', 'c', 'd'])
     b = networkx.current_flow_betweenness_centrality(G, normalized=True)
     epsilon = 0.1
     ba = approximate_cfbc(G, normalized=True, epsilon=0.5 * epsilon)
     for n in sorted(G):
         assert_allclose(b[n], ba[n], atol=epsilon)
 def test_solvers(self):
     "Approximate current-flow betweenness centrality: solvers"
     G=networkx.complete_graph(4)
     epsilon=0.1
     for solver in ['full','lu','cg']:
         b=approximate_cfbc(G,normalized=False,solver=solver,epsilon=epsilon)
         b_answer={0: 0.75, 1: 0.75, 2: 0.75, 3: 0.75}
         for n in sorted(G):
             assert_allclose(b[n],b_answer[n],atol=epsilon)
Exemplo n.º 11
0
 def test_solvers(self):
     "Approximate current-flow betweenness centrality: solvers"
     G = nx.complete_graph(4)
     epsilon = 0.1
     for solver in ["full", "lu", "cg"]:
         b = approximate_cfbc(
             G, normalized=False, solver=solver, epsilon=0.5 * epsilon
         )
         b_answer = {0: 0.75, 1: 0.75, 2: 0.75, 3: 0.75}
         for n in sorted(G):
             np.testing.assert_allclose(b[n], b_answer[n], atol=epsilon)
 def test_seed(self):
     G = nx.complete_graph(4)
     b = approximate_cfbc(G, normalized=False, epsilon=0.05, seed=1)
     b_answer = {0: 0.75, 1: 0.75, 2: 0.75, 3: 0.75}
     for n in sorted(G):
         np.testing.assert_allclose(b[n], b_answer[n], atol=0.1)
 def test_seed(self):
     G = nx.complete_graph(4)
     b = approximate_cfbc(G, normalized=False, epsilon=0.05, seed=1)
     b_answer = {0: 0.75, 1: 0.75, 2: 0.75, 3: 0.75}
     for n in sorted(G):
         assert_allclose(b[n], b_answer[n], atol=0.1)