# Formula for the number of connections needed to connect every node in a set?

Assuming you have a set of nodes, how do you determine how many connections are needed to connect every node to every other node in the set?

Example input and output:

In   Out
<=1  0
2    1
3    3
4    6
5    10
6    15
-

Figured it out. The formula is:

x = n(n - 1) / 2
-

Here is what you want.$$\sum_{k=1}^{n-1}k=\frac{n(n-1)}{2}$$

-
Oh, You`ve already have it. –  4545454545SI Jul 18 '11 at 16:46
If there are $n$ nodes, then this is called "$n$ choose $2$", and is equal to the number of $2$-element subsets of a set of $n$ elements. The Wikipedia article on binomial coefficients includes this and generalizations.