Fast Generation of Unlabelled Free Trees using Weight Sequences

10/14/2020
by   Paul Brown, et al.
0

In this paper, we introduce a new representation for ordered trees, the weight sequence representation. We then use this to construct new representations for both rooted trees and free trees, namely the canonical weight sequence representation. We construct algorithms for generating the weight sequence representations for all rooted and free trees of order n, and then add a number of modifications to improve the efficiency of the algorithms. Python implementations of the algorithms incorporate further improvements by using generators to avoid having to store the long lists of trees returned by the recursive calls, as well as caching the lists for rooted trees of small order, thereby eliminating many of the recursive calls. We further show how the algorithm can be modifed to generate adjacency list and adjacency matrix representations for free trees. We compared the run-times of our Python implementation for generating free trees with the Python implementation of the well-known WROM algorithm taken from NetworkX. The implementation of our algorithm is over four times as fast as the implementation of the WROM algorithm. The run-times for generating adjacency lists and matrices are somewhat longer than those for weight sequences, but are still over three times as fast as the corresponding implementations of the WROM algorithm.

READ FULL TEXT
POST COMMENT

Comments

There are no comments yet.

Authors

page 1

page 2

page 3

page 4

03/24/2019

Lock-Free Transactional Adjacency List

Adjacency lists are frequently used in graphing or map based application...
11/29/2021

Fast algorithms for solving the Hamilton Cycle problem with high probability

We study the Hamilton cycle problem with input a random graph G=G(n,p) i...
08/30/2021

Learning Highly Recursive Input Grammars

This paper presents Arvada, an algorithm for learning context-free gramm...
08/17/2021

Arbitrary-length analogs to de Bruijn sequences

Let α be a length-L cyclic sequence of characters from a size-K alphabet...
12/22/2021

An algorithm for generating random mixed-arity trees

Inspired by [4] we present a new algorithm for uniformly random generati...
06/28/2021

Experimental Comparison of PC-Trees and PQ-Trees

PQ-trees and PC-trees are data structures that represent sets of linear ...
03/05/2020

Finding linearly generated subsequences

We develop a new algorithm to compute determinants of all possible Hanke...
This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.