Total number of edges in a triangle mesh with $n$ vertices

4.7k Views Asked by At

Given a 2D triangle mesh with $n$ vertices, I was wondering if there is an expression that would allow to compute the total number of edges present in the mesh.

For example, the following mesh has 6 vertices and a total of 11 edges:

mesh

1

There are 1 best solutions below

1
On BEST ANSWER

The number of vertices alone is not sufficient to determine the number of edges

From Euler's formula we know that $$v-e+f=2,$$ where $v$ is the number of vertices, $e$ is number of edges and $f$ is number of faces (including the outer one).

Now you now additionally, that boundaries of faces have three edges. However, there is one exception, which is the outer face. Let $b$ denote the number of vertices on its boundary (i.e. on the boundary of your mesh). Then you have $$2e=3(f-1)+b.$$ (We count $3$ edges for each inner face, and $b$ edges for the outer face.)

So if you know both $v$ and $b$, you can calculate the number of edges as $$e=3v-3-b.$$

Some examples $$ \begin{array}{|c|c|c|c|} \hline \text{graph} & e & v & b \\\hline \text{triangle} & 3 & 3 & 3 \\\hline K_4 & 6 & 4 & 3 \\\hline \text{diamond} & 5 & 4 & 4 \\\hline \text{your mesh} & 11 & 6 & 4 \\\hline \end{array} $$

$K_4$ is this graph (complete graph on four vertices):

K4

Diamond is this graph:

diamond

The pictures are taken from list of small graphs.