Skip to content

Commit

Permalink
cleanup: bc
Browse files Browse the repository at this point in the history
  • Loading branch information
aMahanna committed Apr 28, 2024
1 parent 1972f3b commit 498d115
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions nx_arangodb/algorithms/centrality/betweenness.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from networkx.algorithms.centrality import betweenness as nxbc
from networkx.algorithms.centrality import betweenness as nx_betweenness

from nx_arangodb.convert import _to_graph as _to_nx_arangodb_graph
from nx_arangodb.utils import networkx_algorithm
Expand Down Expand Up @@ -68,16 +68,22 @@ def betweenness_centrality(
for s in nodes:
# single source shortest paths
if weight is None: # use BFS
S, P, sigma, _ = nxbc._single_source_shortest_path_basic(G, s)
S, P, sigma, _ = nx_betweenness._single_source_shortest_path_basic(G, s)
else: # use Dijkstra's algorithm
S, P, sigma, _ = nxbc._single_source_dijkstra_path_basic(G, s, weight)
S, P, sigma, _ = nx_betweenness._single_source_dijkstra_path_basic(
G, s, weight
)
# accumulation
if endpoints:
betweenness, _ = nxbc._accumulate_endpoints(betweenness, S, P, sigma, s)
betweenness, _ = nx_betweenness._accumulate_endpoints(
betweenness, S, P, sigma, s
)
else:
betweenness, _ = nxbc._accumulate_basic(betweenness, S, P, sigma, s)
betweenness, _ = nx_betweenness._accumulate_basic(
betweenness, S, P, sigma, s
)

betweenness = nxbc._rescale(
betweenness = nx_betweenness._rescale(
betweenness,
len(G),
normalized=normalized,
Expand Down

0 comments on commit 498d115

Please sign in to comment.