The average shortest path distance ℓ between all pairs of nodes in real-world networks tends to be small compared to the number of nodes. Providing a closed-form formula for ℓ remains challenging in several network models, as shown by recent papers dedicated to this sole topic. For example, Zhang
proposed the deterministic model
and studied an upper bound on ℓ. In this paper, we use graph-theoretic techniques to establish a closed-form formula for ℓ in
. Our proof is of particular interest for other network models relying on similar recursive structures, as found in fractal models. We extend our approach to a stochastic version of
in which layers of triangles are added with probability
. We find a first-order phase transition at the critical probability
= 0.5, from which the expected number of nodes becomes infinite whereas expected distances remain finite. We show that if triangles are added independently instead of being constrained in a layer, the first-order phase transition holds for the very same critical probability. Thus, we provide an insight showing that models can be equivalent, regardless of whether edges are added with grouping constraints. Our detailed computations also provide thorough practical cases for readers unfamiliar with graph-theoretic and probabilistic techniques.