pub struct KnowledgeGraph { /* private fields */ }Expand description
The main knowledge graph container.
Implementations§
Source§impl KnowledgeGraph
impl KnowledgeGraph
Sourcepub fn is_strict_mode(&self) -> bool
pub fn is_strict_mode(&self) -> bool
Returns whether strict mode is enabled.
Sourcepub fn item_count(&self) -> usize
pub fn item_count(&self) -> usize
Returns the number of items in the graph.
Sourcepub fn relationship_count(&self) -> usize
pub fn relationship_count(&self) -> usize
Returns the number of relationships in the graph.
Sourcepub fn add_relationship(
&mut self,
from: &ItemId,
to: &ItemId,
rel_type: RelationshipType,
) -> Option<()>
pub fn add_relationship( &mut self, from: &ItemId, to: &ItemId, rel_type: RelationshipType, ) -> Option<()>
Adds a relationship between two items.
Sourcepub fn get_mut(&mut self, id: &ItemId) -> Option<&mut Item>
pub fn get_mut(&mut self, id: &ItemId) -> Option<&mut Item>
Gets a mutable reference to an item by ID.
Sourcepub fn items_by_type(&self, item_type: ItemType) -> Vec<&Item>
pub fn items_by_type(&self, item_type: ItemType) -> Vec<&Item>
Returns all items of a specific type.
Sourcepub fn count_by_type(&self) -> HashMap<ItemType, usize>
pub fn count_by_type(&self) -> HashMap<ItemType, usize>
Returns the count of items by type.
Sourcepub fn parents(&self, id: &ItemId) -> Vec<&Item>
pub fn parents(&self, id: &ItemId) -> Vec<&Item>
Returns direct parents of an item (items that this item relates to upstream).
Sourcepub fn children(&self, id: &ItemId) -> Vec<&Item>
pub fn children(&self, id: &ItemId) -> Vec<&Item>
Returns direct children of an item (items that relate to this item downstream).
Sourcepub fn orphans(&self) -> Vec<&Item>
pub fn orphans(&self) -> Vec<&Item>
Returns all items with no upstream parents (potential orphans).
Sourcepub fn inner(&self) -> &DiGraph<Item, RelationshipType>
pub fn inner(&self) -> &DiGraph<Item, RelationshipType>
Returns the underlying petgraph for advanced operations.
Sourcepub fn inner_mut(&mut self) -> &mut DiGraph<Item, RelationshipType>
pub fn inner_mut(&mut self) -> &mut DiGraph<Item, RelationshipType>
Returns a mutable reference to the underlying petgraph.
Sourcepub fn node_index(&self, id: &ItemId) -> Option<NodeIndex>
pub fn node_index(&self, id: &ItemId) -> Option<NodeIndex>
Returns the node index for an item ID.
Sourcepub fn has_cycles(&self) -> bool
pub fn has_cycles(&self) -> bool
Checks if the graph has cycles.
Sourcepub fn relationships(&self) -> Vec<(ItemId, ItemId, RelationshipType)>
pub fn relationships(&self) -> Vec<(ItemId, ItemId, RelationshipType)>
Returns all relationships in the graph.
Trait Implementations§
Source§impl Debug for KnowledgeGraph
impl Debug for KnowledgeGraph
Auto Trait Implementations§
impl Freeze for KnowledgeGraph
impl RefUnwindSafe for KnowledgeGraph
impl Send for KnowledgeGraph
impl Sync for KnowledgeGraph
impl Unpin 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
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>
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>
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