Newer
Older
from community import best_partition as louvain_partition
from .base import EpochCommunity
# TODO: look into other louvain implementations
class LouvainCommunity(EpochCommunity):
def __init__(self, epoch=604800, **kwargs):
super().__init__(epoch, **kwargs)
def process(self, **kwargs):
partitions = louvain_partition(g, weight='duration')
for node, c in partitions.items():
communities[c].add(node)
for community in communities.values():
community = frozenset(community)
for node in community:
self.community[node] = community