Exact counting of subtrees with diameter no more than d in trees: A generating function approach - Yang, Yu; Jin, Bang-Bang; Sun, Xiaoming; Zhang, Xiao-Dong; Li, Bo; Zhao, Kai; Wang, Hua (Information and computation, 2025)
Network motifs, regarded as fundamental building blocks, offer crucial insights into the structure and function of complex networks, with broad applications across disciplines including sociology, computer science, bioinformatics, chemoinformatics, and pharmaceutics. However, the identification of network motifs remains a significant and computationally challenging problem. Among various motifs, subtree enumeration has garnered substantial attention in recent years, particularly due to its relevance in network science and bioinformatics. For an n-vertex tree T, by introducing novel generating functions with (d+2) variables, we propose an innovative algorithm for the exact enumeration of T's subtrees rooted at fixed vertex v, where the distance between v and the farthest leaf is k=0,1,…,d, and the distance between any two leaves is no more than d. Building on this algorithm, we develop novel recursive algorithms for exact enumerating various diameter no more than d subtrees (abbreviated as DNMT-d subtrees) of T. As applications, we apply these algorithms to derive the number of DNMT-d subtrees in a full binary tree Bh with h≥2 levels, and briefly discuss the density of DNMT-d subtrees in general trees. Our research generalizes the work of Frank Ruskey on Listing and Counting Subtrees of a Tree in 1981 and makes it a special case of our study where d equals the diameter of the tree T. Moreover, the proposed O(dn2) algorithms introduce new approaches for enumerating subtrees under diameter constraints and lay the groundwork for counting diameter-constrained subgraphs (motifs) in complex networks.