ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
BVGraph.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*----------------------------- File BVGraph.h -----------------------------*/
3/*--------------------------------------------------------------------------*/
68/*--------------------------------------------------------------------------*/
69/*----------------------------- DEFINITIONS --------------------------------*/
70/*--------------------------------------------------------------------------*/
71
72#ifndef __ADS_BVGraph
73 #define __ADS_BVGraph
74/* self-identification: #endif constant */
75
76/*--------------------------------------------------------------------------*/
77/*------------------------------ INCLUDES ----------------------------------*/
78/*--------------------------------------------------------------------------*/
79
80#include "ADS/Contract.h"
85
86#include <algorithm>
87#include <cstddef>
88#include <cstdint>
89#include <iterator>
90#include <string_view>
91#include <utility>
92#include <vector>
93
94/*--------------------------------------------------------------------------*/
95/*--------------------------- NAMESPACE ------------------------------------*/
96/*--------------------------------------------------------------------------*/
97
98namespace ADS
99{
100
101/*--------------------------------------------------------------------------*/
102/*----------------------------- CLASS BVGraph ------------------------------*/
103/*--------------------------------------------------------------------------*/
104
108{
109
110/*--------------------------------------------------------------------------*/
111 public:
113 using List = std::vector< std::size_t >;
114
116 using Interval = std::pair< std::size_t , std::size_t >;
117
119 BVGraph( void ) = default;
120
162 explicit BVGraph( const std::vector< List > & a , std::size_t w = 7 ,
163 std::size_t r = 3 , std::size_t lmin = 4 );
164
166 [[nodiscard]] std::size_t order( void ) const;
167
169 [[nodiscard]] std::size_t edges( void ) const;
170
173 [[nodiscard]] std::size_t outdegree( std::size_t x ) const;
174
202 [[nodiscard]] List successors( std::size_t x ) const;
203
206 [[nodiscard]] std::size_t reference( std::size_t x ) const;
207
209 [[nodiscard]] std::size_t codeBits( void ) const;
210
212 [[nodiscard]] std::size_t sizeInBits( void ) const;
213
216 [[nodiscard]] static BitVector copyList( const List & s , const List & ref );
217
236 [[nodiscard]] static std::pair< bool , std::vector< std::size_t > >
237 copyBlocks( const BitVector & c );
238
258 [[nodiscard]] static std::pair< std::vector< Interval > , List >
259 intervals( const List & e , std::size_t lmin );
260
264 [[nodiscard]] static std::vector< std::uint64_t >
265 residualGaps( const List & res , std::size_t x );
266
267/*----------------------------- THE PERSISTENCE ----------------------------*/
268
270 static constexpr std::string_view persistName = "BVGraph";
271
274 template< class A >
275 void persist( A & a );
276
277/*--------------------------------------------------------------------------*/
278 private:
281 [[nodiscard]] List decode( std::size_t x ) const;
282
283 std::size_t f_n = 0;
284 std::size_t f_m = 0;
285 std::size_t f_lmin = 4;
286 BitVector f_bits;
287 EliasFano f_start;
288
289 }; // end( class BVGraph )
290
291/*--------------------------------------------------------------------------*/
292
293} // end( namespace ADS )
294
295/*--------------------------------------------------------------------------*/
296/*-------------------------- IMPLEMENTATION --------------------------------*/
297/*--------------------------------------------------------------------------*/
298
299#include "ADS/succinct/impl/BVGraph.tpp"
300
301/*--------------------------------------------------------------------------*/
302
303#endif /* BVGraph.h included */
304
305/*--------------------------------------------------------------------------*/
306/*---------------------------- End File BVGraph.h --------------------------*/
307/*--------------------------------------------------------------------------*/
The streams of bits on which the integer codes are written and read [see IntegerCodes....
The vector of bits on which the succinct structures and the integer codes of ADS are built: the bits ...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The Elias-Fano representation of a non-decreasing sequence of integers in (chapters 11,...
The codes of the integers of chapter 11, Integer Coding, of Ferragina's book: self-delimiting binary ...
std::pair< std::size_t, std::size_t > Interval
an interval of extra nodes, its left extreme and its length
Definition BVGraph.h:116
std::size_t sizeInBits(void) const
the bits of the lists and of their places
static std::pair< bool, std::vector< std::size_t > > copyBlocks(const BitVector &c)
the copy blocks of the copy list : its first bit and the lengths less 1 of its runs but the last
static std::pair< std::vector< Interval >, List > intervals(const List &e, std::size_t lmin)
the runs of at least consecutive integers of the strictly increasing , and the residuals
std::size_t edges(void) const
the number of edges,
static BitVector copyList(const List &s, const List &ref)
the copy list of against the reference list ref: a bit per item of ref, 1 if it is in (found by a b...
static std::vector< std::uint64_t > residualGaps(const List &res, std::size_t x)
the residuals res of as written: the first as signedToNatural() of its difference from ,...
std::vector< std::size_t > List
an adjacency list, strictly increasing
Definition BVGraph.h:113
std::size_t order(void) const
the number of nodes,
BVGraph(void)=default
the graph with no node
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]
BVGraph(const std::vector< List > &a, std::size_t w=7, std::size_t r=3, std::size_t lmin=4)
the graph of the adjacency lists , with the window , chains of references at most long and intervals...
std::size_t outdegree(std::size_t x) const
the number of successors of , the first code of its list
static constexpr std::string_view persistName
the name of the structure in a file [see Persistence.h]
Definition BVGraph.h:270
List successors(std::size_t x) const
the successors of , in increasing order
std::size_t reference(std::size_t x) const
the reference of , 0 for none
std::size_t codeBits(void) const
the bits of the lists
a vector of bits packed in words of 64 bits
Definition BitVector.h:479
BasicEliasFano< false > EliasFano
Elias-Fano with the inventories of built in the constructor, the fastest access() and nextGEQ().
Definition EliasFano.h:291
Definition ADT.h:96