Controllability and observability of multi-agent systems with heterogeneous and switching topologies