Flocking in fixed and switching networks