pub trait GraphView: Send + Sync {
// Required methods
fn vertex_count(&self) -> usize;
fn edge_count(&self) -> usize;
fn out_neighbors(&self, slot: u32) -> &[u32];
fn out_degree(&self, slot: u32) -> u32;
fn in_neighbors(&self, slot: u32) -> &[u32];
fn in_degree(&self, slot: u32) -> u32;
fn has_reverse(&self) -> bool;
fn out_weight(&self, slot: u32, edge_idx: usize) -> f64;
fn has_weights(&self) -> bool;
fn to_vid(&self, slot: u32) -> Vid;
fn to_slot(&self, vid: Vid) -> Option<u32>;
fn vertices(&self) -> Box<dyn Iterator<Item = (u32, Vid)> + '_>;
}Expand description
Stable, read-only topology view handed to a plugin algorithm.
Vertices are addressed by dense u32 slots (0..vertex_count);
GraphView::to_vid / GraphView::to_slot translate to and from
external Vids at the boundary. Neighbor accessors return neighbor
slots, not vids. A GraphView reflects the subgraph named by the
GraphProjectionSpec that produced it and does not observe later
writes.
§Panics
GraphView::out_weight panics unless GraphView::has_weights is
true, and GraphView::in_neighbors / GraphView::in_degree
panic unless GraphView::has_reverse is true. Guard with those
predicates before calling.
Required Methods§
Sourcefn vertex_count(&self) -> usize
fn vertex_count(&self) -> usize
Number of vertices; valid slots are 0..vertex_count.
Sourcefn edge_count(&self) -> usize
fn edge_count(&self) -> usize
Total number of outbound edges.
Sourcefn out_neighbors(&self, slot: u32) -> &[u32]
fn out_neighbors(&self, slot: u32) -> &[u32]
Outbound neighbor slots of slot.
Sourcefn out_degree(&self, slot: u32) -> u32
fn out_degree(&self, slot: u32) -> u32
Number of outbound edges from slot.
Sourcefn in_neighbors(&self, slot: u32) -> &[u32]
fn in_neighbors(&self, slot: u32) -> &[u32]
Sourcefn has_reverse(&self) -> bool
fn has_reverse(&self) -> bool
Whether inbound adjacency is available.
Sourcefn out_weight(&self, slot: u32, edge_idx: usize) -> f64
fn out_weight(&self, slot: u32, edge_idx: usize) -> f64
Weight of the edge_idx-th outbound edge of slot.
edge_idx indexes into GraphView::out_neighbors of slot.
§Panics
Panics unless GraphView::has_weights is true.
Sourcefn has_weights(&self) -> bool
fn has_weights(&self) -> bool
Whether edge weights are available.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".