Skip to main content

GraphBuilder

Struct GraphBuilder 

Source
pub struct GraphBuilder<'a> { /* private fields */ }
Expand description

Builder for constructing a Graph from edge lists.

Provides a fluent by-value API for setting optional arrays and configuration flags. All setters consume self and return Self.

Constructs a Graph from device edge lists represented as DeviceArrayView columns. High-level cuDF table ingress is provided by crate::cudf_interop.

§Required parameters

  • src: source vertex ids (device array view)
  • dst: destination vertex ids (device array view)

Properties default to a directed simple graph. Use properties() to override.

§Example

let src_view = src.view().unwrap();
let dst_view = dst.view().unwrap();
let wgt_view = wgt.view().unwrap();
let graph = GraphBuilder::new(&src_view, &dst_view)
    .weights(&wgt_view)
    .renumber()
    .build::<Transposed>(&entered)?;

Implementations§

Source§

impl<'a> GraphBuilder<'a>

Source

pub fn new<V: CugraphElement>( src: &'a DeviceArrayView<'a, V>, dst: &'a DeviceArrayView<'a, V>, ) -> Self

Create a new builder with the required edge arrays.

Properties default to a directed simple graph. All optional arrays default to None and all boolean flags default to false.

§Example
let src = DeviceArray::from_slice(&entered, &[0i32, 1, 2]).unwrap();
let dst = DeviceArray::from_slice(&entered, &[1i32, 2, 0]).unwrap();

let src_view = src.view().unwrap();
let dst_view = dst.view().unwrap();
let graph = GraphBuilder::new(&src_view, &dst_view)
    .renumber()
    .build::<Forward>(&entered)
    .unwrap();
Source

pub fn properties(self, properties: GraphProperties) -> Self

Set the graph properties (symmetric / multigraph).

Defaults to GraphProperties::directed() if not called.

Source

pub fn weights<W: CugraphElement>( self, weights: &'a DeviceArrayView<'a, W>, ) -> Self

Set the optional edge weights array.

Must have the same length as src/dst.

Source

pub fn edge_ids<E: CugraphElement>( self, edge_ids: &'a DeviceArrayView<'a, E>, ) -> Self

Set the optional edge ids array.

Must have the same length as src/dst.

Source

pub fn edge_type_ids<E: CugraphElement>( self, edge_type_ids: &'a DeviceArrayView<'a, E>, ) -> Self

Set the optional edge type ids array.

Must have the same length as src/dst.

Source

pub fn vertices<V: CugraphElement>( self, vertices: &'a DeviceArrayView<'a, V>, ) -> Self

Set the optional vertex array.

When None (the default), vertices are auto-detected from the edge list.

Source

pub fn edge_start_time_ids<E: CugraphElement>( self, times: &'a DeviceArrayView<'a, E>, ) -> Self

Set the optional edge start time ids array.

Must have the same length as src/dst.

Source

pub fn edge_end_time_ids<E: CugraphElement>( self, times: &'a DeviceArrayView<'a, E>, ) -> Self

Set the optional edge end time ids array.

Must have the same length as src/dst.

Source

pub fn renumber(self) -> Self

Enable vertex renumbering (default: disabled).

Compresses non-contiguous or sparse vertex IDs into a contiguous zero-based index range.

Source

pub fn drop_self_loops(self) -> Self

Enable dropping self-loop edges during graph construction (default: disabled).

Source

pub fn drop_multi_edges(self) -> Self

Enable dropping multi-edges during graph construction (default: disabled).

Source

pub fn symmetrize(self) -> Self

Enable graph symmetrization (default: disabled).

Cannot be combined with edge_ids or edge_type_ids.

Source

pub fn do_expensive_check(self) -> Self

Enable expensive validation checks (default: disabled).

Source

pub fn build<T: Transposition>( &self, handle: &EnteredContext<'_>, ) -> Result<Graph<T>>

Validate inputs and construct a Graph<T> on the GPU.

The type parameter T determines the transposition state:

§Errors

Returns an error if:

  • array lengths are inconsistent
  • symmetrize is combined with edge_ids or edge_type_ids
  • only one of edge_start_time_ids / edge_end_time_ids is set
  • the C API rejects the inputs

Trait Implementations§

Source§

impl Clone for GraphBuilder<'_>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for GraphBuilder<'_>

Source§

impl<'a> Debug for GraphBuilder<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Send for GraphBuilder<'a>

§

impl<'a> !Sync for GraphBuilder<'a>

§

impl<'a> Freeze for GraphBuilder<'a>

§

impl<'a> RefUnwindSafe for GraphBuilder<'a>

§

impl<'a> Unpin for GraphBuilder<'a>

§

impl<'a> UnsafeUnpin for GraphBuilder<'a>

§

impl<'a> UnwindSafe for GraphBuilder<'a>

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> 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> 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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.