Manuscript Offprint
arXiv:2611.03620Adjacency Labeling Schemes of Size for Graphs of Bounded Treewidth
Abstract
Gavoille and Labourel (ESA 2007) gave an adjacency labeling scheme of size for graphs of treewidth at most , and asked whether bits suffice. We give a labeling scheme of size for every fixed , the first improvement of the second-order term for any . Equivalently, there is an induced-universal graph with vertices for this family.
We work with laminar families of intervals, in which a vertex finds each earlier neighbor as the owner of an interval of a given nesting depth around it. As long as every subtree occupies consecutive positions, the nesting depth must be logarithmic, and bits per neighbor follow. We give up contiguity. Heavy subtrees are moved out, which brings the depth down to ; the intervals broken by the moves are repaired with additional intervals per vertex; and the bits needed to find these intervals are paid for by the moved subtrees.
1 Introduction
A labeling scheme is a method of distributing the information about the structure of a graph among its vertices, by assigning a short binary label to every vertex, such that a fixed function on pairs of vertices can be computed from their labels alone. In an adjacency labeling scheme for a family of graphs, the function is adjacency: given the labels of two vertices of a graph , a decoder decides whether . The size of the scheme is the maximum label size over the -vertex graphs of . Hereafter, we refer to adjacency labeling schemes simply as labeling schemes. Kannan, Naor and Rudich [9] observed that a labeling scheme of size for is equivalent to an induced-universal graph with vertices. In light of this equivalence every single bit counts: a labeling scheme of size corresponds to an induced-universal graph of linear size.
For graphs of treewidth at most , Gavoille and Labourel [8] presented a labeling scheme of size and proved a lower bound of . They asked whether a labeling scheme of size exists, noting that for this includes the question for trees, which
A graph is induced-universal for a family if every graph in on vertices appears as an induced subgraph of .
was open at the time. To the best of our knowledge, the second-order term has not been improved for any .
The labeling scheme of [8] is also a building block of the labeling schemes for planar graphs, of size [2] and [4]. Dujmović et al. [4] label the subgraphs of , where has bounded treewidth and is a path, with bits, and list the right lower-order term as an open problem; graphs of bounded treewidth are the case in which has a single vertex. Labeling schemes of size are now known for every proper minor-closed family [5].
1.2 Our Contribution
Our main contribution is a labeling scheme of size for graphs of bounded treewidth.² To the best of our knowledge, this is the first improvement of the second-order term of [8] for any . We summarize this result in the following theorem.
Theorem 1.1. For every , the family of graphs of treewidth at most admits a labeling scheme of size . In particular, the size is for every fixed .
By the equivalence of [9], we obtain the following.
Corollary 1.2. For every fixed and every there is a graph with vertices that contains every -vertex graph of treewidth at most as an induced subgraph.
For fixed , Theorem 1.1 improves the second-order term of [8] from to , and Corollary 1.2 improves the size of the induced-universal graph from to . We stress that the dependence on is poor: the bound of Theorem 1.1 is smaller than that of [8] only for .
What is new. The previous labeling schemes for bounded treewidth [8, 2, 4] identify each earlier neighbor of a vertex by its depth along a root path in a tree of logarithmic depth, at a cost of bits per neighbor. We restate this in terms of laminar families of intervals: a vertex finds its earlier neighbor of color as the owner of the interval of color of a given nesting depth around it (Section 2). In this setting the logarithmic depth is forced by contiguity: if every subtree occupies consecutive positions and every vertex owns at most intervals, some trees of treewidth 3 require depth (Proposition 3.3). Our main conceptual contribution is to give up contiguity. We move every subtree that is heavy compared with the interval of its color around it, which reduces the depth to , and we show that this is affordable. The correctness lost by the moves is restored with intervals per vertex, and the bits needed to locate the moved intervals are paid for by the moved subtrees themselves: the subtrees moved out of one interval are disjoint and large, and along every root-to-leaf path they shrink fast enough.
1.3 Our Methods
Our labeling scheme combines two known techniques with two new ingredients. First, following the presentation in [2] of the scheme of [8], a vertex can identify each of its earlier neighbors by a depth along a root path; there, the path lies in a tree of depth at most , so each depth takes bits. We use nested intervals instead: a -tree is represented by a tree in which
² is the number of times should be iterated, starting from , before the result is at most 1.
every vertex is adjacent to its nearest ancestor of each other color, and every vertex stores, for each color, how many intervals of that color contain it (Section 2). The natural choice of intervals, the subtrees in depth-first order, works, but these numbers can be linear in . Our first new ingredient reduces them to : we move every heavy block of siblings out of the interval that contains it, and repair the intervals that a move breaks with additional intervals, at most per vertex (Sections 3 and 4). Second, every vertex must compute where its intervals are. An additional interval lies near an interval of the same vertex that the vertex has already located, and can be found from it with bits, where is the size of the surrounding region. To store these bits we use the approximate lengths and the identifiers aligned to powers of two of Alstrup, Dahlgaard and Knudsen [1], and hash functions with a few choices per key, in the spirit of d-ary cuckoo hashing [7]. Our second new ingredient is the accounting: we show that the identifiers wasted by the alignment are paid for by the subtrees of the moved blocks (Section 5). Proofs that are not needed to follow the argument are deferred to the appendix.
2 Preliminaries
Logarithms are binary, and is the least with . Trees are rooted. For a vertex of a tree we write for its parent, for the subtree rooted at and . Ancestors and descendants are proper unless stated otherwise. A coloring col: is proper if for every non-root . For a vertex and a color , is the nearest proper ancestor of of color , and if there is none.
2.1 Colored Trees
Lemma 2.1. Let be a -tree on vertices. There are a rooted tree on and a proper coloring col: of such that
This representation follows from the elimination ordering of k-trees and their unique proper -coloring (see, e.g., [4]); for completeness, a proof is given in Appendix A.
Every graph of treewidth at most on at least vertices is a spanning subgraph of a -tree [3]. Given and col as in Lemma 2.1, a vertex records in bits which of its edges to the vertices belong to the subgraph. Hence it suffices to give labels from which the decoder decides, for two distinct vertices , whether : applying this test in both directions and reading the recorded bit gives adjacency. Graphs on at most vertices are labeled with bits directly.
Hereafter, we assume to be fixed and to be a rooted tree on vertices with a proper coloring in colors. The vertices , , are the upper neighbors of . One of them is .
2.2 Interval Families and Correctness
Definition 2.2. An interval family for consists of an injective map id: and a laminar family of non-empty integer intervals, each owned by a vertex and of color . It is correct if for every vertex and every color with , the innermost member of of color that contains id is owned by . We write for the number of members of color that contain id, and the depth of is the number of members of color that contain , including .
Lemma 2.3 (counting test). In a correct family, let be a vertex, a color with , and a vertex of color . Then if and only if lies in an interval of of depth .
Proof. By laminarity the members of color containing form a chain with , and a member of color containing contains , so has depth . Hence the only interval of color and depth containing is , which is owned by , as desired.
So a vertex stores and the numbers , and an owner must be able to compute its intervals and their depths from its own label. If no interval of color contains and , the vertex stores and the test answers no.
Identifying an ancestor by a depth is not new. In the presentation in [2] of the scheme of [8], every vertex stores, for each of its at most earlier neighbors, the depth of the node containing it in a decomposition tree of depth at most , which takes bits per neighbor. The intervals of Section 3 have depth instead.
Tools from [1]. We use two techniques of Alstrup, Dahlgaard and Knudsen. First, a -approximation of an integer can be stored in bits. We round the length of every container of our layout, a set of consecutive positions, in this way with , where and is a parameter, and we align the container to a power of two of about the rounding precision. Then a code of bits describes the length, and the first position of the container can be recovered from any position inside it, the code, and further bits (Appendix A). Second, identifiers are aligned to powers of two. If is a multiple of , the label stores the Elias code [6], then exactly bits of other data, and then without its trailing zeros, in bits. These parts take bits together and can be separated by the decoder; we say that the other data are absorbed. Aligning to wastes fewer than identifiers, which Section 5 pays for.
3 The Layout
In this section we construct the order and the intervals. We start with blocks, which give a correct family whose depth can be large. We then move heavy blocks to reduce the depth, and repair correctness with additional intervals, called wraps. Figure 1 follows the construction on a small example.
3.1 Blocks
Definition 3.1. For a vertex with at least one child, the block is the set of children of . As an interval it has color and owner , and its mass is .
Lemma 3.2. Let be a vertex, a color with , and the tree path. Then no with has color , and lies in the subtree of .
Proof. This is the definition of .
If the vertices are written in depth-first order and every block is written as the interval of the subtrees of its members, then by Lemma 3.2 the innermost interval of color around is , so this family is correct (Figure 1(b)). Its depth, however, can be linear: if is a path colored , the blocks of one color are nested about deep. The following proposition, proved in Appendix B, shows that no layout in which subtrees occupy consecutive positions does much better, even if a vertex owns several intervals.

Figure 1: A small example with and the colors red, blue and green. (a) A colored tree. Every vertex is adjacent to its nearest ancestor of each other color; the dashed lines are the edges that are not tree edges. For instance, is adjacent to and . (b) The blocks in depth-first order. The blue intervals around are and , and the inner one is owned by , the blue neighbor of . (c) The block is moved out of its home into the area of , right after it. Now lies in a single blue interval. The move took out of the green block , although is the green neighbor of , so is surrounded by a wrap of , whose source is . (d) The layout tree of (c); its leaves, read from left to right, give the order of (c).
Proposition 3.3. For all and there is a colored tree with and at most vertices such that every correct family for in which every subtree occupies consecutive positions and every vertex owns at most intervals has depth at least . Hence the depth is at least .
3.2 Moving Blocks and Repairing Correctness
We keep a block in its place only if it is light. The home of is the innermost interval of color around . The block is light if its mass is smaller than , where is a threshold and is, roughly, the size of the subtree of the owner of . A heavy block is moved: it is written right after its home , outside . If is kept, the moved block goes to the area of , an unowned stretch of positions right after ; if itself lies in an area, it goes next to , in the same area (Figure 1(c)). As a result, two nested blocks of one color are always light relative to each other, so their masses drop from to below every two levels of nesting, and the depth is .
Moving a block, however, breaks correctness for the other colors. Before the move, the vertices in were inside the intervals of all ancestors of , and afterwards they are inside only those that also contain the new place of . In Figure 1(c), the vertex is no longer inside the green block of , although is its green neighbor. We therefore surround the moved block with a wrap of , an interval owned by . In general, gets a wrap of for every color for which its new place is not already inside an interval of of the right nesting level. The wrap replaces the interval of around before the move, which we call its source. Moved blocks that need the same wraps share them, so the number of wraps stays small.
3.3 The Layout Tree
We describe the layout as a rooted tree , the layout tree, whose leaves are the vertices of and whose inner nodes are of four kinds: the root, blocks, wraps and areas (Figure 1(d)). Blocks and wraps are intervals; each has an owner and the color of its owner. Any depth-first order of lists the leaves below a node consecutively, so with id() the position of in such an order, every interval becomes an integer interval, and the intervals form a laminar family. Section 5 chooses the order and inserts gaps. For a node , its interval ancestors are the intervals on the path from to the root, included if it is an interval. “Below” means “a descendant of” in , and is the owner of an interval .
Fix a nondecreasing function , the threshold. Every block is either kept or moved, and every moved block and every wrap belongs to an area. For an interval let if is a kept block, and if belongs to the area , where is the kept block whose area is . The layout tree is built by emit(root, root of ), where emit() does the following.
(E1) Attach a leaf as a child of . If has no children, stop.
(E2) Let be the nearest interval ancestor of the leaf of color , or . If or , attach as a kept block, as a child of , call for every child of , and stop.
(E3) Otherwise is moved, and is its home. If is a kept block, let be the area of , a child of the parent of created when first needed, and let . Otherwise belongs to an area , and let be the parent of .
(E4) For every color with , the moved block needs if the nearest interval ancestor of of color is not owned by . Let be the needed vertices, ordered from the root down, and let the source be the nearest interval ancestor of the leaf of color .
(E5) Starting at , for let be the child of that is a wrap with owner and source , created if it does not exist; it belongs to and has home . Attach as a child of , and call for every child of .
A wrap is created for the first moved block that passes through it, and later moved blocks with the same and the same pairs reuse it. Hence every wrap has one owner, one source and one home. The procedure is a depth-first traversal of that never changes the parent of a node, so the interval ancestors of a leaf are fixed when it is attached, and the layout tree is well defined.
4 Correctness and Depth
4.1 Correctness
The following theorem is the heart of the construction. Its proof follows the tree path from a vertex up to . The blocks on the way have colors other than , and as long as they are kept, the path in the layout tree simply climbs through them. At the first moved block on the way, either its new place already lies in an interval of color owned by , or a wrap of surrounds it.
Theorem 4.1. For every vertex and every color with , the nearest interval ancestor of the leaf of color is owned by . In particular the family of intervals is correct, whatever the threshold.
Proof. Let be the tree path; by Lemma 3.2, for . The leaf is a child of . If is kept, it is a sibling of the leaf , hence a child of . Let be the least such that is moved, if there is one. Then the path from the leaf up to , or up to if there is no such , passes only through the blocks , whose colors differ from . In the second case we are done. In the first, and . Let and be as in (E3)–(E5) for ; the wraps have distinct colors. If the nearest interval ancestor of of color is owned by , then is not needed and no has color . Otherwise is needed, and its wrap is the only of color . In both cases the nearest interval of color above is owned by , as desired.
Note that for colors this is correctness, while for it says that the home of a moved block is owned by . In Appendix C we derive further properties of the layout. The most important one is lightness: every block of color has mass, where is the nearest interval of color strictly above (Lemma C.4(c)). For kept blocks this is the rule (E2). For moved blocks it follows because the block of a needed vertex lies inside every interval of its color around its wraps (Lemma C.3).
4.2 Depth
For a nondecreasing let , and let be the least with .
Theorem 4.2. Every leaf lies in at most blocks and at most wraps of each color.
Proof idea. If a block lies strictly below a block , then , since the kept block that belongs to lies below . Let be the blocks of one color around a point, with masses . By lightness, , so the masses drop by every two levels. The masses of the blocks of the owners of nested wraps of one color satisfy the same recursion. The full proof is given in Appendix D.
We use the threshold , where is fixed in Appendix F. It is nondecreasing, and for , so .
Lemma 4.3. .
Corollary 4.4. With , every point lies in at most intervals of each color, and an interval depth is stored in bits.
4.3 Intervals per Vertex
A vertex owns its block and its wraps. Every wrap of has a source, which is another interval of , so the intervals of form a tree under the relation “is the source of”, rooted at . The owner computes its intervals along this tree, from down.
Theorem 4.5. Every vertex owns at most intervals.
Lemma 4.6. Let be a wrap of with source . Then the depth of is the depth of minus .

Figure 2: How the owner of a wrap finds it. The source of is an interval of that has already located, and it lies inside the home . (1) The owner recovers the start of from the position of and a few bits, since is aligned. (2) The area starts right after . (3) The owner jumps to the sub-area whose slots have the length of . (4) It picks the slot of with a slot graph, using the position of as the key and a short choice stored in its label. When the walk has to pass through several wraps, each step is of the same kind. All of this happens inside the region of and costs bits, where is the size of the region.
Proof idea. A wrap of with source is determined by , the color of the moved block for which it was created, and the set of colors of the vertices needed before , so is the source of at most wraps. Along a chain of sources the area changes at most times, since the homes at which it changes are nested and have distinct colors, and within one area the number of wraps above the current one strictly decreases. Hence chains of sources have length at most . For the depths, lightness implies that at most one interval of color lies strictly between the home of and its source. The proofs are given in Appendix D.1.
5 Labels
From now on , is the bound of Corollary 4.4, , and . Every point lies in at most intervals.
5.1 Locating Intervals
A vertex knows where its block starts if the block is kept, since it starts right after the vertex. It must, however, compute the positions of a moved block and of its wraps. The key observation is that a wrap is never far from its source: the source lies inside the home , and the wrap lies right after (Figure 2). The owner therefore walks from its source up to and over to the wrap. Each step up recovers the start of an aligned container from a position inside it, which takes bits for a container of length . Each step down picks a slot by means of a slot graph, a hash function with a few choices per key in the spirit of d-ary cuckoo hashing [7]. Appendix E describes the placement in detail.
Every vertex gets an alignment , chosen below, and is a multiple of . For a home , the region consists of and the containers placed right after that hold the moved blocks and wraps with home ; is its length. The set of vertices in does not depend on the alignments, and we let , the sum over the vertices in . The key of a moved block is the leaf of its owner, and the key of a wrap is its source. The following two lemmas are proved in Appendix E.
Lemma 5.1 (locating). Let be a moved block or a wrap with home . There are data loc() of bits such that the first position of is determined by loc() and the first and last positions of the key of .
Lemma 5.2 (size). Let . Then , and for every home .
The alignments determine the layout, and the layout determines the alignments; Appendix E shows that the rule below has a fixed point, which we use.
5.2 The Encoder and the Decoder
Let be an interval of . Its home is the home of if is a moved block or a wrap, and itself if is kept. The data of are: for , whether it is kept and the code of its length; for a moved block or a wrap, the code of its length and ; for a wrap, also the index of its source among the intervals of and the offset of Lemma 4.6. They are written in a self-delimiting way and, by Lemmas 5.1 and 5.2 and Theorem 4.5, take at most
bits, for an absolute constant , where is the home of . We call small if , where is fixed in Appendix F. The data of the small intervals are stored explicitly, and the data of the other intervals of are absorbed in the identifier. Let be the sum of over the intervals that are not small. The alignment is the least with .
The label of a vertex consists of:
-
a head: ; ; for every color the value in bits, or a code for if ; if has children, the depth of in bits; and the bits recording which edges to the vertices are present;
-
the number of intervals of , and for each of them, in the order of the tree of sources, whether it is small;
-
the data of the small intervals;
-
the identifier in absorbed form: , the data of the other intervals padded to bits, and in bits.
Given and , the decoder computes from and parses both labels. It decides whether as follows. If or , the answer is no. Otherwise it computes the intervals of along the tree of sources: the position of , which starts at the least multiple of its grain after if it is kept, and is found by Lemma 5.1 from otherwise; and the position of every wrap from its source by Lemma 5.1. The lengths come from the codes, the depth of from the head, and the depth of a wrap is that of its source minus by Lemma 4.6. The answer is yes if and only if lies in an interval of of depth . Recall from Section 2 that applying this test in both directions and reading the edge bit of the lower vertex decides adjacency.
Theorem 5.3. The decoder is correct.
Proof. The decoder computes the positions and depths of all intervals of correctly by Lemmas 5.1 and 4.6. The family is correct by Theorem 4.1, so Lemma 2.3 applies.
5.3 The Cost of Alignment
It remains to bound , the number of identifiers used once every vertex is aligned.
Lemma 5.4. .

(a)
(b)
Figure 3: Who pays for the bits hidden in the identifiers of the owners of the moved blocks and wraps with home . (a) If the region of has many vertices compared with the number of blocks moved out of , the vertices of the region pay. (b) Otherwise at least two blocks left . Their owners are not below one another, since the home of each of them is owned by , so their subtrees are disjoint, and each has at least vertices, where is the subtree size of .
Proof idea. A moved block may retain few of its vertices, since blocks below it may have been moved further out, so its cost cannot be charged to the vertices it contains. Instead, every vertex that absorbs data is charged to the home of its largest absorbed interval (Figure 3). If the region of has many vertices compared with the number of moved blocks with home , the vertices of the region pay; every vertex lies in few regions. Otherwise at least two blocks were moved out of . By Theorem 4.1, the home of a moved block is owned by , so no moved block with home has its owner below another one, and their subtrees are disjoint. Each has at least vertices, and these subtrees pay. Along a root-to-leaf path of , the masses of consecutive such blocks of one color satisfy , which bounds the total charge per vertex by poly() once is large compared with the number of bits per interval. The full proof is given in Appendix F.
Proof of Theorem 1.1. By Section 2 it suffices to label colored trees, and the decoder is correct by Theorem 5.3. Since , we have by Corollary 4.4. The absorbed form of the identifier takes bits, and by Lemmas 5.2 and 5.4, so . The head has bits. A small interval has data of bits, and there are at most intervals per vertex by Theorem 4.5, so the explicit part has bits. In total the labels have bits for fixed , as desired.
6 Concluding Remarks
We have devised a labeling scheme of size for graphs of bounded treewidth. Two parts of our labels grow with : the depths of at most , and the precision of the alignments, where , which prevents rounding errors from accumulating along the intervals around a point. Each costs bits. By Proposition 3.3, depth requires moving almost every subtree; the threshold does so, but then the moved blocks are too light to pay for locating them. The question of Gavoille and Labourel [8], whether a labeling scheme of size exists, remains open for every , and a positive answer would have to remove both sources of . It would also be of interest to obtain a polynomial dependence on , which needs fewer intervals per vertex or a way to locate the intervals of one vertex jointly, and to replace the slot graphs, which we show to exist by counting, by an explicit construction, which would make encoding and decoding efficient.
Acknowledgments
The author used Claude, a large language model by Anthropic, for assistance in developing and checking parts of the arguments and in drafting the text and figures. The author has verified all proofs and takes full responsibility for the content of this paper.
References
[1] S. Alstrup, S. Dahlgaard, and M. B. T. Knudsen. Optimal induced universal graphs and adjacency labeling for trees. J. ACM 64(4):27, 2017. Preliminary version in FOCS 2015.
[2] M. Bonamy, C. Gavoille, and M. Pilipczuk. Shorter labeling schemes for planar graphs. In SODA, 2020.
[3] H. L. Bodlaender. A partial -arboretum of graphs with bounded treewidth. Theoret. Comput. Sci. 209:1–45, 1998.
[4] V. Dujmović, L. Esperet, C. Gavoille, G. Joret, P. Micek, and P. Morin. Adjacency labelling for planar graphs (and beyond). J. ACM 68(6):42, 2021. Preliminary version in FOCS 2020.
[5] V. Dujmović, C. Gavoille, G. Joret, P. Micek, P. Morin, and D. R. Wood. Adjacency labelling for proper minor-closed graph classes. arXiv:2605.06616, 2026.
[6] P. Elias. Universal codeword sets and representations of the integers. IEEE Trans. Inf. Theory 21(2):194–203, 1975.
[7] D. Fotakis, R. Pagh, P. Sanders, and P. Spirakis. Space efficient hash tables with worst case constant access time. Theory Comput. Syst. 38(2):229–248, 2005.
[8] C. Gavoille and A. Labourel. Shorter implicit representation for planar graphs and bounded treewidth graphs. In ESA, LNCS 4698, pages 582–593, 2007.
[9] S. Kannan, M. Naor, and S. Rudich. Implicit representation of graphs. SIAM J. Discrete Math. 5(4):596–603, 1992. Preliminary version in STOC 1988.
[10] D. D. Sleator and R. E. Tarjan. A data structure for dynamic trees. J. Comput. Syst. Sci. 26(3):362–391, 1983.
A Proofs and Details for Section 2
Proof of Lemma 2.1. Color properly with colors; for a -tree this coloring exists and is unique up to renaming. Fix a construction order: an initial -clique, and then vertices each joined to a -clique of earlier vertices. Make the initial clique a path in creation order, and make every later vertex a child of the last created vertex of . We show by induction that the earlier neighbors of every vertex are the vertices , . For the initial clique this is immediate. For a later , the vertices of are earlier neighbors of , so by induction they are vertices . The colors of are all colors except , so , and .
Codes, grains and residues. For an integer let and , and let be the Elias gamma code of , of bits. Fix an integer ; Appendix E sets . The grain of is with . Since is negative for and increasing for , the grain is nondecreasing in . Moreover
The rounding of is , so that . Its code consists of and the number in bits; it determines and and has bits.
A container is a set of consecutive positions. Every container of the construction has a raw length , a length and a grain , which divides , and it is aligned: its first position is a multiple of . Its code is the code of .
Lemma A.1 (residues). Let be an aligned container and . Then for an integer . Hence is determined by , the code of and further bits.
Proof. Both and are multiples of in the range of , which has multiples of .
B Proof of Proposition 3.3
Proof of Proposition 3.3. Let . A unit is a vertex of color 0 with a child of color 1, which has a child of color 3. For , a unit with root of color 0 consists of , and as before, together with children of of color 1; every has a child of color 2, and every has two children, of color 1 with a child of color 3, and the root , of color 0, of a copy of . Then , and , so and .
We show by induction on that, for a unit with root at level , some position in the range of lies in at least intervals of color 0 owned by vertices of . For , the position of lies in an interval of . For , the at most intervals of have at most endpoints, and the ranges of the subtrees are disjoint, so the range of some contains no endpoint, and every interval of contains or misses it. The range contains , which lies in an interval of by correctness, so . By induction, some position in the range of lies in intervals of color 0 owned by vertices of , and it also lies in .
| nearest proper ancestor of of color | |
|---|---|
| the children of : an interval of color owned by , of mass | |
| home and context of a moved block: it leaves and hangs below | |
| subtree size of the owner of the kept block that belongs to | |
| the threshold; a block is moved iff its mass is at least | |
| source of the -th needed vertex: its interval around the leaf of the owner | |
| number of intervals of color containing |
Table 1: Notation.

Figure 4: The escape rule. Both and lie in , a kept block of color , and have color . The block of is light compared with and is kept. The block of is heavy, so it becomes a moved block in the area of , right after . There it no longer lies in the intervals of color that contained , so it is wrapped in an interval of its upper neighbor .
C Properties of the Layout
We use the following terms. For a moved block with home , the node of (E3) is its context; the moved block is a primary if is kept and a secondary otherwise, and the wraps of (E5) are its chain. We write . Table 1 recalls the notation, and Figures 4 and 5 illustrate moved blocks and shared wraps.
Areas and units. The moved blocks and wraps of an area are its units. The units of form a forest below the node , in which every wrap is the parent of the units created through it; a primary hangs below the area itself, and a secondary below the parent of its home, a unit of the same area. The moved blocks with a common context share their wraps as far as their pairs agree, so these wraps nest like a trie (Figure 5). A moved block moved out of is written right after in the area of if is kept, and next to otherwise. In both cases it lies outside , as the escape rule requires, and its wraps restore the intervals of other colors that it left.
We start with the following simple observations on the layout tree.
Lemma C.1. (a) The interval ancestors of the context of a moved block are interval ancestors of the leaf ; for a primary they are the strict interval ancestors of its home.
(b) Every leaf below an interval is a proper descendant of .
(c) The units of an area lie below the node , and none of them lies below a moved block of . Every leaf below a wrap lies below a moved block below that wrap.
Proof. (a) For a primary, is a child of the parent of the home , so its interval ancestors are the strict interval ancestors of , which is itself an interval ancestor of the leaf . For a secondary,

Figure 5: Five moved blocks with a common context and the vertices they need, shown below each moved block (all with the same sources). Moved blocks that agree on a prefix share the wraps of that prefix, which nest like a trie.
is the parent of . (b) By induction over the attachments. A leaf is attached below with . If is kept, its strict interval ancestors are the interval ancestors of the leaf ; if it is a moved block, they are its chain, whose owners are proper ancestors of , and the interval ancestors of , which are interval ancestors of the leaf by (a). By induction , and hence , is a proper descendant of all their owners. (c) Units of are attached below or below a wrap of , and never below a moved block of . The children of a wrap are units, and an area is a child of a block.
Lemma C.2 (sources). Let be a moved block with home , context , needed vertices and sources . Then
(a) is owned by and lies strictly below , and every interval ancestor of is a strict interval ancestor of ;
(b) for strictly below , both intervals, is a proper descendant of ;
(c) , and is the nearest interval of color strictly above .
Proof. (a) By Theorem 4.1 at , is owned by . If were an interval ancestor of , then by Lemma C.1(a) it would be the nearest interval ancestor of of its color, and would not be needed. For a secondary, the interval ancestors of the leaf that are not interval ancestors of lie below the child of ; for a primary, the interval ancestors of are the strict interval ancestors of by Lemma C.1(a). In both cases lies below , hence strictly below every interval ancestor of , and since .
(b) By induction over the creation of . If is a kept block, its strict interval ancestors are those of its owner's leaf, and Lemma C.1(b) applies. If is a moved block, they are its chain and the interval ancestors of its context, and Lemma C.1(a,b) applies. If is the wrap of a moved block as in (E5), its strict interval ancestors are , owned by proper ancestors of , and the interval ancestors of . Every such lies strictly above by (a), and existed before , so is a proper descendant of by induction.
(c) The sources are interval ancestors of the leaf , hence pairwise comparable. If were below , then would be a descendant of by (b), but it is a proper ancestor. An interval of color strictly between and would be nearer to the leaf than .
In the following lemma we prove that the block of a needed vertex lies inside every interval of its color that the moved block keeps. All quantitative statements below rely on it.
Lemma C.3 (needed blocks). Let be a wrap of . Then lies strictly below every interval of color that is a strict interval ancestor of .

Figure 6: Nested blocks of one color around a point . Every block is light compared with the interval of its color around it (Lemma C.4), and of a block is at most the mass of the block around it, since the kept block it came from lies inside. So the masses drop by every two levels.
Proof. By induction over the creation of , for a moved block with context . Between and there are only wraps of the chain, of colors other than , so every strict interval ancestor of of color is an interval ancestor of . The source of is owned by and lies strictly below by Lemma C.2(a). If we are done. Otherwise is a wrap of created earlier, is a strict interval ancestor of of color , and induction applies.
Lemma C.4. (a) If an interval lies below an interval , then .
(b) Every moved block of an area A has mass at least , where , and its owner is a proper descendant of .
(c) (Lightness.) Let be a block of color and the nearest strict interval ancestor of of color . Then .
(d) Two wraps of the same color, one below the other, belong to different areas.
Proof. (b) A moved block of is heavy for its home, which is or a unit of , and both have . Its owner's leaf lies below , or below a moved block of with a shallower owner (Lemma C.1(c)), and induction on the depth of the owner gives the second claim.
(a) Let be if is kept and if belongs to , so that . If is kept, then lies below : this is clear if is kept, and if belongs to an area , then is a strict ancestor of the node , since otherwise , and with it , would lie below a moved block of , contrary to Lemma C.1(c); hence is also a strict ancestor of the sibling of that node. Lemma C.2(b) gives the claim. If belongs to , then belongs to , with equal , or lies below a moved block of by Lemma C.1(c), and then by (b).
(c) By induction on the depth of . If is kept, is the interval of (E2). Let be a moved block with home and context . Its chain has other colors, so is the nearest interval ancestor of of color , which is also the nearest strict interval ancestor of of color . If is a block, is a proper descendant of and by induction. If is a wrap of , then lies below a moved block below , so is a proper descendant of and ; by Lemma C.3, lies strictly below , so by induction and (a), .
(d) Let , a wrap of , lie strictly below , of the same color, both in , and let be created for the moved block of . By Lemma C.3, (c) and (a), , while since needs , and by (b).
D Proofs for Section 4
Proof of Theorem 4.2. We first show that if a block lies strictly below a block , then . If is kept, is a proper descendant of by Lemma C.2(b). If is a moved block of , then does not lie below the node , since otherwise would lie below a moved block of , contrary to Lemma C.1(c); so is a strict ancestor of the node and of its sibling , and is a proper descendant of .
Fix a leaf and a color , and let be the blocks of color containing it, with masses . The nearest strict interval ancestor of of color lies below , so Lemma C.4(c,a) and the claim give (Figure 6). Hence , and once this is at most the masses still decrease strictly; this bounds the number of blocks.
Let be the wraps of color containing the leaf, owned by , with ; the descend strictly. By Lemma C.3, lies strictly below , so by Lemma C.4(c,a). By Lemma C.4(d), belongs to an area different from that of , so is a strict ancestor of the node , and lies below a moved block below . Then , and .
Proof of Lemma 4.3. Let and . We claim as long as . For , . If the claim holds for , then when . Let be the last with ; then , and . From there reaches 1 in at most steps.
D.1 Intervals per Vertex
We call the intervals of a vertex z its records.
Lemma D.1. Every record S of z is the source of at most wraps of z.
Proof. Let be a wrap of with source , created for the moved block with home , needed vertices and . The leaf lies below , and is the nearest interval ancestor of the leaf of color , so by Lemma C.2(a), is the nearest interval of color strictly above . It determines the context . Going up from , Lemma C.2(c) determines and their owners from the colors of , and these pairs determine . There are at most choices for and for the set of colors.
For a wrap of an area let be the number of wraps of that are ancestors of , included. By Lemma C.4(d) the wraps of on a path have distinct colors, so .
Lemma D.2. If the source S of a wrap W of z is a wrap of z of the same area, then .
Proof. Let be created for the moved block with context , home , and . The source lies strictly below , which is a child of , so is a secondary, and since no unit of the area lies below a moved block of it (Lemma C.1(c)), is a wrap and every interval between and is a wrap of the area. These include and, by Lemma C.2, the sources of , which lie strictly between and . Hence , where if is the area, while .
Lemma D.3 (escape chains). Let be wraps of , each the source of the next. Let be the indices for which belongs to a different area than , and let be the home of . Then , and these homes have distinct colors, all different from . Hence there are at most such indices.
Proof. Let be the area of . By Lemma C.2(a) the home of contains strictly. If were a unit of , then would belong to . So for , is a strict ancestor of the node . Every later wrap of the sequence up to index lies in the area , which is the area of if is kept and the area containing otherwise; in both cases , a strict ancestor of that area node, contains strictly. The color of is that of the moved block for which was created, which needs , so it differs from .
Suppose have the same color , and let be the moved block for which was created; it has home , needs , and . The wrap of lies strictly below . If is a block, then is a proper descendant of by Lemma C.2(b), and by Lemma C.4, , since the nearest strict interval ancestor of of color lies below . If is a wrap of , then again , and lies strictly below by Lemma C.3, so . Both contradict the first inequality.
Proof of Theorem 4.5. Give generation 0, and a wrap the generation of its source plus one. Along a sequence of wraps of , each the source of the next, the area changes at most times by Lemma D.3, and between changes strictly decreases by Lemma D.2, so the sequence has at most wraps. By Lemma D.1 the number of records of generation is at most .
Proof of Lemma 4.6. Let be created for the moved block with context and home . The intervals of color containing are and the interval ancestors of , which are the strict interval ancestors of (Lemma C.1(a) and the definition of ). Those containing are the same strict interval ancestors of , the intervals strictly between and , and ; the home has another color. So is the number of intervals of color strictly between and , and they contain the leaf of . Suppose there are two, . If , then by Lemma C.4. If is a wrap of , then the leaf of lies below a moved block below , so again , and lies strictly below by Lemma C.3. Both contradict .
E The Identifier Layer
In this appendix we fix the order of the layout tree, insert gaps, and prove Lemmas 5.1 and 5.2. The owner of a unit knows the position of the key of : its source if is a wrap, and its own position if is a moved block. We place so that it can be found from its key with few bits. By Theorem E.2 below, the key lies inside the base of the parent of , or inside a sibling of on which depends. We therefore place every unit right after the unit it depends on, together with everything that depends on it, as one cluster. The clusters that depend on nothing are placed in their parent by a slot structure, a hash table without collisions whose slot is found from the position of the key and a short choice (Figure 7). All lengths are rounded and all intervals are aligned, so that the start of an interval can be recovered from any position inside it and a few bits.
E.1 Slot Graphs
Slot graphs are hash functions with choices per key, as in -ary cuckoo hashing [7]; since we need one function that works for every set of keys, we prove their existence by counting.
Lemma E.1 (slot graphs). For all integers and , let and . There is a function such that for every set of at most keys there is a choice for which is injective on .
a wrap or an area : the slot structure of the clusters of its root units

: light dependents cluster of the heavy dependent
Figure 7: Placement of units inside a wrap or an area . The clusters of the units of that depend on no other unit are placed in the slots of a slot structure, grouped into sub-areas by their rounded length (here, one sub-area with short slots and one with long slots); a cluster occupies a slot determined by the position of its key and a short choice. Inside a cluster, a unit is followed by the slot structure of the clusters of its light dependents, and then by the cluster of its heavy dependent .
Proof. Choose every value independently and uniformly in . By Hall's theorem, a set fails only if some with sends all its values into a set of slots. The failure probability is therefore at most with . If , then and , and gives , since . If , then , and , so . The sum is less than 1.
We fix as the lexicographically first such function. If we use , and instead. In both cases a choice takes bits.
E.2 Keys
The key of a unit is its source if is a wrap, and the leaf of its owner if is a moved block. The base of a node that is an area or a wrap is Base() = if is the area , and the source of if is a wrap.
Theorem E.2 (keys). Let be a unit with parent , created for a moved block with home . Then is not below . If is the first wrap of the chain of a secondary, or a secondary with an empty chain, then lies strictly below the sibling of , and is a proper descendant of ; we call a dependent of . Otherwise lies strictly below Base(), and Base() is or lies below .
Proof. Let in the notation of (E5), or with . The key existed before was created, so it is not below . If , the parent is , whose base contains (or the leaf ) strictly by Lemma C.2(c), and lies below . If , the parent is the context and the key lies strictly below by Lemma C.2(a). For a primary Base() = . For a secondary is a child of other than , and is a proper descendant of by Lemma C.2(b).
In other words, the dependency relation among the children of a node is a forest whose roots, the root units of , have their keys below Base(). Every unit has a walk: , and is the parent of as long as is not a dependent and its parent is a wrap. The walk follows the chain of the moved block that created and stops at a unit , , which is a root unit of an area with key below , or a dependent of . In both cases all units of the walk have home , and their bases are or lie below .
E.3 Containers
We now fix the order of and insert gaps. Every vertex gets an alignment , chosen in Section 5, and id(v) will be a multiple of . An aligned container is placed at the least multiple of its grain at or after the current position. Raw lengths are computed bottom-up:
(C1) The cell of a vertex consists of positions, with at the multiple of among them, then if it is kept, at the least multiple of its grain after , then the area of if it exists. Its raw length is , with the terms for and the area omitted if absent.
(C2) A block, kept or moved, consists of the cells of the children of its owner, in any fixed order; its raw length is their total.
(C3) For a unit with dependents, let be the dependent whose cluster contains the most vertices, and call the others light; this is the heavy-light decomposition of [10], applied to the dependency forest. The cluster of is , then , then the cluster of , where is the slot structure of the clusters of the light dependents of , with base . Its raw length is . The cluster of a unit without dependents is the unit itself.
(C4) A slot structure with base for a set of clusters groups them into classes by the code of their raw lengths. A class of clusters of rounded length gets a sub-area of slots of length , with , where if , and otherwise , where is rounded up to a multiple of ; then , and is coded by and . The sub-areas are aligned and placed in order of increasing length. The cluster of a unit occupies the slot of its class, with , , and encoding the color of , whether is a leaf, and the first and last positions of relative to st(). Distinct units of one slot structure have distinct values (see below), so and , as Lemma E.1 requires.
(C5) A wrap consists of the slot structure with base Base() of the clusters of its root units. The area of consists of the slot structure with base of the clusters of its root units, and is placed right after .
Blocks and wraps have the length and grain of their raw length and are aligned; slots start at multiples of the grain of the class, which is at least the grain of the unit at the start of the cluster, since grains are nondecreasing. Two units of one slot structure have different keys : distinct intervals of one color that are nested have different first or last positions, because a wrap of an area has no unit of its color below it in that area (Lemma C.4(d) and induction) and every other interval starts after the first leaf of the block containing it. The positions are assigned top-down, starting with the cell of the root of at position 0, and is the length of that cell.
E.4 Locating Units
For a home , let , the region of , be together with the area of if is kept, and together with and if is a unit. All units with home lie in , since they lie in dependents of or in the area of . Let be the total raw length of the containers forming . The set of vertices in does not depend on the alignments, since heavy dependents are chosen by numbers of vertices. Let , the sum over the vertices in ; Lemma 5.2 below shows .
Proof of Lemma 5.1. Let be the walk of . Going up, lies in , an aligned container, so Lemma A.1 gives its first position from the code of the base and bits, and the code gives its last position. At the top, lies in , and the same gives the first and last positions of . If is a root unit of the area of , the area starts at the end of ; its sub-areas are found from their codes and their offsets, which are below in units of their grains since they are sorted by length, and the slot from the class code, , the key and . If is the heavy dependent of , it starts at the next multiple of its grain after , which ends at a position given by the code of ; if it is light, it is found in like a root unit, with base . Going down, the cluster of is found in the slot structure of in the same way, with base , whose position is known from the way up. The number of classes in a slot structure of total raw length is at most . All codes, offsets and choices refer to containers of raw length at most , and .
E.5 The Identifier Space
We prove the following form of Lemma 5.2: , and every container formed by blocks, wraps, slot structures and clusters has raw length at most times the number of vertices in it plus the alignments of the vertices in it.
Proof of Lemma 5.2. Call a vertex together with its alignment positions an atom. Rounding and aligning a container of raw length adds at most positions, and nothing if ; a sub-area multiplies the rounded lengths of its clusters by at most by the choice of . Expanding the raw lengths top-down, every atom is inflated by the product of over the blocks, wraps, slot structures, sub-areas and rounded clusters that contain it. These are its interval ancestors, at most of them, at most three structures per area or wrap above it, and the sub-areas of the light clusters containing it. The light clusters at one node that contain the atom are nested, and the number of vertices in them at least halves from one to the next, since a light cluster has no more vertices than the heavy one. Their rounded lengths are at least these numbers, so the factors along such a chain multiply to at most . There are at most areas and wraps above an atom, so in total every atom is inflated by at most .
Choosing the alignments. The alignments determine the layout, and the layout determines how much data a vertex must absorb. Section 5 defines by a rule that depends only on the numbers for the homes of the records of and is nondecreasing in each of them. Since the vertex sets do not depend on the alignments, the map that sends a vector of alignments to the vector defined by the rule is nondecreasing. Starting from , the sequence is therefore pointwise nondecreasing. It is also bounded: the rule gives for numbers that do not depend on the alignments, because . Hence the sequence reaches a fixed point , and we use the layout for this . By Lemma 5.2, for every home .
F Proof of Lemma 5.4
Let , let , let , and let be a sufficiently large multiple of . Then , and are , and . We prove

Figure 8: Composition of a label. The head holds the color, depths of at most and the edge bits. The green part costs nothing beyond : is a multiple of , and only the quotient is stored. It holds the data of the records whose homes have large regions. The data of the other records are stored explicitly (orange).
which implies Lemma 5.4.
Notation. For a home , a moved block with home is a moved block whose home is . By Theorem 4.1 applied to the color of , is owned by , so no moved block with home has its owner below another one: the moved blocks with home have pairwise disjoint subtrees in . Let be their number, let be the number of vertices in , and let be the largest alignment of a vertex in . All units with home lie in and contain a vertex, so . All vertices of are proper descendants of the owner of the kept block that belongs to, so , and , so that .
Assignment. Let be a vertex that absorbs data. A short computation shows , so . Since has at most records and is nondecreasing in , this gives , where is the home of the absorbed record of with the largest . We assign to , and also to the moved block , or to the moved block for which the wrap was created; if is kept, we assign to only. A moved block is assigned at most vertices, its owner and the owners of the wraps created for it, and the only other vertex that can be assigned to is the owner of . Let be the sum of over the vertices assigned to . Then
Every vertex that absorbs data contributes to exactly one , and the vertices that absorb nothing have . We call a home with gap-dominated if , content-paid if it is not gap-dominated and , and subtree-paid otherwise. Claims F.2, F.3 and F.4 below bound the total charge of the three kinds by , and , respectively, so
and the bound on follows since . Both the gap-dominated and the content-paid homes are charged to vertices of their regions, so we first bound how many regions contain a vertex.
Claim F.1 (multiplicity of regions). Let be a vertex.
(a) There are at most homes J such that u lies in J, in the area of J, or in the heavy dependent of J.
(b) Every other home with is a unit with , and its parent is one of the at most areas and wraps above . If are the homes at one such node with , ordered from the outside in, then , and hence .
Proof. (a) In each case some interval ancestor of determines : the home itself, a unit of the area of , or the heavy dependent of . There are at most interval ancestors of .
(b) The clusters of the units of one node are nested or disjoint, and all of contain in their clusters. The cluster of lies in the cluster of , but not in the cluster of , which is disjoint from . Hence it lies in the cluster of a light dependent of . Since and the cluster of are disjoint parts of the cluster of , and the latter has at least as many vertices as , the numbers of vertices of the clusters of at least halve from one to the next. Since , we get .
Claim F.2 (gap-dominated homes). The total charge of the gap-dominated homes is at most .
Proof. Let be gap-dominated. Then and , so by (1),
where the last step uses and that is large. We charge to a vertex of with . A vertex is charged only by gap-dominated homes with , and . By Claim F.1, there are at most such homes of the first kind, and at most at each of the at most areas and wraps above , so at most in total. Hence receives at most , and the total is at most .
Now let be a home with that is not gap-dominated. Then , and since by (1), we have and . As is large,
Claim F.3 (content-paid homes). The total charge of the content-paid homes is at most n.
Proof. Spread evenly over the vertices of . Each of them receives at most , which is at most . By Claim F.1, a vertex receives at most 3/8 from the homes of the first kind. From the homes at each of the at most areas and wraps above it, it receives at most . In total a vertex receives less than .
Claim F.4 (subtree-paid homes). Every subtree-paid home has , and the total charge of the subtree-paid homes is at most .
Proof. If , then by (1) and (2), , so is content-paid. Hence for a subtree-paid home. Move the charge of the owner of , if it was assigned to , to one moved block with home . Then every moved block with home carries at most , which we spread evenly over the mass vertices of .
Fix a vertex and a color , and let be the ancestors of of color , from the root down, whose blocks are moved blocks with subtree-paid homes (Figure 9). Let , and . Since is heavy and is a proper descendant of the owner of the kept block that belongs to, . The home is owned by

: and are disjoint subtrees of moved blocks with the same home, owned by , inside ;
, and so on.
Figure 9: Subtree-paid homes along the path from the root to a vertex . The blocks of one color above are moved, with subtree-paid homes . The home of is owned by , which lies in , and at least one other moved block with the same home has a disjoint subtree of at least vertices.
, which is or a descendant of . Hence the at least two moved blocks with home lie in and have disjoint subtrees, and since each of them has mass at least ,
Together with , this gives , where . By (2), , and since is large compared with , we have and . So receives through the color at most
Let , so that for all , and . Group the indices into bands . In band we have , and the masses are distinct, so the band has at most members, and the -th last of them has . The band therefore contributes at most
since for . Summing over gives at most , as is large. Hence receives at most through each color, and at most in total.