Function libreda_pnr::util::tie_cell_insertion::find_clusters
source · fn find_clusters<C: CoordinateType + PrimInt>(
points: &Vec<Point<C>>,
max_cluster_size: u32,
max_cluster_span: C
) -> (Vec<u32>, u32)Expand description
Group points together to clusters and return a vector with the cluster ID for each point and the number of clusters. The clusters are formed as follows:
- Sort the points by (x, y).
- As long as there’s an unassigned point: take the next unassigned point
pand put it into the new clusterc. - Take the closest point to the center of the bounding-box around
c. If addingptocdoes not enlarge the bounding box aroundcbeyondmax_cluster_spanthen addptocand repeat 3) otherwise go to 2).
max_cluster_size: Maximal number of points in cluster.max_cluster_span: Maximal width and height of the bounding box around the cluster.