scirs2_graph/base/types.rs
1//! Core types for graph structures
2
3use std::hash::Hash;
4
5/// A trait representing a node in a graph
6pub trait Node: Clone + Eq + Hash + Send + Sync {}
7
8/// Implements Node for common types
9impl<T: Clone + Eq + Hash + Send + Sync> Node for T {}
10
11/// A trait for edge weights in a graph
12pub trait EdgeWeight: Clone + PartialOrd + Send + Sync {}
13
14/// Implements EdgeWeight for common types
15impl<T: Clone + PartialOrd + Send + Sync> EdgeWeight for T {}
16
17/// Represents an edge in a graph
18#[derive(Debug, Clone)]
19pub struct Edge<N: Node, E: EdgeWeight> {
20 /// Source node
21 pub source: N,
22 /// Target node
23 pub target: N,
24 /// Edge weight
25 pub weight: E,
26}