Skip to main content

BvGraph

Struct BvGraph 

Source
pub struct BvGraph<F> { /* private fields */ }
Expand description

A random-access graph in the BV format.

The graph depends on a RandomAccessDecoderFactory that can be used to create decoders for the graph. This allows to decouple the graph from the underlying storage format, and to use different storage formats for the same graph. For example, one can use a memory-mapped file for the graph, or load it in memory, or even generate it on the fly.

Note that the knowledge of the codes used by the graph is in the factory, which provides methods to read each component of the BV format (outdegree, reference offset, block count, etc.), whereas the knowledge of the compression parameters (compression window and minimum interval length) is in this structure.

Implementations§

Source§

impl BvGraph<()>

Source

pub fn with_basename( basename: impl AsRef<Path>, ) -> LoadConfig<BE, Random, Dynamic, Mmap, Mmap>

Returns a load configuration that can be customized.

Source§

impl<E: Endianness, F: CodesReaderFactoryHelper<E>, OFF: Offsets> BvGraph<DynCodesDecoderFactory<E, F, OFF>>
where for<'a> &'a OFF::DeserType<'a>: IntoIterator<Item = usize>,

Source

pub fn offsets_to_slice( self, ) -> BvGraph<DynCodesDecoderFactory<E, F, Owned<Box<[usize]>>>>

Remaps the offsets in a slice of usize.

This method is mainly useful for benchmarking and testing purposes, as representing the offsets as a slice increasing significantly the memory footprint. It just replaces current decoder factory with the result of DynCodesDecoderFactory::offsets_to_slice.

Source§

impl<E: Endianness, F: CodesReaderFactoryHelper<E>, OFF: Offsets> BvGraph<ConstCodesDecoderFactory<E, F, OFF>>

Source

pub fn offsets_to_slice( self, ) -> BvGraph<ConstCodesDecoderFactory<E, F, Owned<Box<[usize]>>>>

Remaps the offsets in a slice of usize.

This method is mainly useful for benchmarking and testing purposes, as representing the offsets as a slice increasing significantly the memory footprint. It just replaces current decoder factory with the result of ConstCodesDecoderFactory::offsets_to_slice.

Source§

impl<F> BvGraph<F>

Source

pub fn new( factory: F, number_of_nodes: usize, number_of_arcs: u64, compression_window: usize, min_interval_length: usize, ) -> Self

Creates a new BvGraph from the given parameters.

§Arguments
  • reader_factory: backend that can create objects that allows us to read the bitstream of the graph to decode the edges.
  • offsets: the bit offset at which we will have to start for decoding the edges of each node. (This is needed for the random accesses, BvGraphSeq does not need them)
  • min_interval_length: the minimum size of the intervals we are going to decode.
  • compression_window: the maximum distance between two nodes that reference each other.
  • number_of_nodes: the number of nodes in the graph.
  • number_of_arcs: the number of arcs in the graph.
Source

pub fn into_inner(self) -> F

Consumes self and returns the factory.

Source§

impl<F: SequentialDecoderFactory> BvGraph<F>

Source

pub fn offset_deg_iter(&self) -> OffsetDegIter<F::Decoder<'_>>

Creates an iterator specialized in the degrees of the nodes. This is slightly faster because it can avoid decoding some of the nodes and completely skip the merging step.

Source§

impl<F: RandomAccessDecoderFactory> BvGraph<F>
where for<'a> F::Decoder<'a>: Decode,

Source

pub fn offset_deg_iter_from(&self, node: usize) -> OffsetDegIter<F::Decoder<'_>>

Creates an iterator specialized in the degrees of the nodes starting from a given node.

Trait Implementations§

Source§

impl<F: Clone> Clone for BvGraph<F>

Source§

fn clone(&self) -> BvGraph<F>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F: Debug> Debug for BvGraph<F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, F: RandomAccessDecoderFactory> IntoLender for &'a BvGraph<F>

Convenience implementation that makes it possible to iterate over a BvGraphSeq using the for_ macro (see the crate documentation).

Source§

type Lender = <BvGraph<F> as SequentialLabeling>::Lender<'a>

The lender type that this type converts into.
Source§

fn into_lender(self) -> Self::Lender

Converts this type into a Lender.
Source§

impl<F> RandomAccessGraph for BvGraph<F>

Source§

fn successors( &self, node_id: usize, ) -> <Self as RandomAccessLabeling>::Labels<'_>

Returns the successors of a node. Read more
Source§

fn has_arc(&self, src_node_id: usize, dst_node_id: usize) -> bool

Returns whether there is an arc going from src_node_id to dst_node_id. Read more
Source§

impl<F> RandomAccessLabeling for BvGraph<F>

Source§

fn outdegree(&self, node_id: usize) -> usize

Returns the outdegree of a node.

Source§

fn labels(&self, node_id: usize) -> Succ<F::Decoder<'_>>

Returns a random access iterator over the successors of a node.

Source§

type Labels<'a> = Succ<<F as RandomAccessDecoderFactory>::Decoder<'a>> where Self: 'a, F: 'a

The type of the iterator over the labels of a node returned by labels.
Source§

fn num_arcs(&self) -> u64

Returns the number of arcs in the graph.
Source§

impl<F> SequentialLabeling for BvGraph<F>

Source§

fn iter_from(&self, start_node: usize) -> Self::Lender<'_>

Returns a fast sequential iterator over the nodes of the graph and their successors.

Source§

type Label = usize

Source§

type Lender<'b> = NodeLabels<<F as RandomAccessDecoderFactory>::Decoder<'b>> where Self: 'b, F: 'b

The type of Lender over the successors of a node returned by iter.
Source§

fn num_nodes(&self) -> usize

Returns the number of nodes in the graph.
Source§

fn num_arcs_hint(&self) -> Option<u64>

Returns the number of arcs in the graph, if available.
Source§

fn iter(&self) -> Self::Lender<'_>

Returns an iterator over the labeling. Read more
Source§

fn build_dcf(&self) -> DCF

Builds the degree cumulative function for this labeling. Read more
Source§

fn par_node_apply<A: Default + Send, F: Fn(Range<usize>) -> A + Sync, R: Fn(A, A) -> A + Sync>( &self, func: F, fold: R, granularity: Granularity, pl: &mut impl ConcurrentProgressLog, ) -> A

Applies func to each chunk of nodes of size node_granularity in parallel, and folds the results using fold. Read more
Source§

fn par_apply<F: Fn(Range<usize>) -> A + Sync, A: Default + Send, R: Fn(A, A) -> A + Sync, D: for<'a> Succ<Input = usize, Output<'a> = usize>>( &self, func: F, fold: R, granularity: Granularity, deg_cumul: &D, pl: &mut impl ConcurrentProgressLog, ) -> A

Applies func to each chunk of nodes containing approximately arc_granularity arcs in parallel and folds the results using fold. Read more
Source§

impl<F: RandomAccessDecoderFactory> SplitLabeling for BvGraph<F>
where for<'a> <F as RandomAccessDecoderFactory>::Decoder<'a>: Send + Sync,

Source§

type SplitLender<'a> = Take<<BvGraph<F> as SequentialLabeling>::Lender<'a>> where Self: 'a

Source§

type IntoIterator<'a> = Iter<'a, BvGraph<F>> where Self: 'a

Source§

fn split_iter(&self, how_many: usize) -> Self::IntoIterator<'_>

Source§

impl<F> SequentialGraph for BvGraph<F>

Auto Trait Implementations§

§

impl<F> Freeze for BvGraph<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for BvGraph<F>
where F: RefUnwindSafe,

§

impl<F> Send for BvGraph<F>
where F: Send,

§

impl<F> Sync for BvGraph<F>
where F: Sync,

§

impl<F> Unpin for BvGraph<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for BvGraph<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for BvGraph<F>
where F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CastableFrom<T> for T

Source§

fn cast_from(value: T) -> T

Call Self as W
Source§

impl<T, U> CastableInto<U> for T
where U: CastableFrom<T>,

Source§

fn cast(self) -> U

Call W::cast_from(self)
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DowncastableFrom<T> for T

Source§

fn downcast_from(value: T) -> T

Truncate the current UnsignedInt to a possibly smaller size
Source§

impl<T, U> DowncastableInto<U> for T
where U: DowncastableFrom<T>,

Source§

fn downcast(self) -> U

Call W::downcast_from(self)
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Splat<T> for T

Source§

fn splat(value: T) -> T

Source§

impl<T> To<T> for T

Source§

fn to(self) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UpcastableFrom<T> for T

Source§

fn upcast_from(value: T) -> T

Extend the current UnsignedInt to a possibly bigger size.
Source§

impl<T, U> UpcastableInto<U> for T
where U: UpcastableFrom<T>,

Source§

fn upcast(self) -> U

Call W::upcast_from(self)
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V