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

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:

• I think the question is not clear. Will you give some example of a 2D triangle mesh and number of its segments? – Mohsen Shahriari Nov 23 '15 at 3:40
• I have added an example for clarity. – codeaviator Nov 23 '15 at 11:25
• For connected planar graphs, Euler's formula gives us $n-m+f=2$ where $n$ is the number of vertices, $m$ the number of edges, and $f$ the number of faces (including the infinite one). For your example, $n=6, f=7$ which gives $m=11$. – Kelvin Soh Nov 23 '15 at 12:14
• This seems - to some extent - related: math.stackexchange.com/questions/425968/… – Martin Sleziak Nov 23 '15 at 12:44

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):

Diamond is this graph:

The pictures are taken from list of small graphs.