Forgive me if I have looked at this the wrong way, but it seems to me that you just need one function to compare elements in two lists and check for common points in each list, then, if the lists share > 1 point they are in a group, = 1 they are two groups (as in second example), and 0 points means an isolated group.
Just my 2 cents
Lee
Possible comparision function?
(defun common_list (lst1 lst2 / i x)
(setq i 0)
(while (setq x (car lst1))
(if (vl-position x lst2)
(setq i (1+ i)))
(setq lst1 (cdr lst1)))
i)