pub struct Edge {
pub id: EdgeId,
pub source: NodeId,
pub target: NodeId,
pub weight: f64,
pub multi_weight: EdgeWeight,
pub geometry: Option<LineString>,
pub bidirectional: bool,
pub speed_limit: Option<f64>,
pub road_class: Option<RoadClass>,
pub attributes: HashMap<String, String>,
}Expand description
An edge in the network graph
Fields§
§id: EdgeIdUnique identifier
source: NodeIdSource node
target: NodeIdTarget node
weight: f64Edge weight (simple scalar cost – legacy compatibility)
multi_weight: EdgeWeightMulti-criteria edge weight
geometry: Option<LineString>Geographic geometry (optional)
bidirectional: boolWhether the edge is bidirectional
speed_limit: Option<f64>Speed limit (optional, in km/h)
road_class: Option<RoadClass>Road class (for routing priority)
attributes: HashMap<String, String>Custom attributes
Implementations§
Source§impl Edge
impl Edge
Sourcepub fn with_multi_weight(
id: EdgeId,
source: NodeId,
target: NodeId,
multi_weight: EdgeWeight,
) -> Self
pub fn with_multi_weight( id: EdgeId, source: NodeId, target: NodeId, multi_weight: EdgeWeight, ) -> Self
Create a new edge with multi-criteria weight
Sourcepub fn with_geometry(self, geometry: LineString) -> Self
pub fn with_geometry(self, geometry: LineString) -> Self
Set the geometry for this edge
Sourcepub fn bidirectional(self) -> Self
pub fn bidirectional(self) -> Self
Mark the edge as bidirectional
Sourcepub fn with_speed_limit(self, speed_limit: f64) -> Self
pub fn with_speed_limit(self, speed_limit: f64) -> Self
Set the speed limit
Sourcepub fn with_road_class(self, road_class: RoadClass) -> Self
pub fn with_road_class(self, road_class: RoadClass) -> Self
Set the road class
Sourcepub fn add_attribute(&mut self, key: String, value: String)
pub fn add_attribute(&mut self, key: String, value: String)
Add an attribute to the edge
Sourcepub fn get_attribute(&self, key: &str) -> Option<&String>
pub fn get_attribute(&self, key: &str) -> Option<&String>
Get an attribute value
Sourcepub fn travel_time(&self) -> Option<f64>
pub fn travel_time(&self) -> Option<f64>
Calculate travel time based on edge length and speed limit
Sourcepub fn other_node(&self, node: NodeId) -> Option<NodeId>
pub fn other_node(&self, node: NodeId) -> Option<NodeId>
Returns the other endpoint of this edge given one endpoint
Sourcepub fn is_self_loop(&self) -> bool
pub fn is_self_loop(&self) -> bool
Check if this is a self-loop
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Edge
impl RefUnwindSafe for Edge
impl Send for Edge
impl Sync for Edge
impl Unpin for Edge
impl UnsafeUnpin for Edge
impl UnwindSafe for Edge
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