Depth first representations of $k^2$-trees
Gabriel Carmona, Giovanni Manzini
TL;DR
This work investigates compressing $k^2$-trees beyond the canonical level-by-level encoding by leveraging identical subtrees through depth-first representations. It introduces Plain Depth-First, Enriched Depth-First, Balanced Parenthesis, and related variants, along with a linear-time method to detect interchangeable subtrees in BP and compress them to a Compressed BP (CBP) form. Experimental results on web-graph adjacency matrices show notable compression gains, particularly with CBP, and reveal speedups for certain matrix-matrix multiplications when using DFS-based encodings. The findings demonstrate that depth-first layouts can improve both space efficiency and, in some cases, performance, motivating further exploration of mixed representations and optimization techniques. Overall, the approach provides a practical pathway to tighter compressed representations of sparse, clustered matrices while preserving or enhancing computational efficiency for matrix operations.
Abstract
The $k^2$-tree is a compact data structure designed to efficiently store sparse binary matrices by leveraging both sparsity and clustering of nonzero elements. This representation supports efficiently navigational operations and complex binary operations, such as matrix-matrix multiplication, while maintaining space efficiency. The standard $k^2$-tree follows a level-by-level representation, which, while effective, prevents further compression of identical subtrees and it si not cache friendly when accessing individual subtrees. In this work, we introduce some novel depth-first representations of the $k^2$-tree and propose an efficient linear-time algorithm to identify and compress identical subtrees within these structures. Our experimental results show that the use of a depth-first representations is a strategy worth pursuing: for the adjacency matrix of web graphs exploiting the presence of identical subtrees does improve the compression ratio, and for some matrices depth-first representations turns out to be faster than the standard $k^2$-tree in computing the matrix-matrix multiplication.
