pub struct EdgeType {
pub base: DataPoint,
pub relationship_name: String,
pub number_of_edges: i32,
}Expand description
Storage-layer edge type model.
Represents a type of relationship between entities (e.g., “works_at”, “located_in”, “knows”). Used for indexing and semantic search of relationship types.
Fields§
§base: DataPointBase data point fields (id, timestamps, metadata, etc.)
relationship_name: StringRelationship name (e.g., “works_at”, “located_in”)
number_of_edges: i32Number of edges of this type (for statistics)
Implementations§
Source§impl EdgeType
impl EdgeType
Sourcepub const INDEX_FIELDS: &'static [&'static str]
pub const INDEX_FIELDS: &'static [&'static str]
Index fields to embed for vector search.
Sourcepub fn deterministic_id(relationship_name: &str) -> Uuid
pub fn deterministic_id(relationship_name: &str) -> Uuid
Compute a deterministic UUID for an EdgeType from its relationship name.
Mirrors Python’s EdgeType.id_for(relationship_name)
(identity_fields=["relationship_name"]):
uuid5(NAMESPACE_OID, "EdgeType:<normalized relationship_name>").
The EdgeType: class prefix was added upstream in cognee 1.2.0
(namespace_edge_type_point_ids.py) — the previous bare-name scheme
(uuid5(OID, normalized)) let a relationship and a same-named node
collide on one point id.
Sourcepub fn retrieval_text(
edge_text: Option<&str>,
relationship_name: &str,
) -> String
pub fn retrieval_text( edge_text: Option<&str>, relationship_name: &str, ) -> String
Resolve the retrieval text for an edge, mirroring Python’s
get_edge_retrieval_text(edge_text, relationship_name)
(prepare_edges_for_storage.py:26-28 via index_graph_edges.py:33-53):
prefer the nonblank edge_text, fall back to the nonblank
relationship_name, else return an empty string (caller drops empties).
Takes primitive &str params (not a GraphEdgePair, which lives in
cognee-cognify and would introduce a cyclic dependency) so any lane
can recompute the exact text an EdgeType/Triplet vector id was
derived from.
Sourcepub fn new(
relationship_name: impl Into<String>,
dataset_id: Option<Uuid>,
) -> Self
pub fn new( relationship_name: impl Into<String>, dataset_id: Option<Uuid>, ) -> Self
Create a new EdgeType with a random UUID.
§Arguments
relationship_name- Relationship name (e.g., “works_at”)dataset_id- Dataset UUID
Sourcepub fn new_deterministic(
relationship_name: impl Into<String>,
dataset_id: Option<Uuid>,
) -> Self
pub fn new_deterministic( relationship_name: impl Into<String>, dataset_id: Option<Uuid>, ) -> Self
Create a new EdgeType with a deterministic UUID derived from the
relationship name, matching Python’s generate_edge_id.
§Arguments
relationship_name- Relationship name (e.g., “works_at”)dataset_id- Dataset UUID
Sourcepub fn get_embeddable_text(&self) -> String
pub fn get_embeddable_text(&self) -> String
Get the relationship name (for embedding).
Sourcepub fn increment_count(&mut self)
pub fn increment_count(&mut self)
Increment the edge count.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for EdgeType
impl<'de> Deserialize<'de> for EdgeType
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl HasDataPoint for EdgeType
impl HasDataPoint for EdgeType
Source§fn data_point(&self) -> &DataPoint
fn data_point(&self) -> &DataPoint
DataPoint of this container.Source§fn data_point_mut(&mut self) -> &mut DataPoint
fn data_point_mut(&mut self) -> &mut DataPoint
DataPoint of this container.Source§fn for_each_child_mut(&mut self, _visit: &mut dyn FnMut(&mut dyn HasDataPoint))
fn for_each_child_mut(&mut self, _visit: &mut dyn FnMut(&mut dyn HasDataPoint))
HasDataPoint.
Default: no children. Override on container types whose fields
own (rather than reference by Uuid) another HasDataPoint.