pub struct Edge {
pub id: EdgeId,
pub source_node_id: NodeId,
pub target_node_id: NodeId,
pub type_name: String,
pub properties: BTreeMap<String, PropertyValue>,
pub next_outgoing_edge_id: EdgeId,
pub next_incoming_edge_id: EdgeId,
}Expand description
Represents a directed edge connecting two nodes in the graph.
Edges represent relationships between nodes and can have a type and properties. Edges are directed from a source node to a target node.
§Fields
id- Unique identifier for the edgesource_node_id- ID of the source (origin) nodetarget_node_id- ID of the target (destination) nodetype_name- Type/name of the relationshipproperties- Key-value pairs storing edge attributesnext_outgoing_edge_id- Next edge from source nodenext_incoming_edge_id- Next edge to target node
§Examples
use sombra::model::{Edge, PropertyValue};
use std::collections::BTreeMap;
let mut properties = BTreeMap::new();
properties.insert("since".to_string(), PropertyValue::Int(2020));
let edge = Edge::new(1, 1, 2, "KNOWS");
// Or with properties:
let mut edge_with_props = Edge::new(2, 1, 2, "WORKS_WITH");
edge_with_props.properties = properties;Fields§
§id: EdgeIdUnique identifier for this edge
source_node_id: NodeIdID of the source node
target_node_id: NodeIdID of the target node
type_name: StringType/name of the relationship
properties: BTreeMap<String, PropertyValue>Properties as key-value pairs
next_outgoing_edge_id: EdgeIdNext edge from the source node
next_incoming_edge_id: EdgeIdNext edge to the target node
Implementations§
Source§impl Edge
impl Edge
Sourcepub fn new(
id: EdgeId,
source_node_id: NodeId,
target_node_id: NodeId,
type_name: impl Into<String>,
) -> Self
pub fn new( id: EdgeId, source_node_id: NodeId, target_node_id: NodeId, type_name: impl Into<String>, ) -> Self
Creates a new edge with the given parameters.
The edge starts with no properties and no linked edges.
§Arguments
id- Unique identifier for the edgesource_node_id- ID of the source nodetarget_node_id- ID of the target nodetype_name- Type/name of the relationship
§Returns
A new Edge instance.
§Example
use sombra::model::Edge;
let edge = Edge::new(1, 1, 2, "KNOWS");
assert_eq!(edge.id, 1);
assert_eq!(edge.source_node_id, 1);
assert_eq!(edge.target_node_id, 2);
assert_eq!(edge.type_name, "KNOWS");
assert!(edge.properties.is_empty());Trait Implementations§
impl StructuralPartialEq for Edge
Auto Trait Implementations§
impl Freeze for Edge
impl RefUnwindSafe for Edge
impl Send for Edge
impl Sync for Edge
impl Unpin for Edge
impl UnwindSafe for Edge
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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