Generation of weighted trees, block trees and block graphs
Tınaz Ekim, Mordechai Shalom, Mehmet Aziz Yirik
TL;DR
To address the need for uniform generation within structured graph classes, the paper develops a general framework to enumerate and unrank nonnegative-weight colored trees and then specializes it to weighted block trees corresponding to connected block graphs. Central to the approach is centroid-rooted canonical weighted trees to avoid isomorphisms, together with a color-weight scheme that unifies unweighted, positive-weighted, and block-tree constructions. The authors provide theoretical guarantees of linear output-delay enumeration and $O(n^3)$ unranking for rooted trees, as well as $O(N^2 \log N)$ time and space to precompute needed counts; they also establish a one-to-one correspondence with connected block graphs and publish instances up to $19$ vertices. Implementations in Python (including BlockGraphGen and Colab demos) demonstrate practical generation at scale. The framework offers a flexible tool for uniform sampling and analysis of structured graph families and can be extended to other tree-based decompositions.
Abstract
We present a general framework to generate trees every vertex of which has a non-negative weight and a color. The colors are used to impose certain restrictions on the weight and colors of other vertices. We first extend the enumeration algorithms of unweighted trees given in [19, 20] to generate weighted trees that allow zero weight. We avoid isomorphisms by generalizing the concept of centroids to weighted trees and then using the so-called centroid-rooted canonical weighted trees. We provide a time complexity analysis of unranking algorithms and also show that the output delay complexity of enumeration is linear. The framework can be used to generate graph classes taking advantage of their tree-based decompositions/representations. We demonstrate our framework by generating weighted block trees which are in one-to-one correspondence with connected block graphs. All connected block graphs up to 19 vertices are publicly available at [1].
