Collective Dynamics in Physical and Social Networks