Use Exercise 29 to show that a simple graph with n vertices and k connected components has at most (n − k)(n − k + 1)/2 edges. [Hint: First show that
(n1)^2+(n2)^2+...+(nk)^2<=n^2-(k-1)(2n-k),
where ni is the number of vertices in the ith connected component.]