# Find the adjacent tetrahedron of a specific tetrahedron by vertex e?

**URL:** https://community.freefem.org/t/find-the-adjacent-tetrahedron-of-a-specific-tetrahedron-by-vertex-e/4115
**Category:** General Discussion
**Created:** [October 27, 2025, 1:38am UTC](https://community.freefem.org/t/find-the-adjacent-tetrahedron-of-a-specific-tetrahedron-by-vertex-e/4115 "2025-10-27T01:38:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![MatrixVector](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@MatrixVector](https://community.freefem.org/u/MatrixVector)
#### Post date: [October 27, 2025, 1:38am UTC](https://community.freefem.org/t/find-the-adjacent-tetrahedron-of-a-specific-tetrahedron-by-vertex-e/4115/1 "2025-10-27T01:38:06Z")

</div>

The “`Th[k].adj(e)`” function works for 2D triangles, which find the adjacent triangle of the triangle k by edge e.  
Is it also works for 3D? I tested two cases, i.e., “`mesh3 Th = cube(1, 1, 1)`” and “`mesh3 Th = cube(2, 2, 2)`”. It seems that “`Th[k].adj(e)`” can find the adjacent tetrahedron of a specific tetrahedron with a common surface. Is that right?

---

<div class="post-metadata">

### Author: ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)
#### Post date: [October 27, 2025, 9:32am UTC](https://community.freefem.org/t/find-the-adjacent-tetrahedron-of-a-specific-tetrahedron-by-vertex-e/4115/2 "2025-10-27T09:32:36Z")

</div>

Yes, it works like this. If you want to find the tetrahedra with common vertex, you could make a loop over the faces of your tetrahedron (but reject the face opposite to your vertex), get the adjacent tetrahedra (with this common face). Then you have to check next the neighbours by face of this new tetrahedron, and so on. It is a bit complicate but should end in a limited number of iterates.

---

<div class="post-metadata">

### Author: ![MatrixVector](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@MatrixVector](https://community.freefem.org/u/MatrixVector)
#### Post date: [November 3, 2025, 11:40am UTC](https://community.freefem.org/t/find-the-adjacent-tetrahedron-of-a-specific-tetrahedron-by-vertex-e/4115/3 "2025-11-03T11:40:44Z")

</div>

Dear Dr. Bouchut,

Thanks for your reply. Regarding that “finding the tetrahedra with a common vertex“, maybe the way using lists proposed by Prof. Hecht works better.

> [@Mesh connectivity details](https://community.freefem.org/t/mesh-connectivity-details/1285/2):
>
> You want for each vertices of the mesh the list of triangle contening this vertex: // you can do that in few line of code: mesh Th=square(4,4); int[int] headv(Th.nv), next(Th.nt\*3); headv=-1; // for(int k =0;k\< Th.nt; ++k) for(int i =0;i\< 3; ++i) { int v = Th[k][i]; // vertex number next[3k+i] = headv[v]; headv[v]= 3k+i; } // show the list of triangle of vertex v for(int v=0; v\<Th.nv;++v) { cout \<\< v \<\< " : "; for(int p=headv[v]; p \>=0; p=next[p]) { int k = p/3, i = p%3; ass…

---

<div class="post-metadata">

### Author: ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)
#### Post date: [November 3, 2025, 2:46pm UTC](https://community.freefem.org/t/find-the-adjacent-tetrahedron-of-a-specific-tetrahedron-by-vertex-e/4115/4 "2025-11-03T14:46:58Z")

</div>

You are right, this algorithm is more efficient!
