Collective behaviors of swarms and flocks