Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Could anybody explain to my why the asymptotic upper bound for the number of triangles in a graph with n vertices is O(n^3). I could not imagine a graph with n vertices which can contain indeed n^3 triangles.

share|cite|improve this question
up vote 5 down vote accepted

Consider the complete graph $K_n$. Here, choosing any three vertices yields a triangle; and the number of ways of choosing three vertices is $$ \binom{n}{3}=\frac{n(n-1)(n-2)}{6}\sim\frac{n^3}{6}\text{ as }n\to\infty. $$ It is true that you can't ever actually have $n^3$ triangles; but, that is not what the claim says.

Instead, it says, essentially, that there is a constant $C$ and a bound $N$ so that the number of triangles in a graph on $n$ vertices is bounded by $Cn^3$ for $n\geq N$... that is, that the number of triangles is eventually bounded by a multiple of $n^3$. That's what being $O(n^3)$ means.

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.