-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add edge betweenness centrality #799
Changes from 9 commits
9b1e5f7
3e62d20
80c47b3
e94190a
cab4ba7
c0735e1
2c850ab
73cd304
5da85c2
c02e8c4
0da3924
9b6a2bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
features: | ||
- | | ||
Added a new function, :func:`~rustworkx.edge_betweenness_centrality` to compute | ||
edge betweenness centrality of all edges in a :class:`~rustworkx.PyGraph` or | ||
:class:`~rustworkx.PyDiGraph` object. The algorithm used in this function is | ||
based on: | ||
|
||
Ulrik Brandes, On Variants of Shortest-Path Betweenness Centrality | ||
and their Generic Computation. Social Networks 30(2):136-145, 2008. | ||
|
||
Edge betweenness centrality of an edge :math:`e` is the sum of the | ||
fraction of all-pairs shortest paths that pass through :math`e` | ||
|
||
.. math:: | ||
|
||
c_B(e) =\sum_{s,t \in V} \frac{\sigma(s, t|e)}{\sigma(s, t)} | ||
|
||
where :math:`V` is the set of nodes, :math:`\sigma(s, t)` is the | ||
number of shortest :math:`(s, t)`-paths, and :math:`\sigma(s, t|e)` is | ||
the number of those paths passing through edge :math:`e`. | ||
|
||
For example, computing the edge betweenness centrality for all edges in a 5x5 | ||
grid graph and using that to color the edges in a graph visualization: | ||
|
||
.. jupyter-execute:: | ||
|
||
import rustworkx | ||
from rustworkx.visualization import mpl_draw | ||
|
||
graph = rustworkx.generators.grid_graph(5, 5) | ||
btw = rustworkx.edge_betweenness_centrality(graph) | ||
# Color edges in graph visualization with edge betweenness centrality | ||
colors = [] | ||
for i in graph.edge_indices(): | ||
colors.append(btw[i]) | ||
mpl_draw(graph, edge_color=colors) | ||
- | | ||
Added a new function to rustworkx-core ``edge_betweenness_centrality`` to | ||
the ``rustworkx_core:centrality`` module which computes the edge betweenness | ||
centrality of all edges in a given graph. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. File needs a newline. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.