2017-10-15 3 views
0

J'essaie d'utiliser la fonction networkx blockmodel, mais Python n'arrête pas de dire qu'il n'y a pas d'attribut 'blockmodel'. J'utilise l'exemple de code dans la documentation dans le lien here.Le module 'networkx' n'a pas d'attribut 'blockmodel'?

J'ai installé networkx, et beaucoup d'autres fonctions fonctionnent. Seul celui-ci semble se plaindre. L'aide est très appréciée.

Répondre

2

La fonction blockmodel a été remplacée dans la dernière version de networkx (vous consultez une documentation plus ancienne) avec quotient_graph.
Voici un exemple de générer un blockmodel

>>> G = nx.path_graph(6) 
>>> partition = [{0, 1}, {2, 3}, {4, 5}] 
>>> M = nx.quotient_graph(G, partition, relabel=True) 
>>> list(M.edges()) 
[(0, 1), (1, 2)] 

Voir https://networkx.github.io/documentation/stable/reference/algorithms/generated/networkx.algorithms.minors.quotient_graph.html?highlight=blockmodel pour la documentation mise à jour.