pub struct KnowledgeGraph { /* private fields */ }Expand description
In-memory directed knowledge graph backed by adjacency lists
Implementations§
Source§impl KnowledgeGraph
impl KnowledgeGraph
Sourcepub fn add_edge(&mut self, edge: KgEdge)
pub fn add_edge(&mut self, edge: KgEdge)
Append a directed edge. Both endpoint nodes are auto-created with default values if they do not yet exist.
Sourcepub fn neighbors<'a>(&'a self, node_id: &str) -> Vec<(&'a KgEdge, &'a KgNode)>
pub fn neighbors<'a>(&'a self, node_id: &str) -> Vec<(&'a KgEdge, &'a KgNode)>
Return outgoing (edge, target_node) pairs for node_id.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Number of edges
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KnowledgeGraph
impl RefUnwindSafe for KnowledgeGraph
impl Send for KnowledgeGraph
impl Sync for KnowledgeGraph
impl Unpin for KnowledgeGraph
impl UnsafeUnpin for KnowledgeGraph
impl UnwindSafe for KnowledgeGraph
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more