pub struct WebgraphAdapter<G: SwhForwardGraph>(pub G);Expand description
Wraps a SwhForwardGraph in order to implements webgraph’s RandomAccessGraph
§Example
use std::path::PathBuf;
use webgraph::prelude::VecGraph;
use swh_graph::graph::{SwhForwardGraph, SwhUnidirectionalGraph};
use swh_graph::views::WebgraphAdapter;
fn get_graph() -> impl SwhForwardGraph {
// loads this graph:
// 1 --.
// | \
// v v
// 0 --> 2
SwhUnidirectionalGraph::new("./example").unwrap()
}
let graph = get_graph();
let adapter = WebgraphAdapter(graph);
// We can now call generic webgraph algorithms on the adapter
let order = webgraph::algo::BfsOrder::new(&adapter);
assert_eq!(order.collect::<Vec<_>>(), vec![0, 2, 1]);Tuple Fields§
§0: GTrait Implementations§
Source§impl<G: SwhForwardGraph> RandomAccessGraph for WebgraphAdapter<G>
impl<G: SwhForwardGraph> RandomAccessGraph for WebgraphAdapter<G>
Source§fn successors(&self, node_id: usize) -> Self::Labels<'_>
fn successors(&self, node_id: usize) -> Self::Labels<'_>
Returns the successors of a node. Read more
Source§impl<G: SwhForwardGraph> RandomAccessLabeling for WebgraphAdapter<G>
impl<G: SwhForwardGraph> RandomAccessLabeling for WebgraphAdapter<G>
Source§impl<G: SwhForwardGraph> SequentialLabeling for WebgraphAdapter<G>
impl<G: SwhForwardGraph> SequentialLabeling for WebgraphAdapter<G>
type Label = usize
Source§fn num_arcs_hint(&self) -> Option<u64>
fn num_arcs_hint(&self) -> Option<u64>
Returns the number of arcs in the graph, if available.
Source§fn iter_from(&self, node_id: usize) -> Self::Lender<'_>
fn iter_from(&self, node_id: usize) -> Self::Lender<'_>
Returns an iterator over the labeling starting at
from (included). Read moreSource§fn par_node_apply<A, F, R>(
&self,
func: F,
fold: R,
granularity: Granularity,
thread_pool: &ThreadPool,
pl: &mut impl ConcurrentProgressLog,
) -> A
fn par_node_apply<A, F, R>( &self, func: F, fold: R, granularity: Granularity, thread_pool: &ThreadPool, 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 moreSource§fn par_apply<F, A, R, D>(
&self,
func: F,
fold: R,
granularity: Granularity,
deg_cumul: &D,
thread_pool: &ThreadPool,
pl: &mut impl ConcurrentProgressLog,
) -> A
fn par_apply<F, A, R, D>( &self, func: F, fold: R, granularity: Granularity, deg_cumul: &D, thread_pool: &ThreadPool, pl: &mut impl ConcurrentProgressLog, ) -> A
Apply
func to each chunk of nodes containing approximately
arc_granularity arcs in parallel and folds the results using fold. Read moreimpl<G: SwhForwardGraph> SequentialGraph for WebgraphAdapter<G>
Auto Trait Implementations§
impl<G> Freeze for WebgraphAdapter<G>where
G: Freeze,
impl<G> RefUnwindSafe for WebgraphAdapter<G>where
G: RefUnwindSafe,
impl<G> Send for WebgraphAdapter<G>where
G: Send,
impl<G> Sync for WebgraphAdapter<G>where
G: Sync,
impl<G> Unpin for WebgraphAdapter<G>where
G: Unpin,
impl<G> UnwindSafe for WebgraphAdapter<G>where
G: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Truncate the current UnsignedInt to a possibly smaller size
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Truncate the current UnsignedInt to a possibly smaller size
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> UpcastableFrom<T> for T
impl<T> UpcastableFrom<T> for T
Source§fn upcast_from(value: T) -> T
fn upcast_from(value: T) -> T
Extend the current UnsignedInt to a possibly bigger size.
Source§impl<T> UpcastableFrom<T> for T
impl<T> UpcastableFrom<T> for T
Source§fn upcast_from(value: T) -> T
fn upcast_from(value: T) -> T
Extend the current UnsignedInt to a possibly bigger size.