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]
< /code>
Но я получаю эту ошибку: < /p>
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'
Я работаю с NetworkX и Dictionares: < /p> [code]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] < /code> Но я получаю эту ошибку: < /p> 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' [/code] В чем проблема в моем коде?
Извините за запутанный заголовок. Я не знаю, как выразить словами то, что я ищу, но я постараюсь изо всех сил. В настоящее время я создаю приложение, которое заполняет карту введенными пользователем контактами (модели Restroom.cs), при этом каждый...
Недавно начал использовать Python для работы, и у меня возникла проблема с кодом, который я разрабатываю.
Проблема связана с двумя значениями, которые я пытаюсь сравнить. . В настоящее время мой код использует файл Excel в качестве исходного файла и...