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$.
[Math] How many triangles can a connected graph with $n$ vertices and $m$ edges have
graph theory
Related Solutions
Updated 4/17/11:
(Originally, this answer contained a different proof of the result below for $k=3$. Not only did the proof not generalize, but it was wrong.)
The maximum number of edges in a strongly-connected digraph with $n \geq k+1$ vertices and no cycles of length at most $k$ is $${\binom{n}{2}} - n(k-2) + \frac{(k+1)(k-2)}{2}.$$ (A digraph where every vertex is reachable from every other vertex by a directed path is called strongly connected.)
Gordon Royle conjectured this bound an gave an example achieving it for $k=3$. For general $k$ and $n$ the bound is attained by the following construction, almost identical to the one provided by Nathann Cohen in the comments:
Let vertices $x_1,x_2,\ldots,x_{n-k+2}$ form a transitive tournament with $x_i \to x_j$ being an edge for all $1 \leq i < j \leq n-k+2$. Now delete the edge $x_1 \to x_{n-k+2}$ and replace it with a path $x_{n-k+2} \to x_{n-k+3} \to \ldots \to x_n \to x_1$. (The vertices $x_{n-k+3},\ldots, x_n$ will have in-degree one and out-degree one in the resulting graph.)
It remains to prove that the above number is a valid upper bound. The proof is by induction on $n$.
Simple counting shows that the bound is valid if $G$ is a directed cycle. It is tight if $G$ is a cycle of length $k+1$. Assume now that $G$ is not a cycle. Then there exist $\emptyset \neq X \subsetneq V(G)$ such that $G|X$ is strongly connected. (For example, one can choose the vertex set of any induced cycle in $G$.) Choose $X$ maximal subject to the above. Let $u \to v_1$ be an edge of $G$ with $u \in X$, $v_1 \not \in X$, and let $P$ be a shortest path in $G$ from $v_1$ to $X$. Let $P=v_1 \to v_2 \to \ldots \to v_l \to w$.
Note that adding to $G|X$ any path starting and ending in $X$ produces a strongly connected digraph. It follows from the choice of $X$ that any non-trivial such path must include all the vertices in $V(G)-X$. In particular, if $l\geq 3$, $v_2,\ldots,v_{l-1}$ have no neighbors in $X$.
Let us further assume that $u$ and $w$ are chosen so that the directed path $Q$ from $w$ to $u$ in $G|X$ is as short as possible. (Perhaps, $w=u$.) Then $V(P) \cup V(Q)$ induces a cycle in $G$, and so $v_1$ and $v_l$ have at least $k-2$ non-neighbors on $V(P) \cup V(Q)$. At least $k-l$ of those non-neighbors are in $X$ if $l\geq 2$. Therefore there are at least $k-2$ non-edges (pairs of non-adjacent vertices) between $X$ and $V(G)-X$ if $l=1$, and at least $$2(k-l)+(l-2)(k+1) \geq l(k-2)$$ non-edges if $l \geq 2$. By the induction hypothesis there are at least $|X|(k-2)- \frac{(k+1)(k-2)}{2}$ non-edges between vertices of $X$, and therefore at least $$(l+|X|)(k-2)- \frac{(k+1)(k-2)}{2}=n(k-2) - \frac{(k+1)(k-2)}{2}$$ non-edges in total, as desired.
Let $N~$ be the number of figures consisting of two triangles sharing an edge, with one of the vertices not on the common edge marked.
Clearly $N=2x$. Alternatively, start with one triangle, mark a vertex, add a second triangle to the opposite side. So $N\le 3t(\Delta_e-1)$. Which is now exact for complete graphs and sharpens your inequality.
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.