I\'m looking for a clever/fast C++ algorithm, which would allow me to do grouping of several lists of objects when they contain common objects inside. Let\'s say I have N li
For each object, calculate which elements contain it.
i.e.
01 -> [E1, E3]
02 -> [E4]
03 -> [E2, E5]
04 -> [E3]
05 -> [E3, E4]
06 -> [E5]
These lists induce a graph: there's a vertex per element, and two vertices are connected if the corresponding elements show up in the same list.
It seems to me that what you want to calculate are the connected components of the graph.