k_factor

Contents

k_factor#

graph_tool.structure.k_factor(g, k)[git][source]#

Return a \(k\)-factor of a graph.

Parameters:
gGraph

Simple undirected graph to be used.

kint

Degree of every vertex in the factor.

Returns:
factorEdgePropertyMap or None

Boolean edge property map marking the edges of a spanning subgraph in which every vertex has degree \(k\), or None if there is none.

See also

maximum_cardinality_matching

Maximum matching, i.e. a 1-factor if perfect

minimum_edge_cover

Edge cover of minimum size

Notes

Every vertex \(v\) of degree \(d\) is replaced by a gadget of Tutte [tutte-short-1954]: \(d\) outer vertices, one per incident edge, joined to the outer vertex of the other endpoint; and, if \(k \ge d/2\), \(d - k\) core vertices joined to all outer ones, or otherwise \(d\) inner vertices matched to the outer ones and \(k\) core vertices joined to all inner ones. The graph has a \(k\)-factor if and only if the gadget graph has a perfect matching (found with Edmonds’ algorithm, as in maximum_cardinality_matching()), whose edges between outer vertices give the factor. The gadget graph has \(O(E k)\) vertices and \(O(\sum_v k_v^2)\) edges.

References

[tutte-short-1954]

William T. Tutte, “A short proof of the factor theorem for finite graphs”, Canadian Journal of Mathematics 6, 347-352 (1954), DOI: 10.4153/CJM-1954-033-3 [sci-hub, @tor]

Examples

>>> g = gt.lattice([4, 4], periodic=True)
>>> f = gt.k_factor(g, 2)
>>> h = gt.GraphView(g, efilt=f)
>>> print(set(h.get_total_degrees(h.get_vertices()).tolist()))
{2}