A unifying convex analysis and switching system approach to consensus with undirected communication graphs