pub struct Graph { /* private fields */ }Implementations§
Source§impl Graph
impl Graph
pub fn add_node(&mut self, node: Node)
pub fn add_edge(&mut self, edge: Edge)
pub fn node(&self, id: &str) -> Option<&Node>
pub fn edge(&self, id: &str) -> Option<&Edge>
pub fn node_count(&self) -> usize
pub fn edge_count(&self) -> usize
pub fn nodes(&self) -> impl Iterator<Item = &Node>
pub fn edges(&self) -> impl Iterator<Item = &Edge>
Sourcepub fn neighbors(&self, id: &str) -> Vec<NodeId> ⓘ
pub fn neighbors(&self, id: &str) -> Vec<NodeId> ⓘ
Undirected neighbors: every node reachable by one edge, either direction.
pub fn degree(&self, id: &str) -> usize
Sourcepub fn upsert_node(&mut self, n: Node)
pub fn upsert_node(&mut self, n: Node)
Insert or replace a node by id.
Sourcepub fn upsert_edge(&mut self, e: Edge)
pub fn upsert_edge(&mut self, e: Edge)
Insert or replace an edge by id. Replacing an edge whose endpoints
changed unlinks the OLD endpoints first — otherwise the id would linger
in adjacency lists it no longer belongs to and be missing from the ones
it does, so degree()/most_central() would disagree with edges.
Sourcepub fn most_central(&self) -> Option<NodeId>
pub fn most_central(&self) -> Option<NodeId>
The highest-degree node, ties broken by smallest id (deterministic).
None for an empty graph.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graph
impl UnwindSafe for Graph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more