grouping.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:pyhiro 作者: wanweiwei07 项目源码 文件源码
def clusters(points, radius):
    '''
    Find clusters of points which have neighbours closer than radius

    Arguments
    ---------
    points: (n, d) points (of dimension d)
    radius: max distance between points in a cluster

    Returns:
    groups: (m) sequence of indices for points

    '''
    tree   = KDTree(points)
    pairs  = tree.query_pairs(radius)
    graph  = from_edgelist(pairs)
    groups = list(connected_components(graph))
    return groups
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号