Код: Выделить всё
print("number of nodes %d" % G.number_of_nodes())
print("number of edges %d" % G.number_of_edges())
print("Graph is connected?: %s" % nx.is_connected(G))
print("Number of connected components: %s" % nx.number_connected_components(G))
print("Size of connected componnents: %s" % [len(cc) for cc in nx.connected_components(G)])
print("Network Analysis will be performed on the largest cc from now on")
largest_cc = max(nx.connected_component_subgraphs(G), key=len)
dict_communities={}
num_communities=max([y for x,y in largest_cc.nodes(data=True)]).values()[0]
for i in range (1,num_communities+1):
dict_communities[i] = [x for x,y in largest_cc.nodes(data=True) if y['community']==i]
Код: Выделить всё
TypeError Traceback (most recent call last)
in
1 dict_communities={}
----> 2 num_communities=max([y for x,y in largest_cc.nodes(data=True)])[0]
3 for i in range (1,num_communities+1):
4 dict_communities[i] = [x for x,y in largest_cc.nodes(data=True) if y['community']==i]
TypeError: '>' not supported between instances of 'dict' and 'dict'
Подробнее здесь: https://stackoverflow.com/questions/564 ... when-tryin