Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

k_shell

k_shell(G, k=None, core_number=None)[source]

Return the k-shell of G.

The k-shell is the subgraph of nodes in the k-core but not in the (k+1)-core.

Parameters :

G : NetworkX graph

A graph or directed graph.

k : int, optional

The order of the shell. If not specified return the main shell.

core_number : dictionary, optional

Precomputed core numbers for the graph G.

Returns :

G : NetworkX graph

The k-shell subgraph

Raises :

NetworkXError

The k-shell is not defined for graphs with self loops or parallel edges.

See also

core_number, k_corona, ----------

Shai Carmi, Shlomo Havlin, Scott Kirkpatrick, Yuval Shavitt, and Eran Shir, PNAS July 3, 2007 vol. 104 no. 27 11150-11154
http
//www.pnas.org/content/104/27/11150.full

Notes

This is similar to k_corona but in that case only neighbors in the k-core are considered.

Not implemented for graphs with parallel edges or self loops.

For directed graphs the node degree is defined to be the in-degree + out-degree.

Graph, node, and edge attributes are copied to the subgraph.