Wireless sensor networks (WSNs) have a wide array of applications in environment and infrastructure monitoring. An efficient solution to allow sensors to communicate with the outside world is making use of one or several actors as the receiver of the data harvested by the WSNs. A wireless sensor and actor network (WSAN) consists of many randomly deployed sensors and a few actors that organize the sensors in their vicinity into an actor-centric network. Localization, routing, and collision avoidance are three fundamental problems in WSANs. The main contribution of this thesis is to solve the collision avoidance problem by proposing a new virtual infrastructure for the localization, and give optimal (in some cases, near-optimal) distance-two colorings for the adjacency graph of our virtual infrastructure.