On p. 169 (section 6.3.2) we give the following code to import the community module and run the Louvain algorithm:
# download community module at
# github.com/taynaud/python-louvain
import community
# returns the partition with largest modularity
partition_dict = community.best_partition(G)
In some cases (e.g., on Google Colab), the import function does not work as expected, and the above code produces:
AttributeError: module 'community' has no attribute 'best_partition'
In such a case, the following import should work:
import community.community_louvain as community
On p. 169 (section 6.3.2) we give the following code to import the community module and run the Louvain algorithm:
In some cases (e.g., on Google Colab), the import function does not work as expected, and the above code produces:
AttributeError: module 'community' has no attribute 'best_partition'In such a case, the following import should work:
import community.community_louvain as community