#!/usr/bin/env python # coding: utf-8 # # Max-cut problem # # An undirected graph $\mathscr{G} = (\mathcal{V},\mathcal{E})$ is defined as a collection of two sets: a set of vertices $\mathcal{V}$, and a set of edges $\mathcal{E}$. If there is an edge $e_{ij}\in\mathcal{E}$ connecting the vertices $v_{i},v_{j}\in\mathcal{V}$, then we can assign an weight $w_{ij} \geq 0$ to that edge to model the relative importance of that particular edge. Assuming the cardinality of the vertex set $|\mathcal{V}|=n$ , we normalize the weights as $\sum_{i\leq j}w_{ij} = 1$. This gives rise to a weighted directed graph $\mathscr{G}_{W} = (\mathcal{V},\mathcal{E},W)$ where the edge weight matrix $W\in\mathbb{R}^{n\times n}$ is symmetric with elements in $[0,1]$. # # A "cut" in $\mathscr{G}_{W}$ is simply a partition of the vertex set $\mathcal{V}$ into two (disjoint) sets: $\mathcal{S}$ and its complement $\overline{\mathcal{S}}:=\mathcal{V}\setminus\mathcal{S}$, that is, $\mathcal{V}=\mathcal{S}\cup\overline{\mathcal{S}}$. The "weight of a cut" is the sum of weights for those (and only those) edges which connect vertices in $\mathcal{S}$ to vertices in $\overline{\mathcal{S}}$. The "max-cut problem" concerns with finding a cut in $\mathscr{G}_{W}$ that maximizes the weight of cut. # # In the following example graph with $n=4$ vertices, the "red solid" cut is the max-cut (cut weight = 0.7), while the "blue dashed" cut is sub-optimal (cut-weight = 0.5). In this example, the red max-cut corresponds to the partition $\mathcal{V} = \{v_{1},v_{3}\} \cup \{v_{2},v_{4}\}$. The sub-optimal blue cut corresponds to the partition $\mathcal{V} = \{v_{1},v_{2}\} \cup \{v_{3},v_{4}\}$. # # # (a) (5+5=10 points) To formulate the max-cut problem as an optimization problem, let us consider any cut $\mathcal{V}=\mathcal{S}\cup\overline{\mathcal{S}}$, and for $i=1,...,n$, assign a variable $x_{i}$ to each vertex of $\mathscr{G}_{W} = (\mathcal{V},\mathcal{E},W)$, as # # $$x_{i} = \begin{cases} # 1 & \text{if}\quad v_{i}\in\mathcal{S},\\ # -1 & \text{if}\quad v_{i}\in\overline{\mathcal{S}}. # \end{cases}$$ # # Next, notice that $(1-x_{i}x_{j}) = 0$ if the vertices $v_{i}$ and $v_{j}$ are in the same set, and $=2$ otherwise. Therefore, the quantity $\sum_{i