I want to accumulate the edges of triangular model/mesh. For example a triangular cube has 18 edges. 

It looks so simple and easy but literally its too complicated. 
I have all adjacent information of a triangle. For example I have adjacent vertices and triangles, and I know which triangles have common edge but the problem is how to extract that common edge between two triangles.

One thing that needs to consider is there should not be any duplicate index of edge's point/vertex.

First thing is how to count the total number of edges. Remember a Cube has 18 edges.

I tried a lot but gave up now. :)
any idea?
.

***Update 1:***

ok I have a triangle T[i] (index v1, index v2, index v3) which has three edges v1v2, v2v3, v3v1.

and I have a neighbor triangles of all edges.

```
T[i].index_of_sharedTri1_with_edge_v1v2, 
T[i].index_of_sharedTri2_with_edge_v2v3, 
T[i].index_of_sharedTri3_with_edge_v3v1; 

```

now which loop I need to make that can extract unique edge? What information I need to compare? Do I need to compare edge vertices, shared tri index, or what ? I tried with many ways but it so complicated.

**Update 2:**

```
GLTris *e = new GLTris[nb_Tris*3];
int n = getTotalEdges_Sorted(indices, nb_Tris, e);
cout<<n<<endl;
int ne = RemoveDublicatesFromAnSortedEdgeArray(e, n);
for(int i=0; i<ne; i++)
   e[i].Cout();

```

I have tried this and it works perfect but I need to figure it out whether it will work on all types of meshes and is it a efficient way?