Skip to content

Commit d21fe54

Browse files
Add missing release notes for #1292 and #1306 (#1336)
* Add release notes for #1292 * Add release notes for degree centrality * Add centrality entries to the docs * Update releasenotes/notes/accept-generators-31f080871015233c.yaml Co-authored-by: Matthew Treinish <[email protected]> * Update releasenotes/notes/accept-generators-31f080871015233c.yaml --------- Co-authored-by: Matthew Treinish <[email protected]>
1 parent 25077aa commit d21fe54

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

docs/source/api/algorithm_functions/centrality.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ Centrality
77
:toctree: ../../apiref
88

99
rustworkx.betweenness_centrality
10+
rustworkx.degree_centrality
1011
rustworkx.edge_betweenness_centrality
1112
rustworkx.eigenvector_centrality
1213
rustworkx.katz_centrality
1314
rustworkx.closeness_centrality
15+
rustworkx.in_degree_centrality
16+
rustworkx.out_degree_centrality
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
features:
3+
- |
4+
The following methods now support sequences and generators as inputs, in addition to
5+
the existing support for lists:
6+
* :meth:`~rustworkx.PyGraph.add_nodes_from` and :meth:`~rustworkx.PyDiGraph.add_nodes_from`
7+
* :meth:`~rustworkx.PyGraph.add_edges_from` and :meth:`~rustworkx.PyDiGraph.add_edges_from`
8+
* :meth:`~rustworkx.PyGraph.add_edges_from_no_data` and :meth:`~rustworkx.PyDiGraph.add_edges_from_no_data`
9+
* :meth:`~rustworkx.PyGraph.extend_from_edge_list` and :meth:`~rustworkx.PyDiGraph.extend_from_edge_list`
10+
* :meth:`~rustworkx.PyGraph.extend_from_weighted_edge_list` and :meth:`~rustworkx.PyDiGraph.extend_from_weighted_edge_list`
11+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
features:
3+
- |
4+
Added a new function, :func:`~rustworkx.degree_centrality` which is used to
5+
compute the degree centrality for all nodes in a given graph. For
6+
example:
7+
8+
.. jupyter-execute::
9+
10+
import rustworkx as rx
11+
from rustworkx.visualization import mpl_draw
12+
13+
graph = rx.generators.hexagonal_lattice_graph(4, 4)
14+
centrality = rx.degree_centrality(graph)
15+
16+
# Generate a color list
17+
colors = []
18+
for node in graph.node_indices():
19+
centrality_score = centrality[node]
20+
graph[node] = centrality_score
21+
colors.append(centrality_score)
22+
mpl_draw(
23+
graph,
24+
with_labels=True,
25+
node_color=colors,
26+
node_size=650,
27+
labels=lambda x: "{0:.2f}".format(x)
28+
)
29+
30+
- |
31+
Added two new functions, :func:`~rustworkx.in_degree_centrality` and
32+
:func:`~rustworkx.out_degree_centrality` to calculate two special
33+
types of degree centrality for directed graphs.

0 commit comments

Comments
 (0)