|
ADS
Algorithms and Data Structures
|
A static directed graph whose adjacency lists are coded by Elias-Fano [see EliasFano.h] (chapter 15, Compressed Data Structures, of Ferragina's book), the representation of the adjacency lists of large graphs in Facebook's Unicorn and in the quasi-succinct indices of Vigna. More...
#include "ADS/Contract.h"#include "ADS/succinct/EliasFano.h"#include <algorithm>#include <cstddef>#include <cstdint>#include <string_view>#include <vector>#include "ADS/succinct/impl/EliasFanoGraph.tpp"Go to the source code of this file.
Classes | |
| class | ADS::EliasFanoGraph |
| a static directed graph with its adjacency lists in Elias-Fano More... | |
Namespaces | |
| namespace | ADS |
A static directed graph whose adjacency lists are coded by Elias-Fano [see EliasFano.h] (chapter 15, Compressed Data Structures, of Ferragina's book), the representation of the adjacency lists of large graphs in Facebook's Unicorn and in the quasi-succinct indices of Vigna.
The edge \( ( u , v ) \) of a graph of \( n \) nodes is the integer \( u n + v \), so that the lists, each one sorted, are one increasing sequence in \( [ 0 , n^2 ) \), and the prefix sums of the outdegrees are a second sequence that tells where the list of \( u \) starts; with \( m \) edges the graph takes about \( m ( 2 + \lceil \log_2 ( n^2 / m ) \rceil ) + n ( 2 + \lceil \log_2 ( m / n ) \rceil ) \) bits, plus the directories, and answers in \( O( 1 ) \) time the outdegree and the \( i \)-th successor of a node, and the existence of an edge by nextGEQ() in \( O( 1 ) \) expected time.
The same chapter codes each list on its own, with its own universe: since \( \sum_u d_u \log ( n / d_u ) \le m \log ( n^2 / m ) \) by the concavity of the logarithm, the lists alone can take fewer bits when the degrees are skewed, at the price of a directory and an offset per list; the single sequence here keeps one directory and the same \( O( 1 ) \) access. Neither exploits the locality and the similarity of the lists of the Web, which the codes of Boldi and Vigna do [see BVGraph.h], nor the clustering of the adjacency matrix, which the \( k^2 \)-tree does [see K2Tree.h].
The contracts [see Contract.h]: each list is strictly increasing (an audit) with its nodes in \( [ 0 , n ) \), \( n^2 \) fits in 64 bits, and the nodes and the places asked for exist. The functions are defined in EliasFanoGraph.tpp.