Create lists of equivalences from pairs
ConnectedComponents[Graph[ex1]]
would be easier.
ConnectedComponents[ex1]
{{6, 7, 8}, {1, 2, 3}, {4, 5}}
FixedPoint[Union @@@ Gather[#, IntersectingQ] &, ex1]
{{1, 2, 3}, {4, 5}, {6, 7, 8}}
ConnectedComponents[Graph[ex1]]
would be easier.
ConnectedComponents[ex1]
{{6, 7, 8}, {1, 2, 3}, {4, 5}}
FixedPoint[Union @@@ Gather[#, IntersectingQ] &, ex1]
{{1, 2, 3}, {4, 5}, {6, 7, 8}}