use codegraph_core::{EdgeId, EdgeType, NodeId};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CodeEdge {
pub id: EdgeId,
pub from: NodeId,
pub to: NodeId,
pub edge_type: EdgeType,
pub weight: f64,
pub metadata: HashMap<String, String>,
}
impl CodeEdge {
pub fn new(from: NodeId, to: NodeId, edge_type: EdgeType) -> Self {
Self {
id: EdgeId::new_v4(),
from,
to,
edge_type,
weight: 1.0,
metadata: HashMap::new(),
}
}
pub fn with_weight(mut self, weight: f64) -> Self {
self.weight = weight;
self
}
pub fn with_metadata(mut self, key: String, value: String) -> Self {
self.metadata.insert(key, value);
self
}
}