Let $N$ be the number of vertices in $G$ hereafter.
Decision variables¶
Let each of $N$ binary variables $q$ be associated with each vertex to indicate whether the vertex is
included in the vertex cover $R$. The variable is $1$ if its corresponding vertex is included in $R$
and
$0$ if not.
For example, when $R$ is the set of orange vertices as in the figure below, the decision variable $q$
would be as in the below table.
Index of vertex |
0 |
1 |
2 |
3 |
4 |
5 |
$q$ |
1 |
0 |
1 |
0 |
1 |
0 |
Objective function¶
Since the number of elements in $R$ should be as small as possible, the objective function is
$\displaystyle \sum_{v = 0}^{N - 1}q_v$.
Constraints¶
For $q$ to represent a vertex cover, we need the following constraints.
- Condition 1: For each edge $(u, v)$ of $G$, either $u$ or $v$ is contained in $R$.
Since this is a condition that either the binary variable corresponding to $u$ or the binary variable
corresponding to $v$ is $1$,
$$
(1 - q_u) (1 - q_v) = 0 \quad \text{for} \quad (u, v) \in E.
$$
Here, $E$ is an edge set of $G$. Conversely, when condition 1 holds, clearly $R$ is a vertex covering
$G$.