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 diff --git a/releasenotes/notes/accept-generators-31f080871015233c.yaml b/releasenotes/notes/accept-generators-31f080871015233c.yaml new file mode 100644 index 000000000..de35fb3ca --- /dev/null +++ b/releasenotes/notes/accept-generators-31f080871015233c.yaml @@ -0,0 +1,11 @@ +--- +features: + - | + 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` + * :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` + 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