在圖中,如何查找連接(直接綁定)到一個節點的邊數?
然後,這將是微不足道的,但如果有任何直接的方法來找到最大邊連接到他們的獨特(S)節點(S),這將是很好的。
我正在使用Python 2.7和Networkx。查找連接到一個節點和具有最大連接邊的節點的數量
到現在爲止,我在做這樣的:
sG = list(nx.connected_component_subgraphs(G)) # sG is a sub_graph of main graph G
nb_sG = len(sub_graphs)
max_con_node = list()
for m in xrange(nb_sG):
sG_nodes = [(node, len(sG[m].edges(node)), sG[m].edges(node)) for node in sG[m].nodes()]
connexions = [i[1] for i in sG_nodes]
idx = [i for i,x in enumerate(connexions) if x==max(connexions)]
max_con_node.append((max(connexions), [sG_nodes[i][0] for i in idx]))
感謝。