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>
impl<'a> GraphBuilder<'a>
Sourcepub fn new<V: CugraphElement>(
src: &'a DeviceArrayView<'a, V>,
dst: &'a DeviceArrayView<'a, V>,
) -> Self
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();Sourcepub fn properties(self, properties: GraphProperties) -> Self
pub fn properties(self, properties: GraphProperties) -> Self
Set the graph properties (symmetric / multigraph).
Defaults to GraphProperties::directed() if not called.
Sourcepub fn weights<W: CugraphElement>(
self,
weights: &'a DeviceArrayView<'a, W>,
) -> Self
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.
Sourcepub fn edge_ids<E: CugraphElement>(
self,
edge_ids: &'a DeviceArrayView<'a, E>,
) -> Self
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.
Sourcepub fn edge_type_ids<E: CugraphElement>(
self,
edge_type_ids: &'a DeviceArrayView<'a, E>,
) -> Self
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.
Sourcepub fn vertices<V: CugraphElement>(
self,
vertices: &'a DeviceArrayView<'a, V>,
) -> Self
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.
Sourcepub fn edge_start_time_ids<E: CugraphElement>(
self,
times: &'a DeviceArrayView<'a, E>,
) -> Self
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.
Sourcepub fn edge_end_time_ids<E: CugraphElement>(
self,
times: &'a DeviceArrayView<'a, E>,
) -> Self
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.
Sourcepub fn renumber(self) -> Self
pub fn renumber(self) -> Self
Enable vertex renumbering (default: disabled).
Compresses non-contiguous or sparse vertex IDs into a contiguous zero-based index range.
Sourcepub fn drop_self_loops(self) -> Self
pub fn drop_self_loops(self) -> Self
Enable dropping self-loop edges during graph construction (default: disabled).
Sourcepub fn drop_multi_edges(self) -> Self
pub fn drop_multi_edges(self) -> Self
Enable dropping multi-edges during graph construction (default: disabled).
Sourcepub fn symmetrize(self) -> Self
pub fn symmetrize(self) -> Self
Enable graph symmetrization (default: disabled).
Cannot be combined with edge_ids or
edge_type_ids.
Sourcepub fn do_expensive_check(self) -> Self
pub fn do_expensive_check(self) -> Self
Enable expensive validation checks (default: disabled).
Sourcepub fn build<T: Transposition>(
&self,
handle: &EnteredContext<'_>,
) -> Result<Graph<T>>
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:
build::<Forward>: forward form, forGraph::bfsbuild::<Transposed>: transposed form, forGraph::pagerank
§Errors
Returns an error if:
- array lengths are inconsistent
symmetrizeis combined withedge_idsoredge_type_ids- only one of
edge_start_time_ids/edge_end_time_idsis set - the C API rejects the inputs