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
评论列表
文章目录