Skip to content

num::connected_components

Defined in header <spatial/connected_components.hpp>

template <typename InCluster, typename Neighbors>
cluster_result connected_components(int n_sites, InCluster &&in_cluster,
                                    Neighbors &&neighbors);

Label connected components by BFS over one flat queue.

Parameters

  • n_sites: Total number of sites
  • in_cluster: bool(int i): include site i?
  • neighbors: void(int i, auto&& visit): call visit(nb) per neighbor of i

Return value

id[i] is -2 for an excluded site and the cluster index otherwise; also the cluster sizes and the largest cluster.