pub struct GraphNode {
pub id: NodeId,
pub node_type: NodeType,
pub external_id: String,
pub label: String,
pub features: Vec<f64>,
pub categorical_features: HashMap<String, String>,
pub properties: HashMap<String, NodeProperty>,
pub labels: Vec<String>,
pub is_anomaly: bool,
pub anomaly_type: Option<String>,
}Expand description
A node in the graph.
Fields§
§id: NodeIdUnique node ID.
node_type: NodeTypeNode type.
external_id: StringExternal ID (e.g., account code, vendor ID).
label: StringNode label for display.
features: Vec<f64>Numeric features for ML.
categorical_features: HashMap<String, String>Categorical features (will be one-hot encoded).
properties: HashMap<String, NodeProperty>Node properties.
labels: Vec<String>Labels for supervised learning.
is_anomaly: boolIs this node an anomaly?
anomaly_type: Option<String>Anomaly type if anomalous.
Implementations§
Source§impl GraphNode
impl GraphNode
Sourcepub fn new(
id: NodeId,
node_type: NodeType,
external_id: String,
label: String,
) -> Self
pub fn new( id: NodeId, node_type: NodeType, external_id: String, label: String, ) -> Self
Creates a new graph node.
Sourcepub fn with_feature(self, value: f64) -> Self
pub fn with_feature(self, value: f64) -> Self
Adds a numeric feature.
Sourcepub fn with_features(self, values: Vec<f64>) -> Self
pub fn with_features(self, values: Vec<f64>) -> Self
Adds multiple numeric features.
Sourcepub fn with_categorical(self, name: &str, value: &str) -> Self
pub fn with_categorical(self, name: &str, value: &str) -> Self
Adds a categorical feature.
Sourcepub fn with_property(self, name: &str, value: NodeProperty) -> Self
pub fn with_property(self, name: &str, value: NodeProperty) -> Self
Adds a property.
Sourcepub fn as_anomaly(self, anomaly_type: &str) -> Self
pub fn as_anomaly(self, anomaly_type: &str) -> Self
Marks the node as anomalous.
Sourcepub fn with_label(self, label: &str) -> Self
pub fn with_label(self, label: &str) -> Self
Adds a label.
Sourcepub fn feature_dim(&self) -> usize
pub fn feature_dim(&self) -> usize
Returns the feature vector dimension.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for GraphNode
impl<'de> Deserialize<'de> for GraphNode
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for GraphNode
impl RefUnwindSafe for GraphNode
impl Send for GraphNode
impl Sync for GraphNode
impl Unpin for GraphNode
impl UnwindSafe for GraphNode
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