Warning

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

networkx.algorithms.core.onion_layers

onion_layers(G)[source]

Returns the layer of each vertex in the onion decomposition of the graph.

The onion decomposition refines the k-core decomposition by providing information on the internal organization of each k-shell. It is usually used alongside the core numbers.

Parameters

G (NetworkX graph) – A simple graph without self loops or parallel edges

Returns

od_layers – A dictionary keyed by vertex to the onion layer. The layers are contiguous integers starting at 1.

Return type

dictionary

Raises

NetworkXError – The onion decomposition is not implemented for graphs with self loops or parallel edges or for directed graphs.

Notes

Not implemented for graphs with parallel edges or self loops.

Not implemented for directed graphs.

See also

core_number()

References

1

Multi-scale structure and topological anomaly detection via a new network statistic: The onion decomposition L. Hébert-Dufresne, J. A. Grochow, and A. Allard Scientific Reports 6, 31708 (2016) http://doi.org/10.1038/srep31708

2

Percolation and the effective structure of complex networks A. Allard and L. Hébert-Dufresne Physical Review X 9, 011023 (2019) http://doi.org/10.1103/PhysRevX.9.011023