use serde::{Deserialize, Serialize}; use crate::{NodeId, LabelId}; use crate::core::property::PropertyMap; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Node { pub id: NodeId, pub labels: Vec, pub properties: PropertyMap, } impl Node { pub fn new(id: NodeId) -> Self { Self { id, labels: Vec::new(), properties: PropertyMap::new(), } } pub fn with_labels(mut self, labels: Vec) -> Self { self.labels = labels; self } pub fn with_properties(mut self, properties: PropertyMap) -> Self { self.properties = properties; self } pub fn add_label(&mut self, label: LabelId) { if !self.labels.contains(&label) { self.labels.push(label); } } pub fn remove_label(&mut self, label: LabelId) { self.labels.retain(|&l| l != label); } pub fn has_label(&self, label: LabelId) -> bool { self.labels.contains(&label) } }