\chapter{Solving the \acrshort{ECP} and the \acrshort{D-ECP}}
\label{ch:solving}

We now present some techniques for calculating exactly and approximating both
the \acrshort{ECP} and the \acrshort{D-ECP} (\autoref{sub:the_problem_definition}).

\section{Exact Solutions}%
\label{sec:exact-solutions}

We start with our exact algorithms that are based on MIPs.

\subsection{A MIP Model for the \acrshort{ECP}}%
\label{sub:a_mip_model_for_the_ecp}

Let $G$ be an \emph{interaction graph} for contents $\mathcal{C} $ and
threads $T \in \mathcal{T}_{C}, \; C \in \mathcal{C} $ for which we want to
solve the \acrshort{ECP}. Fix
$\alpha \in [0, 1]$. Let $\mathcal{\hat{C}} \subseteq \mathcal{C} $ be the
set of controversial contents and $E_k$ the set
of all edges of thread $T_k$ associated to a controversial content, i.e. $T_{k}
	\in \mathcal{T}_{C}, C \in \mathcal{\hat{C}}$; let also $E^{+}_k $
and $E^{-}_k $ be the set of positive and negative edges in $T_k$, respectively.

The following \acrshort{MIP} model is able to solve the \acrshort{ECP} on $G$
for values of $\alpha \leq 0.5$.

\begin{alignat}{3}
	\label{eq:ecp-exact1}
	\text{maximize}     &                                                 & \sum_{ T_{k} \in \mathcal{T}_{C}, \; C \in
		\mathcal{\hat{C}} } \big( \sum^{}_{ij \in E^{+}_k } x_{ij}
	^{k} - \sum_{ij \in E^{-}_k } x_{ij} ^{k} \big)                                                                                \\
	\label{eq:ecp-v1}
	\text{subject to}   & \quad                                           & x _{ij}^{k}  \leq y_i                                               & \quad \forall ij \in E_k                        \\
	\label{eq:ecp-v2}
	                    &                                                 & x _{ij}^{k}  \leq y_j                                               & \quad \forall ij \in E_k                        \\
	\label{eq:ecp-t1}
	                    &                                                 & x _{ij}^{k}  \leq z_k                                               & \quad \forall ij \in E_k                        \\
	\label{eq:ecp-e1}
	                    &                                                 & x _{ij} ^{k} \geq - 2 + y_i + y_j + z_k                             & \quad \forall ij \in E_k                        \\
	\label{eq:ecp-alpha-constraint1}
	                    &                                                 & \sum^{}_{ij \in E_k^{-} } x_{ij}^{k}  - \alpha \sum^{}_{ij \in E_k}
	x_{ij} ^{k}  \leq 0 & \quad \forall T_{k} \in \mathcal{T} _{C}, C \in
	\hat{\mathcal{C}}                                                                                \\
	\label{eq:ecp-vertex-def1}
	                    &                                                 & y _{i} \in  \{0, 1\}                                                & \quad \forall i \in V                           \\
	\label{eq:ecp-edge-def1}
	                    &                                                 & 0 \leq x _{ij} ^{k}  \leq 1                                         & \quad \forall ij \in E_k                        \\
	\label{eq:ecp-thread-def1}
	                    &                                                 & 0 \leq z _{k} \leq 1                                                & \quad \forall T_{k} \in \mathcal{T} _{C}, C \in
	\hat{\mathcal{C}}
\end{alignat}

The \acrshort{MIP} model introduces variables $x$, $y$ and $z$.
\begin{itemize}
	\item $y$ variables are associated to vertices
	      (\autoref{eq:ecp-vertex-def1}). Intuitively $y_i = 1$ means that the
	      vertex $v_{i} $ is part of the set $U \subseteq V$ considered for the
	      score.
	\item $x$ variables are associated to edges (\autoref{eq:ecp-edge-def1}).
	      A value of $x_{ij}^{k} = 1$ should be interpreted as the fact that
	      the edge $e_{ij} \in E_k$ is contributing to the score,
	      i.e. $T_k \in \mathcal{S}_{C} (U)$.
	\item $z$ variables are associated to threads
	      (\autoref{eq:ecp-thread-def1}). A value greater than 0
	      is generally associated to \emph{non-controversial} threads and
	      \emph{controversial} threads have value $z_k = 0$.
\end{itemize}

We will now show that the \acrshort{ECP} can be solved through
MIP~\eqref{eq:ecp-exact1}-\eqref{eq:ecp-thread-def1}.

\begin{theorem}
	\label{th:ecp-mip}
	Let $G = \{G_k = (V,E_k) \}_k$ be an \emph{Interaction Graph} and $\alpha \in
		[0, 0.5]$. Then

	\begin{equation}
		\max_{U \subseteq V} \xi(U) = \operatorname{OPT}(\operatorname{MIP}),
	\end{equation}
	where $\operatorname{OPT}(\operatorname{MIP})$ denotes the optimal solution to
	MIP~\eqref{eq:ecp-exact1}-\eqref{eq:ecp-thread-def1}.
\end{theorem}

\begin{proof}
	We will show the equality by first proving that $RHS \geq LHS$ and then
	that $LHS \geq RHS$.

	\begin{claim}
		\label{th:claim-v-b-xi}
		For any $U \subseteq V$, the
		MIP~\eqref{eq:ecp-exact1}-\eqref{eq:ecp-thread-def1} achieves value at
		least $\xi(U)$.
	\end{claim}

	\begin{proof}
		Let $E_k[U]$ the set of edges induced by $U$ in thread $T_k$. We
		construct a MIP solution as follows:

		\begin{alignat}{2}
			\label{eq:ecpp-y}
			y_i        & = \begin{cases}
				1, & \text{if } v_{i} \in U, \\
				0, & \text{otherwise,}
			\end{cases} & \forall v_i \in V                                \\
			\label{eq:ecpp-z}
			z_k        & = \begin{cases}
				1, & \text{if } T_{k} \in \mathcal{S}_C(U), \; C \in
				\mathcal{\hat{C}} ,                                  \\
				0, & \text{otherwise,}
			\end{cases} & \forall T_k \in \mathcal{T}_C, C \in \mathcal{C} \\
			\label{eq:ecpp-x}
			x_{ij}^{k} & = \begin{cases}
				1, & \text{if } e_{ij} \in E_{k}[U], \; T_{k} \in \mathcal{S}_C(U), \; C \in
				\mathcal{\hat{C}},                                                           \\
				0, & \text{otherwise.}
			\end{cases} & \forall e_{ij}^k \in E_k
		\end{alignat}

		To satisfy \eqref{eq:ecp-v1}-\eqref{eq:ecp-e1} we need that
		\begin{equation}
			\label{eq:ecpp-x-iff}
			x_{ij}^{k} = 1 \iff y_i = 1 \land y_j = 1 \land z_k = 1.
		\end{equation}
		This is always true since we defined $x_{ij}^{k}$ to be $1$ only and if it
		is associated to an edge induced in a $T_k \in \mathcal{S}_C(U), \; C \in
			\mathcal{\hat{C}} $.

		Let us now consider a thread $T_k \in \mathcal{S}_C(U)$. Then

		\begin{equation}
			\eta(T_k[U]) \leq \alpha \implies \frac{|E^{-}_{k}[U]|}{|E_{k}[U]|} \leq
			\alpha \implies |E^{-}_{k}[U]| - \alpha |E_{k}[U]| \leq 0.
		\end{equation}
		so \eqref{eq:ecp-alpha-constraint1} is satisfied. It is easy to see that
		if $T_k \not\in \mathcal{S}_C(U)$ then $x_{ij}^{k} = 0$ for all $ij \in E_{k}$ and
		the constraint is also satisfied.

		Finally, any edge contributing to $\xi(U)$ will also
		equally contribute to the objective function.
	\end{proof}

	\begin{claim}
		\label{th:claim-xi-b-v}
		Given a feasible solution of
		MIP~\eqref{eq:ecp-exact1}-\eqref{eq:ecp-thread-def1} with value $v$ we can
		construct $U \; s.t. \; \xi(U) \geq v$.
	\end{claim}

	\begin{proof}
		We define $U \coloneqq \{ v_{i} \; s.t. \; y_i = 1\}$. Again, by
		\eqref{eq:ecp-v1}-\eqref{eq:ecp-e1} we have
		\eqref{eq:ecpp-x-iff}, so
		\begin{gather}
			x_{ij}^{k} = 1 \implies z_k = 1, \\
			\label{eq:ecpp-z-iff-xij}
			z_k = 1 \implies x_{i'j'}^{k} = 1 \; \forall i'j'
			\in E_k[U],
		\end{gather}
		meaning that if $z_k = 1$ then for all the edges $e_{ij} \in E_k$ induced
		by $U$ we will have $x_{ij}^{k} = 1$ (i.e.\ they will contribute to the
		objective).
		Let us now consider $T_k \; s.t. \; z_k = 1$. Because of
		\eqref{eq:ecp-alpha-constraint1} and \eqref{eq:ecpp-z-iff-xij} we have

		\begin{equation}
			\label{eq:ecpp-nc-t}
			|E^{-}_{k}[U]| - \alpha |E_{k}[U]| \leq 0 \implies
			\frac{|E^{-}_{k}[U]|}{|E_{k}[U]|} \leq \alpha.
		\end{equation}
		i.e. $\eta(T_k[U]) \leq \alpha$. So $T_k \in
			\mathcal{S}_C(U), \; C \in \mathcal{\hat{C}}$, i.e. $z_k = 1 \implies T_k
			\in \mathcal{S}_C(U), \; C \in \mathcal{\hat{C}}$, thus $T_k[U]$ contributes to
		$\xi(U)$; more specifically any edge contributing to the objective function equally
		contributes to $\xi(U)$.

		Now suppose there exists $T_k \in \mathcal{S}_C(U) \; s.t.
			\; z_k = 0$. Then $ x_{ij}^{k} = 0$ by \eqref{eq:ecp-t1}. Since $\alpha \leq 0.5$,

		\begin{align}
			\eta(T_k[U]) \leq \alpha & \implies \frac{|E^{-}_{k}[U]|}{|E_{k}[U]|}
			\leq 0.5                                                                                \\
			                         & \implies |E^{-}_{k}[U]| \leq 0.5 \cdot (|E^{+}_{k}[U]| + |E^{-}_{k}[U]|) \\
			                         & \implies 0.5 \cdot |E^{+}_{k}[U]| - 0.5 \cdot |E^{-}_{k}[U]| \geq 0      \\
			\label{eq:ecpp-nc-contr}
			                         & \implies |E^{+}_{k}[U]| - |E^{-}_{k}[U]|
			\geq 0.
		\end{align}
		Consequently $T_k$ will contribute positively to $\xi(U)$, i.e.
		in the subgraph induced on $T_k$ by $U$
		the number of positive edges is greater or equal than the
		number of negative edges.

		More generally, due to \eqref{eq:ecp-v1}-\eqref{eq:ecp-e1} we have
		\begin{gather*}
			z_k = c > 0 \implies x_{i'j'}^{k} = c \; \forall i'j'
			\in E_k[U],
			% \\
			% x_{ij}^{k} = c \iff z_k = c \land y_i = 1 \land y_j = 1,
		\end{gather*}
		meaning that if $z_k = c$ all and only the variables $x_{ij}^{k}$
		associated to edges $e_{ij} \in E_k$ induced by $U$
		will get value $c$ (any other $x_{ij}^{k}$ will get value $0$ for
		\eqref{eq:ecp-v1}-\eqref{eq:ecp-v2}).

		Combining this result with \eqref{eq:ecp-alpha-constraint1} we get
		again \eqref{eq:ecpp-nc-t} and, consequently, \eqref{eq:ecpp-nc-contr}.
		Therefore, the contribution of $T_k$ associated to $z_k > 0$ will be

		\begin{equation}
			\sum^{}_{ij \in E^{+}_k } x_{ij}
				^{k} - \sum_{ij \in E^{-}_k } x_{ij} ^{k} = z_k (|E^{+}_{k}[U]| -
			|E^{-}_{k}[U]|) \geq 0.
		\end{equation}
		Since $z_k \in [0, 1]$ the contribution of the same thread in $\xi(U)$
		will be greater (if $z_k \in [0, 1)$) or equal (if $z_k = 1$) to the
		contribution of thread $T_k$ in the objective function.

		% can be similarly shown to be
		% \emph{non-controversial}; furthermore its positive contribution in the
		% objective function will be $\leq$ to $T_k$ contribution in $\xi(U)$, so
		% $\xi(U) \geq v$.
	\end{proof}

	This concludes the proof for \autoref{th:ecp-mip}.
\end{proof}

\subsubsection{A MIP Model for $\alpha > 0.5$}

Previously, we solved the \acrshort{ECP} for $\alpha \in [0, 0.5]$. Solving the problem for $\alpha \in [0, 1]$ requires the definition of
additional variables and constraints.

\begin{equation}
	\label{eq:ecp-exact2}
	\text{maximize}\quad \sum_{ T_{k} \in \mathcal{T}_{C}, \; C \in
		\mathcal{\hat{C}} } \big( \sum^{}_{ij \in E^{+}_k } x_{ij}
	^{k} - \sum_{ij \in E^{-} _k} x_{ij} ^{k} \big)
\end{equation} \begin{center} subject to \end{center}
\begin{alignat}{3}
	\label{eq:ecp-v12}
	                                                                 &                    & x _{ij}^{k}                                                        \leq y_i \quad\quad                   & \forall ij \in E_k                        \\
	\label{eq:ecp-v22}
	                                                                 &                    & x _{ij}^{k}                                                        \leq y_j \quad\quad                   & \forall ij \in E_k                        \\
	\label{eq:ecp-t2}
	                                                                 &                    & x _{ij}^{k}                                                        \leq z_k \quad\quad                   & \forall ij \in E_k                        \\
	\label{eq:ecp-e2}
	                                                                 &                    & x _{ij} ^{k}                                                       \geq - 2 + y_i + y_j + z_k \quad\quad & \forall ij \in E_k                        \\
	\label{eq:ecp-a-alpha-constraint}
	                                                                 &                    & -N_k z_k < \sum^{}_{ij \in E^-_k} a_{ij}^{k}  - \alpha \sum^{}_{ij
		\in E_k}
	a_{ij} ^{k}                   \leq M_{k} (1 - z_{k})  \quad\quad & \forall T_{k} \in
	\mathcal{T} _{C}, C \in \mathcal{\hat{C}}                                                                                \\
	\label{eq:ecp-a-ij-g-i-j2}
	                                                                 &                    & a_{ij}^{k}                                                         \geq -1 + y_i + y_j \quad\quad        & \forall ij \in E_k                        \\
	\label{eq:ecp-a-ij-l-i2}
	                                                                 &                    & a_{ij}^{k}                                                         \leq y_i\quad\quad                    & \forall ij \in E_k                        \\
	\label{eq:ecp-a-ij-l-j2}
	                                                                 &                    & a_{ij}^{k}                                                         \leq y_j \quad\quad                   & \forall ij \in E_k                        \\
	\label{eq:ecp-a-domain-2}
	                                                                 &                    & 0 \leq
	a_{ij}^{k} \leq 1  \quad\quad                                    & \forall ij \in E_k                                                                                \\
	\label{eq:ecp-vertex-def2}
	                                                                 &                    & y _{i}                                                             \in  \{0, 1\} \quad\quad              & \forall i \in V                           \\
	\label{eq:ecp-edge-def2}
	                                                                 &                    & 0 \leq x _{ij} ^{k}                                                \leq 1 \quad\quad                     & \forall ij \in E_k                        \\
	\label{eq:ecp-z-domain-2}
	                                                                 &                    & z _{k}                                                             \in  \{0, 1\} \quad\quad              & \forall T_{k} \in \mathcal{T} _{C}, C \in
	\hat{\mathcal{C}}
\end{alignat}

Where are $N_k$ and $M_k$ are constants of value $\alpha (|E_k^{+}| + 1)$ and $(1 -
	\alpha ) (|E^{-}_k| + 1)$, respectively.

Note also that \eqref{eq:ecp-a-alpha-constraint} involves a strict inequality,
which is not allowed by the definition of
\acrshort{MIP} or \acrshort{LP}. However, this constraint can easily be
transformed into a valid
and equivalent formulation by the means of a small $\epsilon > 0$ (generally
we can choose $\epsilon < \alpha \cdot 10^{-10}$), so that
it becomes
\begin{equation*}
	-N_k z_k \leq \sum^{}_{ij \in E^-_k} a_{ij}^{k}  - \alpha \sum^{}_{ij
		\in E_k}
	a_{ij} ^{k} - \epsilon \leq M_{k} (1 - z_{k})  \quad\quad \forall T_{k} \in
	\mathcal{T} _{C}, C \in \mathcal{\hat{C}}.
\end{equation*}
We will however use \eqref{eq:ecp-a-alpha-constraint} for simplifying notation.

This problem requires the introduction of variables $a_{ij}^{k}$,
associated to edges \eqref{eq:ecp-a-domain-2}, which
generally take value one if they are associated to an edge induced by the
set of vertices considered as solution (i.e. $y_i$ with value one). Note that,
in order to contribute to the score, $x_{ij}^{k}$ also require that the
corresponding thread $T_k \in S_C(U)$. The
other variables have the same meaning as in MIP~\eqref{eq:ecp-exact1}-\eqref{eq:ecp-thread-def1}.

\begin{theorem}
	\label{th:ecp-mip}
	Let $G = \{G_k = (V,E_k) \}_k$ be an \emph{Interaction Graph} and $\alpha \in
		[0, 1]$. Then

	\begin{equation}
		\max_{U \subseteq V} \xi(U) = \text{OPT(MIP)}
	\end{equation}

	where $OPT(MIP)$ denotes the optimal solution to
	MIP~\eqref{eq:ecp-exact2}-\eqref{eq:ecp-z-domain-2}.
\end{theorem}
\begin{proof}
	We will prove the theorem by showing that $LHS \geq RHS$ and that $LHS \leq
		RHS$.
	\begin{claim}
		\label{th:claim-v-b-xi2}
		For any $U \subseteq V$, the
		MIP~\eqref{eq:ecp-exact2}-\eqref{eq:ecp-z-domain-2} gets value $\geq \xi(U)$.
	\end{claim}

	It is easy to see that by choosing $x_{ij}^{k}, \; y_i, \; z_k$ as in
	Claim~\ref{th:claim-v-b-xi} and
	\begin{equation*}
		a_{ij}^{k} = \begin{cases}
			1 & \text{if } e_{ij} \in E_k[U] \\
			0 & \text{otherwise}
		\end{cases}
	\end{equation*}
	all the constraints of the new formulation are satisfied and
	Claim~\ref{th:claim-v-b-xi2} is consequently proved for
	MIP~\eqref{eq:ecp-exact2}-\eqref{eq:ecp-z-domain-2}.

	We will instead focus on proving the analogous of Claim~\ref{th:claim-xi-b-v}.
	\begin{claim}
		\label{th:claim-xi-b-v2}
		Given a feasible solution of
		MIP~\eqref{eq:ecp-exact2}-\eqref{eq:ecp-z-domain-2} with value $v$ we can
		construct $U \; s.t. \; \xi(U) \geq v$ for any $\alpha$.
	\end{claim}

	\begin{proof}
		Let $U \coloneqq \{ v_i \; s.t. \; y_i = 1\} $. We will not prove
		some results in Claim~\ref{th:claim-xi-b-v} which still hold.

		Due to \eqref{eq:ecp-a-ij-g-i-j2}-\eqref{eq:ecp-a-ij-l-j2} we
		have that
		\begin{equation}
			a_{ij}^{k} = 1 \iff y_i = 1 \land y_j = 1
		\end{equation}
		i.e. all and only the edges induced by $U$ will have the corresponding
		$a_{ij}^{k} = 1$. Therefore,
		\begin{align}
			\label{eq:ecpp-a-E-sets}
			|E^{-}_{k}[U]| & = \sum^{}_{ij \in E^-_k} a_{ij}^{k}, &
			|E_{k}[U]|     & = \sum^{}_{ij \in E_k } a_{ij}^{k}.
		\end{align}
		Consider now a thread $T_k \in \mathcal{S}_C(U)$. By definition, we
		have that
		\begin{align}
			\eta(T_k) \leq \alpha & \implies \frac{|E^{-}_{k}[U]|}{|E_{k}[U]|} \leq \alpha \\
			\label{eq:ecpp-nc-thread2}
			                      & \implies |E^{-}_{k}[U]| - \alpha \cdot
			|E_{k}[U]| \leq 0.
		\end{align}
		Now suppose $z_k = 0$. This means that
		\eqref{eq:ecp-a-alpha-constraint} resolves to
		\begin{equation*}
			0 < \sum^{}_{ij \in E^-_k} a_{ij}^{k}  - \alpha \sum^{}_{ij
				\in E_k}
			a_{ij} ^{k} \leq M_{k}
		\end{equation*}
		Which is not satisfied due to \eqref{eq:ecpp-nc-thread2} and
		\eqref{eq:ecpp-a-E-sets}, since they imply that $\sum^{}_{ij \in E^-_k} a_{ij}^{k}  - \alpha \sum^{}_{ij
				\in E_k}
			a_{ij} ^{k} \leq 0$. This justifies
		\eqref{eq:ecp-a-alpha-constraint}.

		Thus, $z_k = 1$. This
		means that the constraint resolves to
		\begin{equation*}
			-N_k = -\alpha (|E^{+}_{k}[U]| + 1)< \sum^{}_{ij \in E^-_k} a_{ij}^{k}  -
			\alpha \sum^{}_{ij \in E_k} a_{ij} ^{k}
		\end{equation*}
		which is satisfied since
		\begin{align}
			\sum^{}_{ij \in E^-_k} a_{ij}^{k}  - \alpha \sum^{}_{ij \in E_k}
			a_{ij} ^{k} = & |E^{-}_{k}[U]| - \alpha \cdot |E_{k}[U]|                \\
			=             & (1- \alpha)|E^{-}_{k}[U]| - \alpha \cdot |E^{+}_{k}[U]| \\
			\geq          & - \alpha \cdot |E^{+}_{k}[U]|                           \\
			>             & - N_k.
		\end{align}

		Consequently, because of \eqref{eq:ecpp-z-iff-xij}, we have that
		\begin{equation}
			T_k \in \mathcal{S}_C(U) \iff x_{ij}^{k} = 1 \; \forall \;i, j \in U
		\end{equation}
		meaning that each \emph{non-controversial} $T_k$ will contribute to
		$\xi$ and $v$ with the same score, i.e.
		\begin{equation*}
			\sum^{}_{ij \in E^{+}_k } x_{ij}
				^{k} - \sum_{ij \in E^{-} _k} x_{ij} ^{k} = |E^{-}_{k}[U]| -
			|E_{k}[U]|.
		\end{equation*}

		Now consider $T_k$ \emph{controversial} and suppose $z_k = 1$. This means that
		\eqref{eq:ecp-a-alpha-constraint} resolves to
		\begin{equation*}
			-N_k < \sum^{}_{ij \in E^-_k} a_{ij}^{k}  - \alpha \sum^{}_{ij
				\in E_k}
			a_{ij} ^{k} \leq 0,
		\end{equation*}
		where the second inequality is not satisfied due to \eqref{eq:ecpp-a-E-sets} and by
		definition of \emph{controversial}. So $z_k$ must be $0$.
		Then, we have
		\begin{align*}
			\sum^{}_{ij \in E^-_k} a_{ij}^{k}  - \alpha \sum^{}_{ij
				\in E_k}
			a_{ij} ^{k} = & |E^{-}_{k}[U]| - \alpha \cdot |E_{k}[U]|                \\
			=             & (1- \alpha)|E^{-}_{k}[U]| - \alpha \cdot |E^{+}_{k}[U]| \\
			\leq          & (1- \alpha )\cdot |E^{-}_{k}[U]|                        \\
			\leq          & M_k,
		\end{align*}
		thus satisfying \eqref{eq:ecp-a-alpha-constraint}. Therefore, $x_{ij}^{k} = 0 \; \forall \;i, j, \in V$ (because of
		\eqref{eq:ecp-t2}).
		This means that the contribution of a controversial $T_k$ is the same in $\xi$ and $v$ and,
		in general, $\xi(U) = v$, proving the claim.
	\end{proof}

	Due to Claims~\ref{th:claim-v-b-xi2} and \ref{th:claim-xi-b-v2} the theorem
	is proved.
\end{proof}

\subsection{A MIP Model for the \acrshort{D-ECP}}%
\label{sub:a_mip_model_for_the_d_ecp}

Similarly to the \acrshort{ECP}, here we propose a \acrshort{MIP} model for
finding a solution for the \acrshort{D-ECP}, $\alpha \in [0, 1]$.

For simplifying notation we define $E_{k} \coloneqq E(T_{k}), T_{k} \in
	\mathcal{T}_{C}, C \in \mathcal{\hat{C}}$.

\begin{equation}
	\label{eq:d-ecp-objective}
	\text{maximize} \; \sum_{ T_{k} \in \mathcal{T}_{C}, \; C \in
		\mathcal{\hat{C}} } \big( \sum^{}_{ij \in E^+_k} x_{ij}
	^{k} - \sum_{ij \in E^-_k} x_{ij} ^{k} \big)
\end{equation}
\begin{center} subject to \end{center}
\begin{alignat}{3}
	\label{eq:d-ecp-a-ij-l-bi}
	                                           &                                           & a_{ij}^{k} \leq b_{i} \quad\quad                                              & \forall ij \in E_k                        \\
	\label{eq:d-ecp-a-ij-l-bj}
	                                           &                                           & a_{ij}^{k} \leq b_{j} \quad\quad                                              & \forall ij \in E_k                        \\
	\label{eq:d-ecp-a-ij-g-ijk}
	                                           &                                           & a _{ij} ^{k} \geq - 1 + b_i + b_j \quad\quad                                  & \forall ij \in E_k                        \\
	\label{eq:d-ecp-alpha-constraint}
	                                           &                                           & -N_{k} z_k < \sum^{}_{ij \in E^-_k} a_{ij}^{k}  - \alpha \sum^{}_{ij \in E_k}
	a_{ij} ^{k}  \leq M_k (1 - z_k) \quad\quad & \forall T_{k} \in \mathcal{T} _{C}, C \in
	\hat{\mathcal{C}}                                                                                \\
	\label{eq:d-ecp-edge-charikar1}
	                                           &                                           & x _{ij}^{k}  \leq y_i \quad\quad                                              & \forall ij \in E_{k}                      \\
	\label{eq:d-ecp-edge-charikar2}
	                                           &                                           & x _{ij} ^{k} \leq y_j \quad\quad                                              & \forall ij \in E_k                        \\
	\label{eq:d-ecp-vertex-charikar1}
	                                           &
	                                           & \sum^{}_{i \in V} y_i = 1
	\quad\quad
	                                           &                                                                                \\
	\label{eq:d-ecp-vertex-l-b}
	                                           &                                           & y_i \leq b_i \quad\quad                                                       & \forall i \in V                           \\
	\label{eq:d-ecp-vertex-g-bi-yj}
	                                           &                                           & y_i \geq -1 + b_i + y_j \quad\quad                                            & \forall i,j \in V                         \\
	\label{eq:d-ecp-x-l-sum1}
	                                           &
	                                           & x_{ij}^{k} \geq -2 +
	a_{ij} ^{k} + z_k + y_i \quad\quad         & \forall ij \in E_k                                                                                \\
	\label{eq:d-ecp-x-l-sum2}
	                                           &
	                                           & x_{ij}^{k} \geq -2 +
	a_{ij} ^{k} + z_k + y_j \quad\quad         & \forall ij \in E_k                                                                                \\
	\label{eq:d-ecp-x-l-a}
	                                           &                                           & x_{ij} ^{k} \leq a_{ij} ^{k} \quad\quad                                       & \forall ij \in E_k                        \\
	\label{eq:d-ecp-x-l-z}
	                                           &                                           & x_{ij} ^{k} \leq z_k \quad\quad                                               & \forall T_{k} \in \mathcal{T} _{C}, C \in
	\hat{\mathcal{C}}                                                                                \\
	\label{eq:d-ecp-a-ij}
	                                           &                                           & a _{ij} ^{k}  \in \{0, 1\} \quad\quad                                         & \forall ij \in E_k                        \\
	\label{eq:d-ecp-b-i}
	                                           &                                           & b _{i} \in \{0, 1\} \quad\quad                                                & \forall i \in V                           \\
	\label{eq:d-ecp-y-i}
	                                           &                                           & y _{i} \geq 0 \quad\quad                                                      & \forall i \in V                           \\
	\label{eq:d-ecp-x-ij}
	                                           &                                           & x _{ij} ^{k}  \geq 0 \quad\quad                                               & \forall ij \in E_k                        \\
	\label{eq:d-ecp-z-k}
	                                           &                                           & z _{k} \in \{0, 1\} \quad\quad                                                & \forall T_{k} \in \mathcal{T} _{C}, C \in
	\hat{\mathcal{C}}
\end{alignat}

Where are $N_k$ and $M_k$ are constants of value $\alpha (|E_k^{+}| + 1)$ and $(1 -
	\alpha ) ( |E^{-}_k| + 1)$, respectively.
Again the strict inequality of \eqref{eq:d-ecp-alpha-constraint} can be
transformed into a valid constraint as explained in
\autoref{sub:a_mip_model_for_the_ecp}.
% In this formulation we introduce variables $b_i$, associated to vertices, that
% take the meaning of variables $y_i$ in

\begin{theorem}
	\label{th:d-ecp-mip}
	Let $G = \{G_k = (V,E_k) \}_k$ be an \emph{Interaction Graph} and $\alpha \in
		[0, 1]$.

	\begin{equation}
		\max_{U \subseteq V} \psi(U) = \text{OPT(MIP)}
	\end{equation}

	where $OPT(MIP)$ denotes the optimal solution to
	MIP~\eqref{eq:d-ecp-objective}-\eqref{eq:d-ecp-z-k}.
\end{theorem}

\begin{proof}
	Similarly to \autoref{th:ecp-mip} we will prove this equality by $2$
	inequalities: $RHS \geq LHS$ and $LHS \geq RHS$

	\begin{claim}
		For any $U \subseteq V$, the
		MIP~\eqref{eq:d-ecp-objective}-\eqref{eq:d-ecp-z-k} gets value at least
		$\psi(U)$.
	\end{claim}

	\begin{proof}
		Let $c = 1 / |U|$. We construct a feasible solution for
		MIP~\eqref{eq:d-ecp-objective}-\eqref{eq:d-ecp-z-k} as follows:

		\begin{align}
			\label{eq:ecpp-y}
			y_i        & = \begin{cases}
				c, & \text{if } v_{i} \in U, \\
				0, & \text{otherwise,}
			\end{cases} \quad & \forall v_i \in U                                \\
			b_i        & = \begin{cases}
				1, & \text{if } v_{i} \in U, \\
				0, & \text{otherwise,}
			\end{cases}\quad  & \forall v_i \in U                                \\
			\label{eq:ecpp-z}
			z_k        & = \begin{cases}
				1, & \text{if } T_{k} \in \mathcal{S}_C(U), \; C \in
				\mathcal{\hat{C}},                                   \\
				0, & \text{otherwise,}
			\end{cases} \quad & \forall T_k \in \mathcal{T}_C, C \in
			\mathcal{\hat{C}}                                                                                \\
			\label{eq:ecpp-x}
			a_{ij}^{k} & = \begin{cases}
				1, & \text{if } e_{ij} \in E_{k}[U], \; T_{k} \in \mathcal{T} _C, \; C \in
				\mathcal{\hat{C}},                                                         \\
				0, & \text{otherwise,}
			\end{cases} \quad & \forall e_{ij} \in E_k, T_k \in \mathcal{T}_C, C
			\in \mathcal{\hat{C}}                                                                              \\
			x_{ij}^{k} & = \begin{cases}
				c, & \text{if } e_{ij} \in E_{k}[U], \; T_{k} \in \mathcal{S}_C(U), \; C \in
				\mathcal{\hat{C}},                                                           \\
				0, & \text{otherwise.}
			\end{cases}       & \forall e_{ij} \in E_k, T_k \in \mathcal{T}_C, C
			\in \mathcal{\hat{C}}
		\end{align}

		\eqref{eq:d-ecp-a-ij-l-bi}-\eqref{eq:d-ecp-a-ij-g-ijk} are easily
		satisfied since $a_{ij}^{k} = 1 \iff b_i = 1 \land b_j = 1$, meaning
		that an edge is induced (thus $a_{ij}^{k} = 1$) if and only if $ v_i,
			v_j \in U$. The same idea applies to
		\eqref{eq:d-ecp-edge-charikar1}-\eqref{eq:d-ecp-edge-charikar2}.
		\eqref{eq:d-ecp-vertex-l-b} is trivial and
		\eqref{eq:d-ecp-x-l-a}-\eqref{eq:d-ecp-x-l-z} hold since
		$\mathcal{S}_C(U) \subseteq \mathcal{T}_C $. It is also easy to see that
		\eqref{eq:d-ecp-vertex-g-bi-yj} is satisfied since we defined $y_i$
		and $b_i$ s.t. $b_i = 1$ if and only if $y_i = c$. Furthermore, since
		$y_i = c$ if and only if $
			y_i \in U$ then
		\begin{equation*}
			\sum^{}_{i \in V} y_i = \sum^{}_{i \in U} c = 1
		\end{equation*}
		and \eqref{eq:d-ecp-vertex-charikar1} is also satisfied.

		Let us know consider $T_k \in \mathcal{S}_C(U)$ which by definition
		implies $z_k = 1$. Then,
		\begin{align}
			\eta(T_k[U]) \leq \alpha & \implies
			\frac{|E^{-}_{k}[U]|}{|E_{k}[U]|} \leq \alpha               \\
			                         & \implies |E^{-}_{k}[U]| - \alpha
			(|E_{k}[U]|) \leq 0.
		\end{align}

		Thus, due to the definition of $a_{ij}^k$, the second inequality of \eqref{eq:d-ecp-alpha-constraint} is true;
		the first one is also satisfied since
		\begin{align}
			\sum^{}_{ij \in E^-_k} a_{ij}^{k}  - \alpha \sum^{}_{ij \in E_k}
			a_{ij} ^{k} & = |E^{-}_{k}[U]| - \alpha \cdot |E_{k}[U]| \\
			            & = (1- \alpha)|E^{-}_{k}[U]| - \alpha \cdot
			|E^{+}_{k}[U]|                                           \\
			            & \geq - \alpha \cdot |E^{+}_{k}[U]|         \\
			            & > N_k.
		\end{align}

		\eqref{eq:d-ecp-x-l-sum1}-\eqref{eq:d-ecp-x-l-sum2} are true
		since in this case (for $z_k = 1$) by definition $a_{ij}^{k} = 1
		$ implies $x_{ij}^{k} = c$. If instead $T_k \not\in S_c$ and $z_k = 0$ we
		have that

		\begin{align}
			\eta(T_k[U]) > \alpha & \implies
			\frac{|E^{-}_{k}[U]|}{|E_{k}[U]|} > \alpha                                \\
			                      & \implies |E^{-}_{k}[U]| - \alpha (|E_{k}[U]|) > 0
		\end{align}

		and consequently the first inequality of
		\eqref{eq:d-ecp-alpha-constraint} is satisfied. Also
		\begin{align}
			\sum^{}_{ij \in E^-_k} a_{ij}^{k}  - \alpha \sum^{}_{ij \in E_k}
			a_{ij} ^{k} & = |E^{-}_{k}[U]| - \alpha \cdot |E_{k}[U]|
			\\ & =
			(1- \alpha)|E^{-}_{k}[U]| - \alpha \cdot |E^{+}_{k}[U]|  \\
			            & \leq (1 -\alpha) \cdot |E^{-}_{k}[U]|      \\
			            & < M_k.
		\end{align}

		Thus, also the second inequality is true. Also,
		\eqref{eq:d-ecp-x-l-sum1}-\eqref{eq:d-ecp-x-l-sum2} are trivially
		satisfied.

		\bigskip
		Consequently an edge contributing to $\psi(U)$ will also count in the
		objective function by $c$. So, for a given thread $T_k \in \mathcal{S}_C, C \in \mathcal{\hat{C}}$

		\begin{align*}
			\sum^{}_{ij \in E^+_k} x_{ij} ^{k} - \sum_{ij \in E^{-}
			(T_{k})} x_{ij} ^{k} & = \sum^{}_{ij \in E^{+}_k[U] } c - \sum_{ij \in E^{-}
			_k[U]} c                                                                     \\
			                     & = c (|E^{+}_{k}[U]| - |E^{-}_{k}[U]|)                 \\
			                     & = \frac{|E^{+}_{k}[U]| -
			|E^{-}_{k}[U]|}{|U|}.
		\end{align*}

		Thus, for each thread we have the same contribution to both $\psi(U)$
		and the objective function of
		MIP~\eqref{eq:d-ecp-objective}-\eqref{eq:d-ecp-z-k}. Therefore, the sum through
		all the threads will correspond as well.
	\end{proof}

	\begin{claim}
		Given a feasible solution of
		MIP~\eqref{eq:d-ecp-objective}-\eqref{eq:d-ecp-z-k} with value $v$ we can
		construct $U \; s.t. \; \psi(U) \geq v$.
	\end{claim}

	\begin{proof}

		Let us define $U \coloneqq \{ v_i \; s.t. \; y_i \neq 0\}$; consider
		$v_i$ s.t. $y_i \neq 0$ (if no such vertex exists then the proof is
		trivial) and let $c \coloneqq y_i$. By
		\eqref{eq:d-ecp-vertex-g-bi-yj} and \eqref{eq:d-ecp-vertex-l-b}
		we have that
		\begin{gather}
			\label{eq:d-ecpp-y-in}
			\forall v_j \in V, \; y_j \in \{ 0, c\}, \\
			\forall i, j \in V, \; b_i = 1 \land b_j = 1 \implies y_i = y_j =
			c.
		\end{gather}

		Furthermore, due to \eqref{eq:d-ecp-a-ij-l-bi}-\eqref{eq:d-ecp-a-ij-g-ijk} we
		have that
		\begin{equation}
			\label{eq:d-ecpp-a-iff}
			a_{ij}^{k} = 1 \iff b_i = 1 \land b_j = 1.
		\end{equation}

		Now consider some $x_{ij}^{k} > 0 $. By \eqref{eq:d-ecp-x-l-a}
		$x_{ij}^{k} > 0$ implies $a _{ij}^{k} = 1$ and, thanks to
		\eqref{eq:d-ecp-x-l-z}, $x_{ij}^{k} > 0$ implies $z_k = 1$. Thus, combining
		this to the results in \eqref{eq:d-ecpp-y-in} and
		\eqref{eq:d-ecpp-a-iff}
		\begin{gather}
			\label{eq:d-ecpp-x-impl}
			x_{ij}^{k} > 0 \implies a_{ij}^{k} = 1 \land z_k =1, \\
			\label{eq:d-ecpp-z-impl}
			z_k = 1 \implies x_{i'j'}^{k} = c, \; \forall i', j' \in U, \\
			\label{eq:d-ecpp-za-impl}
			z_k = 1 \land a_{ij}^{k} = 1 \implies x_{ij}^{k} = c.
		\end{gather}
		This means that if exists $ x_{ij}^{k} > 0$ then all the variables
		$x_{i'j'}^{k}$ associated to edges induced by $U$ have value $c$.
		Also, since we have that $z_k = 1$, \eqref{eq:d-ecp-alpha-constraint}
		will correspond to

		\begin{equation}
			\sum^{}_{ij \in E^-_k} a_{ij}^{k}  - \alpha \sum^{}_{ij \in E_k}
			a_{ij} ^{k} \leq 0.
		\end{equation}
		We showed in \eqref{eq:d-ecpp-x-impl} and \eqref{eq:d-ecpp-za-impl} that $a_{ij}^{k} = 1 \land z_k
			= 1$ if and only if $x_{ij}^{k} > 0 $. In other other words, the edges contributing to the objective
		function are part of a \emph{non-controversial} subgraph, i.e. the
		corresponding thread $T_k \in
			\mathcal{S}_C(U)$ and it will contribute to $\psi(U)$.

		Now suppose exists $ T_k \in \mathcal{S}_C(U), \; C \in \mathcal{\hat{C}},
			\; s.t. \; z_k = 0$. By definition of $\mathcal{S}_C(U)$ we have that

		\begin{align}
			\eta(T_k[U]) \leq \alpha & \implies |E^{-}_{k}[U]| - \alpha |E_{k}[U]|
			\\
			                         & \implies \sum^{}_{ij \in E^-_k}
			a_{ij}^{k}  - \alpha \sum^{}_{ij \in E_k}
			a_{ij} ^{k} \leq 0,
		\end{align}
		because $a_{ij}^{k} = 1$ for all edges induced by $U$. But, if $z_k =
			0$ then constraint \eqref{eq:d-ecp-alpha-constraint} is violated,
		and this would be a \emph{contradiction}. So no such $T_k$ exists and $T_k
			\in \mathcal{S}_C(U) \iff z_k = 1$.

		This means that a thread contributing to the objective function of
		MIP~\eqref{eq:d-ecp-objective}-\eqref{eq:d-ecp-z-k} also counts towards
		$\psi(U)$. Due to \eqref{eq:d-ecpp-z-impl} we can then write, for
		$T_k \in \mathcal{S}_C(U)$

		\begin{align*}
			\sum^{}_{ij \in E^+_k} x_{ij} ^{k} - \sum_{ij \in E^{-}
			(T_{k})} x_{ij} ^{k} & = \sum^{}_{ij \in E^{+}_k[U] } c - \sum_{ij \in E^{-}
			_k[U]} c                                                                     \\
			                     & = c (|E^{+}_{k}[U]| - |E^{-}_{k}[U]|)                 \\
			                     & = \frac{|E^{+}_{k}[U]| -
			|E^{-}_{k}[U]|}{|U|}.
		\end{align*}

		Thus, each threads equally contributes to $\psi(U)$ and the objective
		function of MIP~\eqref{eq:d-ecp-objective}-\eqref{eq:d-ecp-z-k}.
		Therefore, $\psi(U) \geq v$.
	\end{proof}

	This concludes the proof of the theorem.

\end{proof}

\section{Heuristics}%
\label{sub:approximation_algorithms}

We now present some heuristic algorithms for solving the \acrshort{ECP} and
\acrshort{D-ECP}. We start by describing how $\xi(U)$ and $\psi(U)$ can be
computed in practice.

Let $\textsc{Score}_{\xi} (U)$ and $\textsc{Score}_{\psi} (U)$ be the functions
computing the \emph{Echo Chamber Score} and \emph{Densest-Echo Chamber Score}
of $U$, respectively. These subroutines iterate over the edges of the vertices
in $U$, ignoring those that are not induced by $U$, and counting for each
thread $T \in \mathcal{T}_{C}, C \in \mathcal{\hat{C}} $ the number of edges
and negative edges to see which are \emph{controversial}, then calculating
their contributions (\autoref{alg:score_xi} shows in detail
$\textsc{Score}_\xi$; $\textsc{Score}_\psi$ can simply be computed as
$\textsc{Score}_\xi(U)/|U|$).  Note that this algorithm operates also on the
weights $w_{ij}^{k}$ of the edges. This is something that is "implicitely" done
in the \acrshort{MIP}s, as the sums iterate over positive and negative edges.

\begin{algorithm}
	\SetAlgoLined
	\KwIn{Interaction graph $G = \{G_k = (V,E_k) \}_k$, a set of users $U
			\subseteq V$, $\alpha \in [0, 1]$}
	\KwResult{$\xi(U)$}
	$N^{+} (T) \leftarrow 0, \; N^{-} (T) \leftarrow 0\; $ for all threads $T
		\in \mathcal{T}_{C}, C \in \mathcal{\hat{C}}   $ \;

	\ForEach{$v_{i} \in U$}{
		$S_i \leftarrow$ edges starting from $v_{i} $ \;
		\ForEach{$e_{ij} \in S_i$ \textbf{if} $v_{j} \in U$}{
			$T_{ij}  \leftarrow$ thread of $e_{ij} $ \;
			$w_{ij}  \leftarrow$ weight of $e_{ij} $ \;

			\uIf{$w_{ij} \geq 0$}{
				$N^{+}(T_{ij} ) \leftarrow N^{+}(T_{ij} ) + 1$ \;
			}\Else{
				$N^{-}(T_{ij} ) \leftarrow N^{-}(T_{ij} ) + 1$ \;
			}

		}
	}

	$\xi(U) \leftarrow 0$ \;
	$\eta(T) \leftarrow\frac{N^{-}(T)}{(N^{-}(T) + N^{+} (T))} \; $ for all threads $T
		\in \mathcal{T}_{C}, C \in \mathcal{\hat{C}}   $  \;
	\ForEach{$T\in \mathcal{T}_{C}, C \in \mathcal{\hat{C}}$ \textbf{if}
		$ \eta(T) \leq \alpha $}{
		$\xi(U) \leftarrow \xi(U) + N^{+}(T) - N^{-}(T)$
	}
	\Return $\xi(U)$ \;

	\caption{The $\textsc{Score}_{\xi}  $ subroutine}
	\label{alg:score_xi}
\end{algorithm}

We present our algorithms focusing on \acrshort{ECP} in detail. They can generally be
adapted for solving the \acrshort{D-ECP} by replacing calls to
$\textsc{Score}_{\xi}$ with $\textsc{Score}_{\psi}$.

\subsection{The $\beta$-Algorithm}%
\label{ssub:the_beta_approach}

The $\beta$-algorithm is an heuristic for the \acrshort{ECP}. The
$\beta$-algorithm (\autoref{alg:algorithm_beta}) constructs a set of users $U$ by
iteratively adding the node which increases the most the score or removing from
$U$ the one which contributes the least, stopping when the score cannot be
increased by adding a node. The frequencies of addition and removal are regulated
through a parameter $\beta \in [0, 1]$ (for smaller values a higher density is to be expected,
generally).

$U$ is initialized by sampling one node from the graph. There are two possible
approaches in doing that: one is uniformly;
the other is using probabilities proportional to the number
of positive edges each node has.

\begin{algorithm}
	% \KwIn{Interaction graph G, $\alpha \in [0,1]$} \;
	\SetAlgoLined
	% \KwResult{Write here the result }
	$U = \{$ a single random node $\}$\;
	$\xi(U) = 0$ \;
	\While{ $\exists \; v_{j} \; s.t. \; \textsc{Score}_{\xi} (U \cup \; \{
			v_{j} \} )> \xi(U)$}{
		$N(U) \leftarrow $ neighbours of vertices in $U$ in the graph $G$ \;
		Flip a coin which gives head with probability $\beta$ \;
		If head\:  {
			$U \leftarrow U \cup \; \{ \arg\max_{v_{j} \in N(U)}
				\textsc{Score}_{\xi} (U \cup \;
				\{ v_{j} \}) \}$ \;
		}

		else\: {
			$U \leftarrow U \setminus \{ \arg\max_{v_{j} \in U }
				\textsc{Score}_{\xi} (U \setminus \{ v_{j} \}) \}$ \;
		}

	}
	\Return $\textsc{Score}_{\xi} (U)$ \;
	\caption{$\beta$-algorithm}
	\label{alg:algorithm_beta}
\end{algorithm}

In addition, one may also want to ignore a node when it is removed for the
next iterations, in order to prevent the algorithm from repeatedly adding
and taking out from $U$ the same vertex.

The result is clearly dependent on the choice of the initial node. For this
reason the process should be repeated for different initial nodes.

One of the limitations of this approach is that the algorithm will only find
sets of users that are connected in the original graph. This is due to the fact
that it will never add a node which is not connected to any of the vertices in
$U$, as it produces an increase of the score equal to $0$.

\subsection{Peeling Algorithm}%
\label{ssub:peeling_algorithm}

Inspired to the greedy algorithm proposed in \cite{charikar2000greedy}, the
peeling
algorithm starts by considering a set $U = V$,
iteratively removing the worst nodes (\autoref{alg:algorithm_peeling}).

\begin{algorithm}
	\SetAlgoLined
	% \KwResult{Write here the result }
	$U = V$\;
	$S = \textsc{Score}_{\xi}(U)$ \;
	\While{$U \neq \emptyset$ }{
		$v = \arg\max_{v_{j} \in U }
			\textsc{Score}_{\xi} (U \setminus \{ v_{j} \})$ \; $U \leftarrow U \setminus \{ v \}$ \;

		$S_i = \textsc{Score}_{\xi} (U) $ \;
	}
	\Return $\arg\max_{i}S_i$ \;

	\caption{Peeling algorithm}
	\label{alg:algorithm_peeling}
\end{algorithm}

If many nodes produce the same score, then one of them is
randomly selected (or, alternatively, the one which has the highest fraction of
negative edges).

\subsection{Rounding Algorithm}%
\label{ssub:rounding_algorithm}

This algorithm reconstructs a solution starting from the results of the
relaxation of the exact models and is again inspired by the algorithm for
reconstructing the exact solution from the \acrshort{LP} model in
\cite{charikar2000greedy}.

More specifically, our relaxation of
MIP~\eqref{eq:ecp-exact2}-\eqref{eq:ecp-z-domain-2} replaces constraints
\eqref{eq:ecp-vertex-def2} and \eqref{eq:ecp-z-domain-2} with
\begin{gather}
	0 \leq y_i \leq 1, \\
	0 \leq z_i \leq 1.
\end{gather}
We now have to solve an \acrshort{LP} problem.

Let $\tilde{E}$ be the sequence of edges ordered in descending order by $x_{ij}
		^{k} $. The algorithm (\autoref{alg:algorithm_rounding}) iterates over
the edges in $\tilde{E}$, adding them to a \emph{dummy} graph $\hat{G}$, also eventually
adding incident nodes if not already present. At each iteration it computes
the score of the vertices in the graph $\hat{G}$ and the score
of the vertices of each component in the graph, keeping track of the best
result.

\begin{algorithm}
	\SetAlgoLined
	Solve the relaxation of MIP~\eqref{eq:ecp-exact2}-\eqref{eq:ecp-z-domain-2}
	\;
	$\hat{G} \leftarrow $ empty graph \;
	$\hat{V} \leftarrow $ vertices of $\hat{G}$ \;
	$S = 0$

	\ForEach{ $e_{ij}^{k} \in \tilde{E}$ in descending order of $x_{ij}^{k}$ }{
		$\hat{V} \leftarrow \hat{V} \bigcup \{ v_{i} \}$ \textbf{if} $v_i
			\not\in \hat{V}$ \;
		$\hat{V} \leftarrow \hat{V} \bigcup \{ v_{j} \}$ \textbf{if} $v_j
			\not\in \hat{V}$ \;

		$S \leftarrow \max(S, \; \textsc{Score}_{\xi}(\hat{V})  )$

		\ForEach{component $C$ in $\hat{G}$}{
			$S \leftarrow \max(S, \; \textsc{Score}_{\xi}(C)  )$
		}

	}

	\Return S \;
	\caption{Rounding algorithm}
	\label{alg:algorithm_rounding}
\end{algorithm}

The motivation for the algorithm can be seen in
Figures~\ref{fig:rounding-original}-\ref{fig:rounding-relaxed}: the problem
relaxation involves a solution whose value assigned to the edges can be used to
find subgraphs with many positive edges by using each separate component as set
of users $U$.

\begin{figure}
	\begin{center}
		\begin{subfigure}[b]{0.4\textwidth}
			\centering
			\tikzfig{tex/tikz/rounding_original_t1}
			\caption{$T_1$}
			\label{fig:rounding-original-t1}
		\end{subfigure}
		\begin{subfigure}[b]{0.4\textwidth}
			\centering
			\tikzfig{tex/tikz/rounding_original_t2}
			\caption{$T_2$}
			\label{fig:rounding-original-t2}
		\end{subfigure}
	\end{center}
	\caption{Example original \emph{Interaction Graph} $G$}
	\label{fig:rounding-original}
\end{figure}
\begin{figure}
	\begin{center}
		\begin{subfigure}[b]{0.4\textwidth}
			\centering
			\tikzfig{tex/tikz/rounding_integer_t1}
			\caption{$T_1$}
			\label{fig:rounding-integer-t1}
		\end{subfigure}
		\begin{subfigure}[b]{0.4\textwidth}
			\centering
			\tikzfig{tex/tikz/rounding_integer_t2}
			\caption{$T_2$}
			\label{fig:rounding-original-t2}
		\end{subfigure}
	\end{center}
	\caption{Exact solution of the example in \autoref{fig:rounding-original},
		$\alpha = 0.4$}
	\label{fig:rounding-integer}
\end{figure}
\begin{figure}
	\begin{center}
		\begin{subfigure}[b]{0.4\textwidth}
			\centering
			\scalebox{0.8}{
				\tikzfig{tex/tikz/rounding_relaxed_t1}
			}
			\caption{$T_1$, where $z_1 = 0.66$}
			\label{fig:rounding-relaxed-t1}
		\end{subfigure}
		\begin{subfigure}[b]{0.4\textwidth}
			\centering
			\scalebox{0.8}{
				\tikzfig{tex/tikz/rounding_relaxed_t2}
			}
			\caption{$T_2$, where $z_2 = 1.0$}
			\label{fig:rounding-relaxed-t2}
		\end{subfigure}
	\end{center}
	\caption{Solution of the relaxation of $G$ of
		\autoref{fig:rounding-original}, $\alpha = 0.4$}
	\label{fig:rounding-relaxed}
\end{figure}

While one may think from these examples that the relaxation trivially assigns
non-zero values only to positive edges, \autoref{fig:rounding-original2} shows
a case in which a negative edge, $e_{31}$, gets the value of $1$. Furthermore,
in this example the algorithm is able to reconstruct the exact solution of the problem.

\begin{figure}
	\centering
	\tikzfig{tex/tikz/rounding_original2}
	\caption[Example of rounding algorithm finding the exact solution]{Another
		\emph{Interaction graph} example, with only one thread. In
		this case the rounding algorithm is able to find the exact solution by
		selecting all the nodes except for $v_4$. In the result of the
		relaxation all the edges except for $e_{42}$ get the value of $1$.}%
	\label{fig:rounding-original2}
\end{figure}

\section{Alternative Formulations}%
\label{sec:alternative-formulations}

Due to the intrinsic complexity of the problems
(\autoref{ch:complexity}) we define variants of
the \acrshort{ECP} and \acrshort{D-ECP} problems, for some of which we are also able to find an exact solution.

For these new problems we need to define new graphs, obtained by preprocessing
the \emph{interaction graph}.

\subsection{The \acrlong{PA} Graph}%
\label{sub:pa-graph}

Let $G = \{G_k = (V,E_k) \}_k$ be the \emph{interaction graph}, let $E_k$ and
$E^-_k$ denote the edges and negative edges in thread $T_k$,
respectively. We define $\delta(v_{i}, v_{j})$ and
$\delta^{-} (v_{i}, v_{j})$ to be the sum of the edges and negative edges, respectively,
associated to controversial contents between vertices $v_{i} $ and $v_{j}
$, i.e.\

\begin{align}
	\label{eq:}
	\delta(v_{i}, v_{j})   & = \sum^{}_{T_k \in \mathcal{T}_C, C \in
	\mathcal{\hat{C}} } ( \sum^{}_{e_{ij} \in E_k} w_{ij} + \sum^{}_{e_{ji} \in
	E_k} w_{ji} ),
	\\
	\delta^-(v_{i}, v_{j}) & = \sum^{}_{T_k \in \mathcal{T}_C, C \in
	\mathcal{\hat{C}} } ( \sum^{}_{e_{ij} \in E^-_k} w_{ij} + \sum^{}_{e_{ji} \in
	E^-_k} w_{ji} ).
\end{align}

\bigskip

The \acrfull{PA} graph $G_P = (V_{P}, E_{P}) $ is constructed as follows from
$G$:

\begin{itemize}
	\item For any vertex $v_{i} \in V$ add a corresponding vertex in $V_{P} $.
	\item For any pair of vertices $v_i, v_j$ in $G$ let $\eta(v_i,v_j)
		      \coloneqq \frac{\delta^{-} (v_i,v_j)}{\delta (v_i,v_j)} $. If
	      $\eta(v_i,v_j) \leq \alpha $, add a positive edge between $v_{i} $ and
	      $v_{j} $ in $G_{P} $. If, instead, $\eta(v_i,v_j) > \alpha $ or $\delta(v_{i}, v_{j}) =
		      0$ then don't add any edge between the two vertices.
	      % \item don't add any edge otherwise between $v_{i} $ and $v_{j} $
\end{itemize}

The problem then is finding the Densest Subgraph of $G_P$, i.e., if $E_{P} [U]$
is the set of edges induced on $G_P$ by $U \subseteq V$, finding $U$ maximizing

\begin{equation}
	\xi(U) = \frac{|E_{P} [U]|}{|U|}.
\end{equation}

\subsection{The \acrlong{TPA} Graph}%
\label{ssub:the_tpa_graph}

Differently from the previous method, in this case edges are aggregated
separately for each thread.

\bigskip

More specifically, given an \emph{interaction graph} $G = \{G_k = (V,E_k) \}_k$,
let $E(T)$ and
$E^-(T)$ denote the edges and negative edges in thread $T$,
respectively. We define $\delta_{T}(v_{i}, v_{j})$ and
$\delta^{-} _{T}(v_{i}, v_{j})$ to be the sum of the edges and negative edges, respectively,
associated to thread $T$ between vertices $v_{i} $ and $v_{j} $, being $T \in
	\mathcal{T}_{C}, C \in \mathcal{\hat{C}}$, i.e.

\begin{align}
	\label{eq:}
	\delta_T(v_{i}, v_{j})   & = \sum^{}_{e_{ij} \in E(T)} w_{ij} + \sum^{}_{e_{ji} \in
	E(T)} w_{ji},
	\\
	\delta^-_T(v_{i}, v_{j}) & =  \sum^{}_{e_{ij} \in E^-(T)} w_{ij} + \sum^{}_{e_{ji} \in
	E^-(T)} w_{ji}.
\end{align}

We will produce a graph, the \acrfull{TPA} Graph
\begin{equation*}
	G_{TP} = (V_{TP}, E_{TP}),
\end{equation*}
that, differently from the \acrshort{PA} Graph, is a multiplex
graph (each layer representing a thread). The construction of the
\acrshort{TPA} Graph is as follows:

\begin{itemize}
	\item For any vertex $v_{i} \in V$ add a corresponding vertex in $V_{P} $.
	\item For any thread $T \in
		      \mathcal{T}_{C}, C \in \mathcal{\hat{C}}$ we add a layer $T$ to
	      $G_{TP}$.
	\item For any thread $T \in
		      \mathcal{T}_{C}, C \in \mathcal{\hat{C}}$ and pair of vertices
	      $v_i, v_j$ in $G$, let $\eta_{T}(v_i,v_j)
		      \coloneqq \frac{\delta^{-} _{T}(v_i,v_j)}{\delta _{T}(v_i,v_j)} $. If
	      $\eta_{T}(v_i,v_j) \leq \alpha $ add a positive edge between $v_{i} $ and
	      $v_{j} $ in $G_{TP} $, in the layer associated to thread $T$.
	      % \item don't add any edge otherwise between $v_{i} $ and $v_{j} $
\end{itemize}

We can then solve on $G_{TP}$:

\begin{enumerate}
	\item The Densest Subgraph Problem (or, equivalently, the
	      \acrshort{DCS}-MM), which we will refer to as the Densest
	      \acrlong{TPA} (D-\acrshort{TPA}) Problem
	      (\autoref{sub:densest_subgraphs}).
	\item The \acrshort{O2BFF} Problem, more specifically \acrshort{O2BFF}-AM,
	      which we will denote as \acrshort{O2BFF} \acrlong{TPA}
	      (\acrshort{O2BFF}-\acrshort{TPA}) Problem
	      (\autoref{sub:the_o_2_bff_problem}).
\end{enumerate}