Sign up ×
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It's 100% free, no registration required.

If a graph with $n$ vertices has more than $\frac{(n-1)(n-2)}{2}$ edges then it is connected.

I am a bit confused about this question, since I can always prove that for a graph to connected you need more than $|E|>n-1$ edges.

share|cite|improve this question
hint: What if you have one isolated vertex (not connected to any other vertices) what is the maximum number of edges in the graph? – Joe Nov 22 '12 at 0:42

3 Answers 3

up vote 9 down vote accepted

I am not sure what bothers you but as I see it you are confused about the following two facts

  1. If a graph is connected then $e \geq n-1.$

  2. If a graph has more than $e > \frac{(n-1)(n-2)}{2}$ then it is connected.

Notice that the implications in 1 and 2 are in opposite directions.

For a proof of 2. you can check out this link.

share|cite|improve this answer

I think your problem might be to prove that you cannot construct an undirected graph with $\dfrac{(n-1)(n-2)}{2}$ edges that is not connected. You are thinking about it the wrong way. The $E = n - 1$ formula about how few edges can you use to connect all the vertices.

Imagine you are an adversary trying to design a horrible highway system so that one town is disconnected. No matter how inefficiently you spend your roads, you'll still have to connect all the towns if there are so many roads.

Consider what the worst possible design could be, eg, the one that uses as many roads as possible but still leaves one town disconnected. How many edges does that have? What happens when you add one more edge to that?

share|cite|improve this answer

1.As you mentioned we have:

$G\text{ is connected} \Rightarrow |V|-1 \le |E|$

But the other direction is not true, i.e:

$G\text{ is connected} \Leftrightarrow |V|-1 \le |E|$

is wrong statement.

So you can not use it for further reasoning. Sample counter example is this graph ($K_t$ is a complete graph on $t$ vertices, and $\cup$ means disjoint union of graphs):

$G = K_{n-1} \cup K_1$

$G$ has $n-1\choose 2$ edges and $n$ nodes, and ${n-1\choose 2} > n-1$ for $n>4$.

2.On the other hand, to prove that :

${|V|-1 \choose 2} < |E| \Rightarrow G\text{ is connected}$

We can do it as follow:

Suppose not, then $G$ is disjoint union of two graphs $G=G_1\cup G_2$, with $|G_1| = k, |G_2| = n-k, 0<k<n$, if we connect all the vertices of $G_1,G_2$ together to make graph $G"$, then $|E_{G"}|\le {n \choose 2}$ (because $G"$ has at most as complete graph edges) but:

${n-1 \choose 2} + 1 + k\cdot (n-k) \le |E_{G"}| \le {n \choose 2} \Rightarrow$

$(k-1)(n-k-1) + 1 \le 0\Rightarrow$ Contradicts with $0<k<n$.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.