[Math] How many triangles can a connected graph with $n$ vertices and $m$ edges have

graph theory

I am very interested in the maximum number of triangles could a connected graph with $n$ vertices and $m$ edges have. For example, if $m\leq n−1$, this number is $0$, if $m=n$, this number is $1$, if $m=n+1$, this number is $2$, and if $m=n+2$, this number is $4$.

Best Answer

It is a bound and since it is very long, I wrote it an answer, may be it can be helpful.

Let $G$ be a connected graph with $n$ vertices and $m$ edges. Suppose the eigenvalues of this graph are $\lambda_1\geq \lambda_2\geq\ldots\geq\lambda_n$. We know that $\sum{\lambda_i^3}=6\Delta_G$, where $\Delta_G$ counts the total number of triangles of the graph $G$.

Also,we have:

$$\lambda_1\leq\sqrt{2m-\delta(n-1)+\Delta(\delta-1)}.$$

Since your graph is connected, we can set $\delta=1$ and obtain: $$\lambda_1\leq\sqrt{2m-n+1}.$$

So we have:

$$\Delta_G\leq\frac{n}{6}(2m-n+1)^{\frac{3}{2}},$$

as you wanted in your comments.

Actually, you can get more information from this method since we exactly know when the upper inequalities which I used are equality for which graphs. You can search for "SHARP UPPER BOUNDS OF SPECTRAL RADIUS OF GRAPHS" or similar keywords.