From 2050a6d6d2f947c89f0c5e2bb340696a7da4bd98 Mon Sep 17 00:00:00 2001 From: Ivan Carvalho Date: Tue, 3 Dec 2024 20:57:18 -0500 Subject: [PATCH 1/5] Add release notes for #1292 --- .../notes/accept-generators-31f080871015233c.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 releasenotes/notes/accept-generators-31f080871015233c.yaml diff --git a/releasenotes/notes/accept-generators-31f080871015233c.yaml b/releasenotes/notes/accept-generators-31f080871015233c.yaml new file mode 100644 index 000000000..f96ffb3d0 --- /dev/null +++ b/releasenotes/notes/accept-generators-31f080871015233c.yaml @@ -0,0 +1,11 @@ +--- +features: + - | + The following meths now support iterators as inputs, in addition to + the existing support for lists: + * :meth:`~rustworkx.PyGraph.add_nodes_from` and :meth:`~rustworkx.PyDiGraph.add_nodes_from` + * :meth:`~rustworkx.PyGraph.add_edges_from` and :meth:`~rustworkx.PyDiGraph.add_edges_from` + * :meth:`~rustworkx.PyGraph.add_edges_from_no_data` and :meth:`~rustworkx.PyDiGraph.add_edges_from_no_data` + * :meth:`~rustworkx.PyGraph.extend_from_edge_list` and :meth:`~rustworkx.PyDiGraph.extend_from_edge_list` + * :meth:`~rustworkx.PyGraph.extend_from_weighted_edge_list` and :meth:`~rustworkx.PyDiGraph.extend_from_weighted_edge_list` + From bc39ada2b0e862b9b021ce7b368308ec9e74e216 Mon Sep 17 00:00:00 2001 From: Ivan Carvalho Date: Tue, 3 Dec 2024 21:09:26 -0500 Subject: [PATCH 2/5] Add release notes for degree centrality --- .../degree-centrality-e7ddf61a9a8fbafc.yaml | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 releasenotes/notes/degree-centrality-e7ddf61a9a8fbafc.yaml diff --git a/releasenotes/notes/degree-centrality-e7ddf61a9a8fbafc.yaml b/releasenotes/notes/degree-centrality-e7ddf61a9a8fbafc.yaml new file mode 100644 index 000000000..391c664fb --- /dev/null +++ b/releasenotes/notes/degree-centrality-e7ddf61a9a8fbafc.yaml @@ -0,0 +1,33 @@ +--- +features: + - | + Added a new function, :func:`~rustworkx.degree_centrality` which is used to + compute the degree centrality for all nodes in a given graph. For + example: + + .. jupyter-execute:: + + import rustworkx as rx + from rustworkx.visualization import mpl_draw + + graph = rx.generators.hexagonal_lattice_graph(4, 4) + centrality = rx.degree_centrality(graph) + + # Generate a color list + colors = [] + for node in graph.node_indices(): + centrality_score = centrality[node] + graph[node] = centrality_score + colors.append(centrality_score) + mpl_draw( + graph, + with_labels=True, + node_color=colors, + node_size=650, + labels=lambda x: "{0:.2f}".format(x) + ) + + - | + Added two new functions, :func:`~rustworkx.in_degree_centrality` and + :func:`~rustworkx.out_degree_centrality` to calculate two special + types of degree centrality for directed graphs. \ No newline at end of file From 6f6f2c29ee8123a9501c9ea5385338611905009e Mon Sep 17 00:00:00 2001 From: Ivan Carvalho Date: Tue, 3 Dec 2024 21:46:21 -0500 Subject: [PATCH 3/5] Add centrality entries to the docs --- docs/source/api/algorithm_functions/centrality.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/source/api/algorithm_functions/centrality.rst b/docs/source/api/algorithm_functions/centrality.rst index 78b54514e..dfbaaa598 100644 --- a/docs/source/api/algorithm_functions/centrality.rst +++ b/docs/source/api/algorithm_functions/centrality.rst @@ -7,7 +7,10 @@ Centrality :toctree: ../../apiref rustworkx.betweenness_centrality + rustworkx.degree_centrality rustworkx.edge_betweenness_centrality rustworkx.eigenvector_centrality rustworkx.katz_centrality rustworkx.closeness_centrality + rustworkx.in_degree_centrality + rustworkx.out_degree_centrality \ No newline at end of file From a0118cbd60247b6195cf0e77a0025dd820de4cc5 Mon Sep 17 00:00:00 2001 From: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com> Date: Wed, 4 Dec 2024 08:53:15 -0500 Subject: [PATCH 4/5] Update releasenotes/notes/accept-generators-31f080871015233c.yaml Co-authored-by: Matthew Treinish --- releasenotes/notes/accept-generators-31f080871015233c.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/accept-generators-31f080871015233c.yaml b/releasenotes/notes/accept-generators-31f080871015233c.yaml index f96ffb3d0..148036ecc 100644 --- a/releasenotes/notes/accept-generators-31f080871015233c.yaml +++ b/releasenotes/notes/accept-generators-31f080871015233c.yaml @@ -1,7 +1,7 @@ --- features: - | - The following meths now support iterators as inputs, in addition to + The following methods now support iterators as inputs, in addition to the existing support for lists: * :meth:`~rustworkx.PyGraph.add_nodes_from` and :meth:`~rustworkx.PyDiGraph.add_nodes_from` * :meth:`~rustworkx.PyGraph.add_edges_from` and :meth:`~rustworkx.PyDiGraph.add_edges_from` From f03a20779ee85df7308e72ee5564f1596f5fd084 Mon Sep 17 00:00:00 2001 From: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com> Date: Wed, 4 Dec 2024 08:54:17 -0500 Subject: [PATCH 5/5] Update releasenotes/notes/accept-generators-31f080871015233c.yaml --- releasenotes/notes/accept-generators-31f080871015233c.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/accept-generators-31f080871015233c.yaml b/releasenotes/notes/accept-generators-31f080871015233c.yaml index 148036ecc..de35fb3ca 100644 --- a/releasenotes/notes/accept-generators-31f080871015233c.yaml +++ b/releasenotes/notes/accept-generators-31f080871015233c.yaml @@ -1,7 +1,7 @@ --- features: - | - The following methods now support iterators as inputs, in addition to + The following methods now support sequences and generators as inputs, in addition to the existing support for lists: * :meth:`~rustworkx.PyGraph.add_nodes_from` and :meth:`~rustworkx.PyDiGraph.add_nodes_from` * :meth:`~rustworkx.PyGraph.add_edges_from` and :meth:`~rustworkx.PyDiGraph.add_edges_from`