rustworkx.core_number#

core_number(graph)[source]#

Return the core number for each node in the graph.

A k-core is a maximal subgraph that contains nodes of degree k or more.

Note

The function implicitly assumes that there are no parallel edges or self loops. It may produce incorrect/unexpected results if the input graph has self loops or parallel edges.

Parameters:

graph – The graph to get core numbers. Can either be a PyGraph or PyDiGraph

Returns:

A dictionary keyed by node index to the core number

Return type:

dict raise TypeError(“Invalid Input Type %s for graph” % type(graph))