#

Note

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

#

networkx.algorithms.regular.k_factor

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.

Parameters
  • G (NetworkX graph) – Undirected graph

  • 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.

Returns

G2 – A k-factor of G

Return type

NetworkX graph

References

1

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