community_detection#
- community_detection(domain, network_name='default_network', edge_weight_name=None, community_method='louvain', community_method_parameters={'resolution': 1, 'seed': 42, 'threshold': 1e-07}, add_as_label_to_objects=True, community_label_name='community label', community_cmap=None)#
Community detection on a provided network. Community detection partitions nodes based in their connectivity. This function will return a list of sets for each community which contain the node indices associated with that community. Egde weights can be used modify the community detection algorithm. The function will also add the community labels to the objects in the domain.
- Parameters:
- domainobject
The domain object containing the network.
- network_namestr, optional
The name of the network, by default ‘default_network’.
- edge_weight_namestr or None, optional
The name of the edge weight attribute, by default None.
- community_methodstr, optional
The community detection method to use, by default ‘louvain’.
- community_method_parametersdict, optional
Parameters for the community detection method, by default {‘resolution’:1,’threshold’:1e-07,’seed’:42}.
- add_as_label_to_objectsbool, optional
Whether to add the community labels to the objects, by default True.
- community_label_namestr, optional
The name of the community label, by default ‘community label’.
- community_cmapcolormap or None, optional
The colormap for the community labels, by default None.
- Returns:
- dict
A dictionary where keys are community indices and values are lists of node indices in each community.
- Raises:
- RuntimeError
If the network name is not in the list of generated networks.
- RuntimeError
If the edge weight name is not in the list of edge weights for the network.
Notes
For more information, see https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.community.louvain.louvain_communities.html