minimum_edge_cover

minimum_edge_cover#

graph_tool.structure.minimum_edge_cover(g)[git][source]#

Return an edge cover of minimum size.

Parameters:
gGraph

Graph to be used. Edge directions are ignored.

Returns:
coverEdgePropertyMap

Boolean edge property map marking the edges of the cover.

See also

maximum_cardinality_matching

Maximum matching, extended to the cover

approx_minimum_vertex_cover

Vertex counterpart

Notes

An edge cover is a set of edges such that every vertex is incident to at least one of them. A minimum one is obtained from a maximum matching (see maximum_cardinality_matching()) by adding, for every unmatched vertex, one of its edges [gallai-uber-1959], so that it has \(V - M\) edges, where \(M\) is the size of the matching. Self-loops are not used. A ValueError is raised if there are isolated vertices.

References

[gallai-uber-1959]

Tibor Gallai, “Über extreme Punkt- und Kantenmengen”, Annales Universitatis Scientiarum Budapestinensis de Rolando Eötvös Nominatae, Sectio Mathematica 2, 133-138 (1959).

Examples

>>> g = gt.collection.data["karate"]
>>> c = gt.minimum_edge_cover(g)
>>> print(c.a.sum())
21

The cover can be highlighted in a drawing of the network:

>>> ecolor = g.new_ep("string", vals=np.where(c.a, "#e41a1c", "#999999"))
>>> ewidth = g.new_ep("double", vals=np.where(c.a, 2.5, 1))
>>> gt.graph_draw(g, g.vp.pos, vertex_fill_color="#cccccc",
...               edge_color=ecolor, edge_pen_width=ewidth,
...               output="minimum_edge_cover-karate.pdf")
<...>
../_images/minimum_edge_cover-karate.png

Minimum edge cover of Zachary’s karate club network, with its edges shown in red.#