This documents the development version of NetworkX. Documentation for the current release can be found here.


k_factor(G, k, matching_weight='weight')[source]

Compute a k-factor of G

A k-factor of a graph is a spanning k-regular subgraph. A spanning k-regular subgraph of G is a subgraph that contains each vertex of G and a subset of the edges of G such that each vertex has degree k.

GNetworkX graph

Undirected graph

matching_weight: string, optional (default=’weight’)

Edge data key corresponding to the edge weight. Used for finding the max-weighted perfect matching. If key not found, uses 1 as weight.

G2NetworkX graph

A k-factor of G



“An algorithm for computing simple k-factors.”, Meijer, Henk, Yurai Núñez-Rodríguez, and David Rappaport, Information processing letters, 2009.