To get the neighborhoods of radius r of each point in your data set, given
distances calculated already in the matrix d, you could do (but note below)

$ A <- (d <= r)

then rows (or columns) of A are indicator vectors for the neighborhoods.
"Unique" will work on these vectors, as "unique.array", to give the unique
rows, which would be the unique neighborhood lists:

$ unique(A)

Your question about why "unique" applied to a distance matrix ignores zeros
points to a possible problem: the object you get from dist() is not a
matrix. The "upper" and "diag" options only control printing. If you check
length() you'll see you only have n(n-1)/2 elements, the lower triangle of
the distance matrix. (To answer the question: unique() sees only these;
there's not a method for objects of class dist.) So you need to do

While I work on this, I realize (again) that I'm a C programmer
masquerading in R, and its really tricky working with R lists. Here are
things that surprise me, I wonder what your experience/advice is.

I need to calculate overlapping U-diametric clusters of a given radius.

(Again, I apologize this looks so much like C.)

## Returns a list of all U-diametric clusters of a given radius
## Give an R distance matrix
## Clusters may overlap. Clusters may be identical (redundant)

##make sure they are sorted in reverse order
if (length(redundantCluster)>0)

{
redundantCluster <- unique(sort(redundantCluster, decreasing=T))

## remove redundant clusters (must do in reverse order to preserve
index of cluslist)

for (i in redundantCluster) cluslist[[i]] <- NULL
}

Question: am I deleting the list elements properly?

I do not find explicit documentation for R on how to remove elements
from lists, but trial and error tells me

myList[[5]] <- NULL

will remove the 5th element and then "close up" the hole caused by
deletion of that element. That suffles the index values, So I have to
be careful in dropping elements. I must work from the back of the list
to the front.

Is there an easier or faster way to remove the redundant clusters?

Now, the next question. After eliminating the redundant sets from the
list, I need to calculate the total number of items present in the whole
list, figure how many are in each subset--each list item--and do some
calculations.

I expected this would iterate over the members of the list--one step for
each subcollection

for (i in cluslist){

}

but it does not. It iterates over the items within the subsets of the
list "cluslist." I mean, if cluslist has 5 sets, each with 10 elements,
this for loop takes 50 steps, one for each individual item.

I find this does what I want

for (i in 1:length(cluslist))

But I found out the hard way :)

Oh, one more quirk that fooled me. Why does unique() applied to a
distance matrix throw away the 0's???? I think that's really bad!