pub struct Graph { /* private fields */ }Expand description
Directed multigraph over typed nodes.
Invariants, enforced at construction:
- node ids are unique and case-sensitive; a collision is an error
- every edge endpoint refers to an existing node
- every node has a non-empty id, name, and file, and a span with
end > start
Parallel edges that differ in relation or confidence coexist; exact duplicate edges deduplicate silently.
Implementations§
Source§impl Graph
impl Graph
pub fn new() -> Self
pub fn add_node(&mut self, node: Node) -> Result<(), GraphError>
pub fn add_edge(&mut self, edge: Edge) -> Result<(), GraphError>
pub fn node(&self, id: &NodeId) -> Option<&Node>
pub fn nodes(&self) -> impl Iterator<Item = &Node>
pub fn edges(&self) -> impl Iterator<Item = &Edge>
pub fn edges_from<'a>( &'a self, id: &'a NodeId, ) -> impl Iterator<Item = &'a Edge>
pub fn edges_to<'a>(&'a self, id: &'a NodeId) -> impl Iterator<Item = &'a Edge>
pub fn node_count(&self) -> usize
pub fn edge_count(&self) -> usize
Trait Implementations§
impl Eq for Graph
impl StructuralPartialEq for Graph
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