Identifying clusters of adjacent points on a lattice
- To: mathgroup at smc.vnet.net
- Subject: [mg81384] Identifying clusters of adjacent points on a lattice
- From: Gareth Russell <russell at njit.edu>
- Date: Fri, 21 Sep 2007 03:10:20 -0400 (EDT)
Hi, Is there any way to use the built-in clustering routines to find clusters of ajacent elements on a 2d lattice? For example, I might generate a 'map' with SeedRandom[1]; testMap = =E2=80=A8 Last[CellularAutomaton[{1018, {2, {{0, 2, 0}, {2, 1, 2}, {0, 2, 0}}}, {1, =E2=80=A8 1}}, Table[If[Random[Real] < 0.1, 1, 0], {100}, {100}], 10]]; I would then like to find and label the separate 'patches' consisting of clusters of 1's. Ultimately, I'm looking for a list of {x,y,id} triples where the x and y are the coordinates of each 1 and the id is a number that identifies the patch to which that element belongs, but the trick is to find the clusters. I can't see how any of the included options for FindClusters would perform this particular test (each cluster must consist of elements connected to at least one other element by a distance of 1). Of perhaps there is another way? Thanks, Gareth -- Gareth Russell NJIT