From time to time, social network analysis requires us to classify the number of groups from a given network. This simple module is a python implementation of a locus based genetic algorithm for community detection by Clara Pizzuti.[1]
This algorithm is particularly good at detecting communities in which we don't know their number beforehand. This algorithm finds communities by its structure: it classify densely connected nodes into a group. Although it runs slowly, this algorithm will help us in preliminary analysis of a social network.
import gacomm as gc
nodes = [0,1,2,3,4,5,6,7,8,9,10]
edges = [(0,1),(0,4),(1,2),(2,3),(1,3),(3,0),(0,2),(4,5),(5,6),(6,7),(10,8),(10,9),(8,9),(8,7),(9,7),(7,10)]
gc.community_detection(N,E)
# Possible output
# [[0,1,2,3],[4,5,6],[7,8,9,10]]