def GCC_Partition(UnclusteredGraph, scale):
# Make edges on Unclustered graph
# between all nodes separated by distance 'scale'
for node1 in UnclusteredGraph.nodes():
for node2 in UnclusteredGraph.nodes():
if node1 != node2:
dist = common.euclidean_dist(node1, node2)
if dist <= scale:
UnclusteredGraph.add_edge(*(node1, node2), weight=dist)
Clusters = []
subgraphs = nx.connected_component_subgraphs(UnclusteredGraph)
for i, sg in enumerate(subgraphs):
Clusters.append(sg.nodes(data=True))
return Clusters
评论列表
文章目录