pub struct GraphStore { /* private fields */ }Expand description
In-memory graph store backed by adjacency lists.
Implementations§
Source§impl GraphStore
impl GraphStore
Sourcepub fn add_entity(&mut self, entity: Entity)
pub fn add_entity(&mut self, entity: Entity)
Adds an entity, replacing any existing entity with the same id.
Sourcepub fn add_relation(&mut self, relation: Relation)
pub fn add_relation(&mut self, relation: Relation)
Adds a directed relation and updates the adjacency list.
Sourcepub fn get_entity(&self, id: &str) -> Option<&Entity>
pub fn get_entity(&self, id: &str) -> Option<&Entity>
Returns a reference to an entity by id.
Sourcepub fn entity_ids(&self) -> Vec<String>
pub fn entity_ids(&self) -> Vec<String>
Returns all entity ids.
Sourcepub fn entity_count(&self) -> usize
pub fn entity_count(&self) -> usize
Returns the number of entities.
Sourcepub fn relation_count(&self) -> usize
pub fn relation_count(&self) -> usize
Returns the number of relations.
Sourcepub fn neighbors(&self, entity_id: &str) -> Vec<String>
pub fn neighbors(&self, entity_id: &str) -> Vec<String>
Returns the neighbor entity ids of a given entity (both directions).
Sourcepub fn subgraph(&self, seed: &str, depth: usize) -> (Vec<Entity>, Vec<Relation>)
pub fn subgraph(&self, seed: &str, depth: usize) -> (Vec<Entity>, Vec<Relation>)
Returns the subgraph around a seed entity: the seed, its direct neighbors, and all relations among them.
Sourcepub fn relations_for(&self, entity_id: &str) -> Vec<&Relation>
pub fn relations_for(&self, entity_id: &str) -> Vec<&Relation>
Returns all relations involving a given entity.
Sourcepub fn all_entities(&self) -> &HashMap<String, Entity>
pub fn all_entities(&self) -> &HashMap<String, Entity>
Returns a reference to all entities.
Sourcepub fn all_relations(&self) -> &[Relation]
pub fn all_relations(&self) -> &[Relation]
Returns a reference to all relations.
Sourcepub fn set_communities(&mut self, communities: Vec<Community>)
pub fn set_communities(&mut self, communities: Vec<Community>)
Replaces the stored communities.
Sourcepub fn communities(&self) -> &[Community]
pub fn communities(&self) -> &[Community]
Returns a reference to the stored communities.
Sourcepub fn set_community_summaries(&mut self, summaries: Vec<String>)
pub fn set_community_summaries(&mut self, summaries: Vec<String>)
Replaces the stored community summaries.
Sourcepub fn community_summaries(&self) -> &[String]
pub fn community_summaries(&self) -> &[String]
Returns a reference to the stored community summaries.
Sourcepub fn community_summaries_mut(&mut self) -> &mut Vec<String>
pub fn community_summaries_mut(&mut self) -> &mut Vec<String>
Returns a mutable reference to the stored community summaries.
Trait Implementations§
Source§impl Clone for GraphStore
impl Clone for GraphStore
Source§fn clone(&self) -> GraphStore
fn clone(&self) -> GraphStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more