Say I have a tetraeder which is built up out of triangles (or faces), each triangle contains three vertices. The tetraeder is represented as follows:
vertices = [[0. 0. 0.] [0. 1. 1.] [1. 0. 1.] [1. 1. 0.]]
faces = [[0 1 2] [0 2 3] [0 1 3] [1 2 3]]
I would like to have a structure that I can give a vertex index and can return me the faces that contain this vertex in an efficiënt way. It needs to be efficiënt as I need to find the faces connected to for example 1000 vertices in a file with 20 000 faces. It should thus be some sort of data structure where an element of the structure is a list of faces and the index of that element equals the vertex index that is connected with those faces.
For example: "return the face indices of the faces connected to the vertex with index 1" should look like:
vertex_index = 1
find_connected_faces[vertex_index] --> [0,2,3]
The answer should be [0,2,3] because the vertex with index 1 ([0. 1. 1.]) is present in these faces. I'm struggling with a way to solve this problem efficiently. I thought about graphs using the networkx library, but haven't quite found the best approach. I found a lot of solutions to find two faces that are connected by an edge, but as you can see this is not exactly what I am looking for.