pub struct GraphEdge {
pub id: EdgeId,
pub source: NodeId,
pub target: NodeId,
pub edge_type: EdgeType,
pub direction: EdgeDirection,
pub weight: f64,
pub features: Vec<f64>,
pub properties: HashMap<String, EdgeProperty>,
pub labels: Vec<String>,
pub is_anomaly: bool,
pub anomaly_type: Option<String>,
pub timestamp: Option<NaiveDate>,
}Expand description
An edge in the graph.
Fields§
§id: EdgeIdUnique edge ID.
source: NodeIdSource node ID.
target: NodeIdTarget node ID.
edge_type: EdgeTypeEdge type.
direction: EdgeDirectionEdge direction.
weight: f64Edge weight (e.g., transaction amount).
features: Vec<f64>Edge features for ML.
properties: HashMap<String, EdgeProperty>Edge properties.
labels: Vec<String>Labels for supervised learning.
is_anomaly: boolIs this edge anomalous?
anomaly_type: Option<String>Anomaly type if anomalous.
timestamp: Option<NaiveDate>Timestamp (for temporal graphs).
Implementations§
Source§impl GraphEdge
impl GraphEdge
Sourcepub fn new(
id: EdgeId,
source: NodeId,
target: NodeId,
edge_type: EdgeType,
) -> Self
pub fn new( id: EdgeId, source: NodeId, target: NodeId, edge_type: EdgeType, ) -> Self
Creates a new graph edge.
Sourcepub fn with_weight(self, weight: f64) -> Self
pub fn with_weight(self, weight: f64) -> Self
Sets the edge weight.
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_property(self, name: &str, value: EdgeProperty) -> Self
pub fn with_property(self, name: &str, value: EdgeProperty) -> Self
Adds a property.
Sourcepub fn with_timestamp(self, timestamp: NaiveDate) -> Self
pub fn with_timestamp(self, timestamp: NaiveDate) -> Self
Sets the timestamp.
Sourcepub fn undirected(self) -> Self
pub fn undirected(self) -> Self
Makes the edge undirected.
Sourcepub fn as_anomaly(self, anomaly_type: &str) -> Self
pub fn as_anomaly(self, anomaly_type: &str) -> Self
Marks the edge 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 GraphEdge
impl<'de> Deserialize<'de> for GraphEdge
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 GraphEdge
impl RefUnwindSafe for GraphEdge
impl Send for GraphEdge
impl Sync for GraphEdge
impl Unpin for GraphEdge
impl UnwindSafe for GraphEdge
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