Maximizing the sum of the products of endpoints of edges in a graph Let $G$ be a graph with vertex set $V=\{v_1,v_2\dots v_n\}$ and edge set $E$. Let $f:V\rightarrow \mathbb [0,\infty)$ be a real valued function such that $\sum\limits_{i=1}^n f(v_i)=A$.
What is the maximum possible value for $\sum\limits_{uv\in E}f(u)f(v)$?
I remember seeing a sloppy proof a couple years ago that it was $\frac{A^2(k-1)}{2k}$ where $k$ is the clique number of $G$.
It is straightforward that this is a lower bound for the maximum, however I am having trouble proving it is the actual maximum. We can see it is a lower bound by taking a maximal clique and letting $f(v)=\frac{1}{k}$ if the vertex is in the clique and $0$ elsewhere.

I managed to solve it with some help from fractal in AOPS.
For each function $f:V\rightarrow [0,\infty)$ with the desired properties let $pos(f)$ be $\{v\in V|f(v)>0\}$.
Now, consider the set of all such functions in $f$ such that $\sum\limits_{uv\in E}f(u)f(v)$ reaches the maximum-
Take $f$ to be one of functions in this set so that $|pos(f)|$ is minimal.
Suppose $pos(f)$ does not induce a clique, then there are vertices $a,b\in pos(f)$ which are not connected by an edge.
We can now write $\sum\limits_{uv\in E}f(u)f(v)=c_1+c_2f(a)+c_3f(b)$. Where $c_1$ is the sum of the products of the endpoints of all the edges that don't include $a$ or $b$, $c_2$ is the sum of $f(x)$ over all neighbours $x$ of $a$ and $c_3$ is the sum of $f(x)$ over all neighbours $x$ of $b$.
So basically, the edges not containing $a$ or $b$, plus the edges containing $a$ plus the edges containing $b$. So if we suppose $c_2\geq c_3$ then the function $f'$ defined as $f'(x)=f(x)$ if $x\neq a,b$ and $f'(a)=f(a)+f(b)$ and $f'(b)=0$ satisfies the following three conditions:
$\sum\limits(u\in V)f(u)  =A  $.
$\sum\limits_{uv\in E}f(u)f(v)\leq \sum\limits_{uv\in E}f'(u)f'(v)$.
$pos(f')<pos(f)$.
Contradicting the minimality of $|pos(f)|$.
So we can find a function that reaches the maximum and satisfies that $pos(f)$ induces a clique.
So now let $f$ be a function so that $pos(f)$ is a clique with vertex set $\{w_1,w_2\dots w_k\}$. Then we want to maximize:
$\sum\limits_{1\leq i<j\leq k}f(w_i)f(w_j)=\frac{(w_1+w_2+\dots w_k)^2-(w_1^2+w_2^2 + \dots + w_k^2)}{2}=\frac{A^2-(w_1^2+w_2^2 + \dots + w_k^2)}{2}$.
So we want to minimize the sum of squares, by Jensen's inequality or alternatively by AM-QM this occurs when $w_i=\frac{A}{k}$ for $1\leq i\leq k$. And in this case the desired sum becomes $\frac{A^2-k(A/k)^2}{2}=\frac{A^2(k-1)}{2k}$. Clearly this becomes larger as $k$ becomes larger, so the maximum is reached when $k$ is the clique number, as desired.
