Detection of communities in a complex network