simongog / sdsl

Succinct Data Structure Library
Other
105 stars 15 forks source link

NOTE: This is version 1.0 of SDSL which is not developed further. Version 2.0 contains more features and is better documented. It is available at https://github.com/simongog/sdsl-lite.

SDSL: Succinct Data Structure Library

This is a C++ template library for succinct data structures called sdsl.

Succinct data structures are fascinating: They represent an object (like a bitvector, a tree, suffix array,...) in space close the information-theoretic lower bound of the object but the defined operations can still be performed efficiently. Hmmm, at least in theory ;) Actually there is still a big gap between theory and practice. Why? The time complexity of an operations performed on the classical fat data structure and the slim succinct data structure are the same most time in theory. However, in practice succinct structures are slow since the operations require often memory accesses with bad locality of references. Moreover, often the in theory small sub-linear space data structures account for a large amount of memory, since they are only asymptotic sub-linear and the input size for which they are negligible in practice is galactic.

The aim of the library is to provide basic and complex succinct data structure which are

A lot of engineering tricks had to be applied to reach the performance goal, for instance the use a semi-external algorithm, bit-parallelism on 64-bit words, and cache-friendly algorithms.

List of implemented data structures

Example of a complex data structure

Let us now show how you can assemble even a very complex data structure very easily. Lets begin with the most complex one, a CST! It basically consists of a CSA, an compressed LCP-array, and a succinct representation of the tree topology; each part can be specified by a template parameter. Say, we want fast navigation operations, so we take the class cst_sada<cst_type, lcp_type, bp_support_type> for our CST. Now we can specify the type of CSA. Lets take a CSA based on wavelet tree: csa_wt<wt_type, SA_sample_dens, inv_SA_sample_dens>. We can recursively specify the used types. So now we can specify the used wavelet tree, say a run-length compressed wavelet tree (wt_rlmn<>). We could recurse again and specify, each detail of the wavelet tree (e.g. which rank support structure should be used) but we stick now with the default configuration which uses an sd_vector for the marking of the heads of the runs in the wavelet tree. Lets choose at last a LCP array which uses the topology of the CST and the CSA to compress the LCP values (lcp_support_tree2) and stick with default template parameters for all types. So the final type looks like this: cst_sada<cst_wt<wt_rlmn<> >, lcp_support_tree2<> >.

Now, lets explore the data structure a little bit. We take the english.100MB input from the Pizza&Chili-corpus, construct the CST-object, output its structure, and visualise it using the d3js-library. Have fun with the result.

Types of data structures

The data structures in the library can be divided into several classes:

Each sdsl-class X has to implement the following methods:

We provide many handy methods for sdsl objects in the util namespace:

Supported platforms

The library was successfully tested on the following configurations

We plan to support Windows in the near future.

Installation

The installation requires that the cmake tool and a C++ compiler (e.g. from the GNU Compiler Collection) is installed. You can than install the library into a directory SDSL_INSTALL_DIR by calling ./install SDSL_INSTALL_DIR If SDSL_INSTALL_DIR is not specified your home directory is used. Please use an absolute path name for SDSL_INSTALL_DIR. The library header files will be located in the directory SDSL_INSTALL_DIR/include and the library in the directory SDSL_INSTALL_DIR/lib. After the installation you can execute the tests in the test directory or start with some code examples in the examples folder.

Tests

We have used the gtest framework for the tests. Compile with make and run tests with make test. We have another target vtest which runs the test with the valgrind tool. make test will try to download some texts from a gutenberg.org mirror. See the README file in the directory for details.

Examples

Compile the examples with make and experience how esay it is to use succinct data structures.

Construction of Suffix Arrays

The current version includes Yuta Mori's incredible fast suffix array construction library libdivsufsort version 2.0.1.

Contributors

Here is a list of contributes:

Code:

Bug reports:

New contributors are welcome any time!

Have fun with the library!