|
| 1 | +```@meta |
| 2 | +EditURL = "<unknown>/examples/DominatingSet.jl" |
| 3 | +``` |
| 4 | + |
| 5 | +# Dominating set problem |
| 6 | + |
| 7 | +!!! note |
| 8 | + It is highly recommended to read the [Independent set problem](@ref) chapter before reading this one. |
| 9 | + |
| 10 | +## Problem definition |
| 11 | + |
| 12 | +In graph theory, a [dominating set](https://en.wikipedia.org/wiki/Dominating_set) for a graph ``G = (V, E)`` is a subset ``D`` of ``V`` such that every vertex not in ``D`` is adjacent to at least one member of ``D``. |
| 13 | +The domination number ``\gamma(G)`` is the number of vertices in a smallest dominating set for ``G``. |
| 14 | +The decision version of finding the minimum dominating set is an NP-complete. |
| 15 | +In the following, we are going to solve the dominating set problem on the Petersen graph. |
| 16 | + |
| 17 | +````@example DominatingSet |
| 18 | +using GenericTensorNetworks, Graphs |
| 19 | +
|
| 20 | +graph = Graphs.smallgraph(:petersen) |
| 21 | +```` |
| 22 | + |
| 23 | +We can visualize this graph using the following function |
| 24 | + |
| 25 | +````@example DominatingSet |
| 26 | +rot15(a, b, i::Int) = cos(2i*π/5)*a + sin(2i*π/5)*b, cos(2i*π/5)*b - sin(2i*π/5)*a |
| 27 | +
|
| 28 | +locations = [[rot15(0.0, 1.0, i) for i=0:4]..., [rot15(0.0, 0.6, i) for i=0:4]...] |
| 29 | +
|
| 30 | +show_graph(graph; locs=locations) |
| 31 | +```` |
| 32 | + |
| 33 | +## Generic tensor network representation |
| 34 | +We can use [`DominatingSet`](@ref) to construct the tensor network for solving the dominating set problem as |
| 35 | + |
| 36 | +````@example DominatingSet |
| 37 | +problem = DominatingSet(graph; optimizer=TreeSA()); |
| 38 | +nothing #hide |
| 39 | +```` |
| 40 | + |
| 41 | +### Theory (can skip) |
| 42 | +Let ``G=(V,E)`` be the target graph that we want to solve. |
| 43 | +The tensor network representation map a vertex ``v\in V`` to a boolean degree of freedom ``s_v\in\{0, 1\}``. |
| 44 | +We defined the restriction on a vertex and its neighbouring vertices ``N(v)``: |
| 45 | +```math |
| 46 | +T(x_v)_{s_1,s_2,\ldots,s_{|N(v)|},s_v} = \begin{cases} |
| 47 | + 0 & s_1=s_2=\ldots=s_{|N(v)|}=s_v=0,\\ |
| 48 | + 1 & s_v=0,\\ |
| 49 | + x_v^{w_v} & \text{otherwise}, |
| 50 | +\end{cases} |
| 51 | +``` |
| 52 | +where ``w_v`` is the weight of vertex ``v``. |
| 53 | +This tensor means if both ``v`` and its neighbouring vertices are not in ``D``, i.e., ``s_1=s_2=\ldots=s_{|N(v)|}=s_v=0``, |
| 54 | +this configuration is forbidden because ``v`` is not adjacent to any member in the set. |
| 55 | +otherwise, if ``v`` is in ``D``, it has a contribution ``x_v^{w_v}`` to the final result. |
| 56 | +One can check the contraction time space complexity of a [`DominatingSet`](@ref) instance by typing: |
| 57 | + |
| 58 | +````@example DominatingSet |
| 59 | +timespacereadwrite_complexity(problem) |
| 60 | +```` |
| 61 | + |
| 62 | +## Solving properties |
| 63 | + |
| 64 | +### Counting properties |
| 65 | +##### Domination polynomial |
| 66 | +The graph polynomial for the dominating set problem is known as the domination polynomial (see [arXiv:0905.2251](https://arxiv.org/abs/0905.2251)). |
| 67 | +It is defined as |
| 68 | +```math |
| 69 | +D(G, x) = \sum_{k=0}^{\gamma(G)} d_k x^k, |
| 70 | +``` |
| 71 | +where ``d_k`` is the number of dominating sets of size ``k`` in graph ``G=(V, E)``. |
| 72 | + |
| 73 | +````@example DominatingSet |
| 74 | +domination_polynomial = solve(problem, GraphPolynomial())[] |
| 75 | +```` |
| 76 | + |
| 77 | +The domination number ``\gamma(G)`` can be computed with the [`SizeMin`](@ref) property: |
| 78 | + |
| 79 | +````@example DominatingSet |
| 80 | +domination_number = solve(problem, SizeMin())[] |
| 81 | +```` |
| 82 | + |
| 83 | +Similarly, we have its counting [`CountingMin`](@ref): |
| 84 | + |
| 85 | +````@example DominatingSet |
| 86 | +counting_min_dominating_set = solve(problem, CountingMin())[] |
| 87 | +```` |
| 88 | + |
| 89 | +### Configuration properties |
| 90 | +##### finding minimum dominating set |
| 91 | +One can enumerate all minimum dominating sets with the [`ConfigsMin`](@ref) property in the program. |
| 92 | + |
| 93 | +````@example DominatingSet |
| 94 | +min_configs = solve(problem, ConfigsMin())[].c |
| 95 | +
|
| 96 | +all(c->is_dominating_set(graph, c), min_configs) |
| 97 | +```` |
| 98 | + |
| 99 | +````@example DominatingSet |
| 100 | +show_gallery(graph, (2, 5); locs=locations, vertex_configs=min_configs) |
| 101 | +```` |
| 102 | + |
| 103 | +Similarly, if one is only interested in computing one of the minimum dominating sets, |
| 104 | +one can use the graph property [`SingleConfigMin`](@ref). |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +*This page was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).* |
| 109 | + |
0 commit comments