Community detection and its applications in understanding dynamics of social networks