Is the following optimization problem NP-hard?
Problem. For a given undirected graph $G=(V,E)$, find an orientation of the edges that minimizes the objective value $\sum_\limits{v\in V} ~d_{out}(v)\times d_{in}(v)$, where $d_{out}$ (resp. $d_{in}$) is the number of out-neighbors (resp. in-neighbors).
Motivation: Assume the edge orientation does not induce any cycle of length 3, then the following algorithm lists all triangles in the input undirected graph in linear memory and in time $O(\sum_\limits{v\in V} ~d_{out}(v)\times d_{in}(v)+m+n)$ where $m$ is the number of edges and $n$ is the number of nodes.
For each node u: For each out-neighbor v of node u: For each out-neighbor w of node v: If u,w is an edge of the input undirected graph: output triangle u,v,w
Implementation details: the graph should be stored in a CSR-like format and, in addition, the edges of the input undirected graph should be put in a hashtable.
Finding the edge orientation that minimizes the quantity should lead to a faster algorithm. I think that the constraint "no induced cycle of length 3" is too complicated and, as a stepping stone, I've decided to formulate the above problem.
The question is related to that one where the edge orientation has to induce a DAG.
Another formulation: The problem can be written as the following Integer Quadratic Programming.
\begin{align}
\text{Minimize} &\qquad \sum_{v\in V} y_v\times (d_v-y_v) &\qquad (IQP)\\
\text{s.t.} &\qquad \forall v \in V, \forall u \in N_v, x_{u,v} \in \{0,1\} \\
&\qquad \forall (u,v) \in E, x_{u,v}+x_{v,u}=1\\
&\qquad \forall v \in V, y_v=\sum_{u \in N_v} x_{u,v}\\
\end{align}
with $N_v$ the set of neighbors of node $v$ in the input undirected graph and $d_v=|N_v|$.
Is (IQP) NP-hard?