I tried doing it by contrapositive. I'm here to ask two things
1) Whether this proof is correct
2) If there's a better, more direct way of proving this using graph theory
Here's how I did it:
Let G be a non-connected graph with n vertices. Then G has at most ${n-1 \choose 2}$ edges
Proof:
If G isn't connected, it has two subgraph components F and H, such that $ \#V_F = m$ and $\#V_H = n - m$, $ 1 \le m \le n-1$
$\#E_F + \#E_H = \#E_G$ and also $\#E_F \le \#E_{K_m}$ and $\#E_H \le \#E_{K_{n-m}}$
So from this follows that $ \#E_G = \#E_F + \#E_H \le \#E_{K_m} + \#E_{K_{n-m}} = {m \choose 2 } + {n-m \choose 2}$
So I'll define $f(m) = {m \choose 2 } + {n-m \choose 2}$ and I want to prove that
$ \Delta f(m) \le 0$, for $1 \le m \le \lfloor \frac {n-1}{2} \rfloor$
$\Delta f(m) \ge 0$, for $\lceil \frac{n-1}{2} \rceil \le m \le n-1$
$f(m) = f(n-1) = {n-1 \choose 2}$
This would prove f(m) has its maximum value at m=1. And then the maximum amount of edges in G is f(1).
I'm not writing the proof for these three last statements, but it's easy to prove knowing that $\Delta f(m) = 2m+1-n$
Thanks in advance!
Your proof is correct, but there is a simple one using the degree sum formula.
Since twice the number of edges is the sum of the vertex degrees, the average degree is greater than $$\frac{(n-1)(n-2)}{n} > n-3$$ so there must be a vertex $v$ of degree at least $n-2$. If $v$ is of degree $n-1$ the graph is clearly connected, so suppose $v$ is of degree $n-2$, and let $x$ be the one vertex not adjacent to $v$. The subgraph induced by $v$ and its neighbors has at most $\binom{n-1}{2}$ edges, so there is an edge from $x$ to some neighbor of $v$, and the graph is connected.