Skip to content

Importing the community module #27

@filmenczer

Description

@filmenczer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    errataFlag errors in the book

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions