在图中,如何查找连接(直接绑定)到一个节点的边数?
然后,这将是微不足道的,但如果有任何直接的方法来找到最大边连接到他们的独特(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]))
感谢。