Good day. Help solve the problem, well, or in what place to dig? (Google did not help)
There is a list of faces: [1, 2, 3, 4, 5, 6]
There is a list of vertices from the faces: [(2, 6), (3, 7), (8, 2), (8, 3), (6, 9), (7, 9)]
(where the index of a pair of vertices corresponds to the index of the face)
The task: to sort the faces by the condition of common vertices. If the face has a common vertex with the checked one, add it to the list. At the same time observing the sequence.
For example:
faces (2, 6) and (6, 9) have a common vertex 6, in the list (1)
faces (6, 9) and (7, 9) have a common vertex 9, in the list (1, 5)
faces (7, 9) and (3, 7) have a common vertex 7, to the list (1, 5, 6)
etc.
output: [1, 5, 6, 2, 4, 3]
How to express such a check in code?