A Cognitive radio ad hoc network (CRAHN) is an ad hoc network of primary user (PU) nodes and secondary user (SU) nodes, wherein the SU nodes use the licensed channels of the PU nodes when not in use. As the availability of the PU channels fluctuates with time, communication topologies spanning the SU nodes have to be dynamically and frequently reconfigured. Given the complete knowledge of the availability of the PU channels, we propose a generic benchmarking algorithm that determines a sequence of stable communication topologies spanning all of the SU nodes such that the number of transitions from one instance of the topology to another is the global minimum. At any time instant t when we need a stable communication topology spanning the entire network, we look for the largest value of k such that the intersection of the static SU graphs from time instants t to t+k, defined as the mobile graph, is connected and that the mobile graph G t...t+k+1 (SU) is not connected. We repeat the above procedure for the entire network session to determine a sequence of longest-living instances of the mobile graphs and the corresponding instances of the communication topology of interest (say a shortest path tree rooted at a source SU node) such that the number of topology transitions is the minimum. We prove the theoretical correctness of the algorithm and evaluate its effectiveness by implementing it to determine a sequence of shortest path trees of the maximum lifetime.