LOUDS
This crate provides a succinct data structure called LOUDS (level order unary degree sequence). LOUDS represents an ordered tree structure and supports almost constant-time tree traversal operations.
In LOUDS, a tree structure containing n nodes is repsresented as a bit sequence of length 2n + 1. We compress the sequence by using fid.
This crate also includes Trie implementation with LOUDS.
Usage
Add this to your Cargo.toml
.
[]
= "0.1.1"
Examples
Ordered Tree
0
/ \
1 2
/ | \ / \
3 4 5 6 7
/ \ | |
8 9 10 11
extern crate louds;
use Louds;
// Create LOUDS tree by pushing degree (# of children) of
// each node in breadth-first order.
let degrees = &;
let mut louds = new;
for &d in degrees
// Tree traversal operations (move to parent/children/sibling)
// are supported in constant-time.
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// Computing depth of a node takes time proportional to
// the height of the tree.
assert_eq!;
Credits
LOUDS representation was first proposed in [1].
[1] G. Jacobson(1989). Space-efficient Static Trees and Graphs. In Proc. IEEE FOCS, pages 549–554.
[2] 定兼 邦彦(2018). 簡潔データ構造. 共立出版.