Communities modules

The modularity communities module

Communities Modularity propagation class.

class hcga.features.communities_modularity.CommunitiesModularity(graph=None)[source]

Communities Modularity propagation class.

Features based on the community detection using modularity.

Uses networkx, see ‘https://networkx.org/documentation/stable/reference/algorithms/ community.html`

Find communities in graph using Clauset-Newman-Moore greedy modularity maximization. This method currently supports the Graph class and does not consider edge weights.

Greedy modularity maximization begins with each node in its own community and joins the pair of communities that most increases modularity until no such pair exists.

References

1

M. E. J Newman ‘Networks: An Introduction’, page 224 Oxford University Press 2011.

2

Clauset, A., Newman, M. E., & Moore, C. “Finding community structure in very large networks.” Physical Review E 70(6), 2004.

Initialise a feature class.

Parameters

graph (Graph) – graph for initialisation, converted to given encoding

compute_features()[source]

Main feature extraction function.

This function should be used by each specific feature class to add new features.

hcga.features.communities_modularity.eval_modularity(graph, weight=None)[source]

this evaluates the main function and cach it for speed up.

hcga.features.communities_modularity.largest_commsize(graph)[source]
hcga.features.communities_modularity.largest_commsize_weighted(graph)[source]
hcga.features.communities_modularity.num_communities(graph)[source]
hcga.features.communities_modularity.num_communities_weighted(graph)[source]
hcga.features.communities_modularity.ratio_commsize_maxmin(graph)[source]
hcga.features.communities_modularity.ratio_commsize_maxmin_weighted(graph)[source]

The asyn fluid communities module

Communities Asyn class.

class hcga.features.communities_asyn.CommunitiesAsyn(graph=None)[source]

Communities Asyn class.

The asynchronous fluid communities algorithm is described in [1]_. The algorithm is based on the simple idea of fluids interacting in an environment, expanding and pushing each other. Its initialization is random, so found communities may vary on different executions.

References

1

Parés F., Garcia-Gasulla D. et al. “Fluid Communities: A Competitive and Highly Scalable Community Detection Algorithm”. [https://arxiv.org/pdf/1703.09307.pdf].

Initialise a feature class.

Parameters

graph (Graph) – graph for initialisation, converted to given encoding

compute_features()[source]

Main feature extraction function.

This function should be used by each specific feature class to add new features.

hcga.features.communities_asyn.asyn_fluidc(G, k, max_iter=100, seed=None)[source]

This function is adapted from networks directly.

hcga.features.communities_asyn.eval_asyn(graph, num_comms)[source]

this evaluates the main function and cach it for speed up.

hcga.features.communities_asyn.len_least_dense(graph, num_comms)[source]
hcga.features.communities_asyn.len_most_dense(graph, num_comms)[source]
hcga.features.communities_asyn.partitions(graph, num_comms)[source]
hcga.features.communities_asyn.sum_density(graph, num_comms)[source]

The bisection communities module

Communities Bisection class.

class hcga.features.communities_bisection.CommunitiesBisection(graph=None)[source]

Communities Bisection class.

This algorithm partitions a network into two sets by iteratively swapping pairs of nodes to reduce the edge cut between the two sets. The pairs are chosen according to a modified form of Kernighan-Lin, which moves node individually, alternating between sides to keep the bisection balanced.

References

1

Kernighan, B. W.; Lin, Shen (1970). “An efficient heuristic procedure for partitioning graphs.” Bell Systems Technical Journal 49: 291–307. Oxford University Press 2011.

Initialise a feature class.

Parameters

graph (Graph) – graph for initialisation, converted to given encoding

compute_features()[source]

Main feature extraction function.

This function should be used by each specific feature class to add new features.

hcga.features.communities_bisection.eval_bisection(graph)[source]

this evaluates the main function and cach it for speed up.

hcga.features.communities_bisection.largest_commsize(graph)[source]

The label propagation communities module

Communities Label propagation class.

class hcga.features.communities_labelprop.CommunitiesLabelPropagation(graph=None)[source]

Communities Label propagation class.

Features based on the community detection using label propagation.

Uses networkx, see ‘https://networkx.org/documentation/stable/reference/algorithms/ community.html`

Finds communities in G using a semi-synchronous label propagation method[1]_. This method combines the advantages of both the synchronous and asynchronous models.

References

1

Cordasco, G., & Gargano, L. (2010, December). Community detection via semi-synchronous label propagation algorithms. In Business Applications of Social Network Analysis (BASNA), 2010 IEEE International Workshop on (pp. 1-8). IEEE.

Initialise a feature class.

Parameters

graph (Graph) – graph for initialisation, converted to given encoding

compute_features()[source]

Main feature extraction function.

This function should be used by each specific feature class to add new features.

hcga.features.communities_labelprop.eval_labelprop(graph)[source]

this evaluates the main function and cach it for speed up.

hcga.features.communities_labelprop.largest_commsize(graph)[source]
hcga.features.communities_labelprop.ratio_commsize_maxmin(graph)[source]