Table of Contents
Fetching ...

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.

Depth first representations of $k^2$-trees

TL;DR

This work investigates compressing -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 -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 -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 -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 -tree in computing the matrix-matrix multiplication.
Paper Structure (11 sections, 1 theorem, 4 equations, 7 figures, 3 tables)

This paper contains 11 sections, 1 theorem, 4 equations, 7 figures, 3 tables.

Key Result

Lemma 2

The subtree starting at position $i$ in $B$ is interchangeable with the subtree starting in position $j$, if and only if, setting $c=\hbox{\rm find_close}(i)$, the substring $B[i..c]$ is equal to $B[j..j+c-i]$.

Figures (7)

  • Figure 1: A $16\times16$ matrix split recursively into $2\times 2$ submatrices for the construction of a $k^2$-tree with $k = 2$.
  • Figure 2: The $k^2$-tree, with $k=2$, representing the matrix of Figure \ref{['fig:matrix-example']}. The color of each the internal nodes is related to the size of the submatrix it represents.
  • Figure 3: The Plain Depth-First representation of the same tree as Figure \ref{['fig:k2-tree-example']}. The representation consists of the bit array $P$ containing the concatenation of the 4-tuples of bits shown above: the first row represents the children of the root node. Each of the subsequent four rows corresponds to the subtrees rooted at each child of the root, listed in depth-first traversal order; different colors represent different tree levels.
  • Figure 4: The balanced parenthesis representation of the $k^2$-tree of Figure \ref{['fig:k2-tree-example']}. The resulting parenthesis vector $B$ is the concatenation of the six rows of parentheses: the first and last row are the open and close parenthesis for the root; and the other four rows represents the subtrees rooted at the four children of the root. Also shown is the bit vector $L'$ containing the values in the bottom level stored according to the depth-first order visit.
  • Figure 5: The subtrees surrounded by dashed lines of the same color are interchangeable according to Definition \ref{['def:isubtrees']}. Note that the subtrees surrounded in red are interchangeable even if the values stored in some of the leaves at the last level are different.
  • ...and 2 more figures

Theorems & Definitions (2)

  • Definition 1
  • Lemma 2