pub struct Node {
pub id: NodeId,
pub labels: Vec<String>,
pub properties: BTreeMap<String, PropertyValue>,
pub first_outgoing_edge_id: EdgeId,
pub first_incoming_edge_id: EdgeId,
}Expand description
Represents a node in the graph.
Nodes are the primary entities in a graph database and can have multiple labels and properties. Nodes are connected by edges.
§Fields
id- Unique identifier for the nodelabels- List of labels categorizing the nodeproperties- Key-value pairs storing node attributesfirst_outgoing_edge_id- Head of the outgoing edge linked listfirst_incoming_edge_id- Head of the incoming edge linked list
§Examples
use sombra::model::{Node, PropertyValue};
use std::collections::BTreeMap;
let mut properties = BTreeMap::new();
properties.insert("name".to_string(), PropertyValue::String("Alice".to_string()));
properties.insert("age".to_string(), PropertyValue::Int(30));
let mut node = Node::new(1);
node.labels.push("Person".to_string());
node.properties = properties;Fields§
§id: NodeIdUnique identifier for this node
labels: Vec<String>Labels that categorize this node
properties: BTreeMap<String, PropertyValue>Properties as key-value pairs
first_outgoing_edge_id: EdgeIdFirst edge in the outgoing edge list
first_incoming_edge_id: EdgeIdFirst edge in the incoming edge list
Implementations§
Source§impl Node
impl Node
Sourcepub fn new(id: NodeId) -> Self
pub fn new(id: NodeId) -> Self
Creates a new node with the given ID.
The node starts with no labels, no properties, and no edges.
§Arguments
id- Unique identifier for the node
§Returns
A new Node instance.
§Example
use sombra::model::Node;
let node = Node::new(1);
assert_eq!(node.id, 1);
assert!(node.labels.is_empty());
assert!(node.properties.is_empty());Trait Implementations§
impl StructuralPartialEq for Node
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Node
impl UnwindSafe for Node
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