Why a complete graph has $\frac{n(n-1)}{2}$ edges? I'm studying graphs in algorithm and complexity,
(but I'm not very good at math) as in title:

Why a complete graph has $\frac{n(n-1)}{2}$ edges?

And how this is related with combinatorics?

$\frac{n(n-1)}{2}$ comes from simple counting argument. You could directly say that every edge is obtained by asking the question: "how many pairs of vertices can I choose?", and this choosing of vertices is $C(n,2) = \frac{n(n-1)}{2}$. or you could take the other way of counting. Label the vertices $1,2, \ldots ,n$. The first vertex is now joined to $n-1$ other vertices. The second vertex has already been joined to vertex $1$ and hence has to be joined to the remaining $n-2$ vertices and in general the $k^{th}$ vertex has already been joined to the previous $k-1$ vertices and hence has to be joined to the remaining $n-k$ vertices. So the total number of edges is given by $(n-1) + (n-2) + \ldots 2 + 1 = \frac{n(n-1)}{2}$.
