rg.py 文件源码

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

项目:QTop 作者: jacobmarks 项目源码 文件源码
def Partition(UnclusteredGraph, code, type, scale):
    # Make edges on Unclustered graph
    # between all nodes separated by distance 'scale'
    # on Dual Lattice
    for node1 in UnclusteredGraph.nodes():
        for node2 in UnclusteredGraph.nodes():
            if node1 != node2:
                d = code.distance(type, node1, node2)
                if d <= scale:
                    UnclusteredGraph.add_edge(*(node1, node2), weight=d)
    Clusters = []
    # Networkx connected components analysis
    subgraphs = nx.connected_component_subgraphs(UnclusteredGraph)
    for i, sg in enumerate(subgraphs):
        Clusters.append(sg.nodes(data=True))


    return Clusters


# Choose fixed node for cluster fusion
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号