Just for fun I tried solving it using mostly native components, the logic is basically the same as @TomTom’s script but hopefully a little more transparent of what’s going on: tangency-grouping.gh (51.6 KB)
A little scripting magic happens in that Python component on the right which merges overlapping sets together.
from ghpythonlib.treehelpers import list_to_tree
sets = map(set, sets.Branches) # Tree Access
def folder(acc, x):
s = acc.pop()
if s.intersection(x):
return acc + [s.union(x)]
else:
return acc + [x, s]
result = []
for s in sets:
if not s: continue
result = reduce(folder, result, [s])
joined = list_to_tree(result)
yeah should have commented my one. I didn‘t even used a real graph, just simple recursion and a simple boolean mask to filter out visited faces. My first approach was about iterating over the edges, but this actually made it difficult to map the faces into the right groups. Thats the error occuring in the first scripts.Thats why i redesigned the algorithm to iterate over faces from beginning on.
It just became complicated to write, because when iterating over the face from beginning on, you need to find the corresponding edges from two adjacent faces beforehand, which results in this cryptic algorithm. I‘ll might comment it later on and do some testing and optimisation. Seems to work this way.