Skip to main content

GraphView

Trait GraphView 

Source
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§

Source

fn vertex_count(&self) -> usize

Number of vertices; valid slots are 0..vertex_count.

Source

fn edge_count(&self) -> usize

Total number of outbound edges.

Source

fn out_neighbors(&self, slot: u32) -> &[u32]

Outbound neighbor slots of slot.

Source

fn out_degree(&self, slot: u32) -> u32

Number of outbound edges from slot.

Source

fn in_neighbors(&self, slot: u32) -> &[u32]

Inbound neighbor slots of slot.

§Panics

Panics unless GraphView::has_reverse is true.

Source

fn in_degree(&self, slot: u32) -> u32

Number of inbound edges into slot.

§Panics

Panics unless GraphView::has_reverse is true.

Source

fn has_reverse(&self) -> bool

Whether inbound adjacency is available.

Source

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.

Source

fn has_weights(&self) -> bool

Whether edge weights are available.

Source

fn to_vid(&self, slot: u32) -> Vid

Translate a dense slot to its external Vid.

Source

fn to_slot(&self, vid: Vid) -> Option<u32>

Translate an external Vid to its dense slot, if present.

Source

fn vertices(&self) -> Box<dyn Iterator<Item = (u32, Vid)> + '_>

Iterate over every (slot, vid) pair in the view.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§