connected_dominating_set

connected_dominating_set#

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

Return a connected dominating set of a connected graph.

Parameters:
gGraph

Connected graph to be used. Edge directions are ignored.

Returns:
dsetVertexPropertyMap

Boolean vertex property map marking the vertices of the set.

See also

approx_minimum_dominating_set

Approximate minimum dominating set

steiner_tree

Approximate minimum tree connecting a subset of vertices

Notes

A connected dominating set is a set of vertices that induces a connected subgraph and such that every other vertex is adjacent to one of them. The non-leaf vertices of any spanning tree form such a set, and the minimum ones are the complements of the sets of leaves of the spanning trees with the most leaves; finding one is NP-hard. The first greedy algorithm of Guha and Khuller [guha-approximation-1998] starts from a vertex of largest degree, whose neighbors become reached, and then adds repeatedly the reached vertex with the most unreached neighbors, which become reached in turn, until all vertices are reached. Since every vertex added is adjacent to one added before, the set is connected, and it approximates the minimum within a factor \(2(1 + H(\Delta))\), where \(H\) is the harmonic number and \(\Delta\) the largest degree. The time is \(O((V+E)\log V)\).

References

[guha-approximation-1998]

Sudipto Guha and Samir Khuller, “Approximation algorithms for connected dominating sets”, Algorithmica 20, 374-387 (1998), DOI: 10.1007/PL00009201 [sci-hub, @tor]

Examples

>>> g = gt.collection.data["karate"]
>>> d = gt.connected_dominating_set(g)
>>> print(d.a.sum())
5

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

>>> vcolor = g.new_vp("string", vals=np.where(d.a, "#f28c8e", "#cccccc"))
>>> s = gt.edge_endpoint_property(g, d, "source")
>>> t = gt.edge_endpoint_property(g, d, "target")
>>> ecolor = g.new_ep("string", vals=np.where(s.a & t.a, "#e41a1c",
...                                           "#999999"))
>>> ewidth = g.new_ep("double", vals=np.where(s.a & t.a, 2.5, 1))
>>> gt.graph_draw(g, g.vp.pos, vertex_fill_color=vcolor,
...               edge_color=ecolor, edge_pen_width=ewidth,
...               output="connected_dominating_set-karate.pdf")
<...>
../_images/connected_dominating_set-karate.png

Connected dominating set of Zachary’s karate club network, with its vertices and the edges between them shown in red.#