Social behavior requires the interaction among animals. Aggregation, spatial assembly of animals, facilitates inter-individual communication, and provides occasions of social interaction. To quantify aggregation in small animals such as insects it is necessary to detect individual animals at a high precision. By expanding the utility of recently developed machine vision software, we here track multiple individual Drosophila melanogaster and provide new metrics for quantifying aggregation. Flies in a circular arena immediately formed aggregation that is significantly higher than random distribution, and it developed over the course of 30 minutes. As the first step toward the identification of neural circuits underlying aggregation, we analyzed large trajectory data (18, 992 videos), where 2, 204 groups of neurons were genetically stimulated. Large-scale correlations of behavioral performance and labelled neurons identified brain areas associated with aggregation and isolation.