0

Given edges and vertices, how can we separate these into connected components? A situation where I need this is when I extract vertices and edges by using an algorithm like the marching cube method, I want to then obtain multiple connected polyhedra.

For example, say, there are two not-connected spheres and we have signed distance function f for these spheres. Marching cube algorithm can compute vertices V where f(v)=0 forall v in V. However, what I want to obtain is not the whole vertices V, but the two different set of vertices V1 and V2 which corresponds to each sphere of the two. (Here, the union of V1 and V2 is V.)

It seems easy to implement this in a naive way, but if there are some well-known algorithms for that, I wanna know this.

Stef
  • 13,242
  • 2
  • 17
  • 28
orematasaburo
  • 1,207
  • 10
  • 20
  • Does this answer your question? [Decomposing a concave mesh into a set of convex meshes](https://gamedev.stackexchange.com/questions/53142/decomposing-a-concave-mesh-into-a-set-of-convex-meshes) – Stef Sep 23 '20 at 12:56
  • @stef I forgot the word "connected". I'm sorry. I want to obtain multiple connected polyhedra. – orematasaburo Sep 23 '20 at 13:00
  • If I understand, your question is "How to find the **connected components** in an undirected graph?" – Stef Sep 23 '20 at 13:29
  • 1
    Finding connected components is a very typical problem, so it might already be implemented in most graph libraries. Since your question doesn't list any programming language nor libraries, we can't really answer about that - the question [Find connected components in a graph](https://stackoverflow.com/questions/21078445/find-connected-components-in-a-graph) was even closed because it "wasn't focused enough". However, you can still look at its answers for the idea of the simplest algorithm if you want to implement it yourself. – Stef Sep 23 '20 at 13:32
  • @Stef Exactly! thanks. – orematasaburo Sep 23 '20 at 13:32
  • Simplest algorithm goes like this: 1) Pick a vertex 2) colour this vertex and every vertex which you can reach from it (using depth-first-search or breadth-first-search or whichever); 3) if there remains at least one non-coloured vertex, pick a non-coloured vertex and repeat from step 1; 4) The number of times you've repeated steps 1-2-3 is the number of connected components. – Stef Sep 23 '20 at 13:34

0 Answers0