pub struct DynamicGraph { /* private fields */ }Expand description
Mutable directed graph with incremental add/remove and a reverse index.
Implementations§
Source§impl DynamicGraph
impl DynamicGraph
Sourcepub fn from_adjacency_list(g: &AdjacencyList) -> GraphalgResult<Self>
pub fn from_adjacency_list(g: &AdjacencyList) -> GraphalgResult<Self>
Build a dynamic graph from a static AdjacencyList (directed).
Parallel edges in the source list increment the multiplicity.
Sourcepub fn num_distinct_edges(&self) -> usize
pub fn num_distinct_edges(&self) -> usize
Number of distinct directed edges (ignoring multiplicity).
Sourcepub fn out_neighbors(&self, u: usize) -> GraphalgResult<&[usize]>
pub fn out_neighbors(&self, u: usize) -> GraphalgResult<&[usize]>
Out-neighbours of u (distinct, unsorted).
Sourcepub fn in_neighbors(&self, u: usize) -> GraphalgResult<&[usize]>
pub fn in_neighbors(&self, u: usize) -> GraphalgResult<&[usize]>
In-neighbours of u (distinct, unsorted).
Sourcepub fn out_degree(&self, u: usize) -> GraphalgResult<usize>
pub fn out_degree(&self, u: usize) -> GraphalgResult<usize>
Out-degree of u counting multiplicity.
Sourcepub fn edge_multiplicity(&self, u: usize, v: usize) -> u32
pub fn edge_multiplicity(&self, u: usize, v: usize) -> u32
Multiplicity of the ordered pair (u, v) (zero if absent).
Sourcepub fn has_edge(&self, u: usize, v: usize) -> bool
pub fn has_edge(&self, u: usize, v: usize) -> bool
Whether the directed edge u -> v is present.
Sourcepub fn add_edge(&mut self, u: usize, v: usize) -> GraphalgResult<bool>
pub fn add_edge(&mut self, u: usize, v: usize) -> GraphalgResult<bool>
Insert a directed edge u -> v, incrementing multiplicity.
Returns true if this introduced a new distinct edge (the pair was not
previously present), false if it only bumped an existing multiplicity.
Sourcepub fn remove_edge(&mut self, u: usize, v: usize) -> GraphalgResult<bool>
pub fn remove_edge(&mut self, u: usize, v: usize) -> GraphalgResult<bool>
Remove one unit of multiplicity from the directed edge u -> v.
Returns true if the distinct edge was fully removed (multiplicity hit
zero), false if it merely decremented. Errors with GraphalgError::NoSolution
when the edge is absent.
Sourcepub fn to_adjacency_list(&self) -> AdjacencyList
pub fn to_adjacency_list(&self) -> AdjacencyList
Materialise the current state as a static AdjacencyList, expanding
each pair to its multiplicity (so parallel edges reappear).
Trait Implementations§
Source§impl Clone for DynamicGraph
impl Clone for DynamicGraph
Source§fn clone(&self) -> DynamicGraph
fn clone(&self) -> DynamicGraph
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more