Function: findClusters()
ts
function findClusters(activeMask, neighbors): ClusterResult;Defined in: src/utils/statistics.ts:182
Finds connected clusters using BFS flood-fill.
Algorithm:
- Initialize all cluster IDs to -1
- For each active vertex not yet assigned: a. Start a new cluster with BFS b. Mark all connected active neighbors with the same cluster ID
- Record cluster sizes
Time complexity: O(V + E) where E is the number of edges Space complexity: O(V) for cluster IDs and queue
Parameters
activeMask
Uint8Array
Binary mask (1 = active, 0 = inactive)
neighbors
Set<number>[]
Adjacency list (neighbors[v] = set of neighbor indices)
Returns
Cluster result with IDs, sizes, and count