def _detect_communities(self):
    if self.nested:
        lowest_level = self.model_.get_levels()[0]
    else:
        lowest_level = self.model_
    number_of_communities = lowest_level.get_B()
    if self.allow_overlap:
        membership_vector = list(lowest_level.get_overlap_blocks()[0])
    else:
        membership_vector = list(lowest_level.get_blocks())
    if self.allow_overlap:
        return _overlapping_membership_to_list_of_communities(membership_vector, number_of_communities)
    return _membership_to_list_of_communities(membership_vector, number_of_communities)
def _detect_communities(self):
    if self.nested:
        lowest_level = self.model_.get_levels()[0]
    else:
        lowest_level = self.model_
    number_of_communities = lowest_level.get_B()
    if self.allow_overlap:
        membership_vector = list(lowest_level.get_overlap_blocks()[0])
    else:
        membership_vector = list(lowest_level.get_blocks())
    if self.allow_overlap:
        return _overlapping_membership_to_list_of_communities(membership_vector, number_of_communities)
    return _membership_to_list_of_communities(membership_vector, number_of_communities)