In recent years, mobile devices are becoming popular and high-speed wireless communication is uproaring. In a wireless network environment, a mobile ad hoc network (MANET) has the characteristics of being infrastructure-free and self-organizing. Although the topology of MANET can be deployed easily with few restrictions, the maintenance faces great challenges. Furthermore, all nodes transmit packets by multi-hop in MANET. If transmission is by traditional broadcasting, it has a broadcasting storm problem and it can significantly reduce the wireless network throughput. The CDS (Connected Dominating Set) scheme is a well-known solution to the broadcasting storm problem. In a MANET, a virtual backbone network can be constructed by using CDS. All nodes can transmit data effectively through the virtual backbone network. In previous research on the subject, most algorithms are only suitable for a static MANET environment, with all nodes being stationary. This is contrary to the desirable characteristics of MANET. In this paper, we present an algorithm which is suitable for both static and dynamic MANET environments.