Skip to main content

Edge

Struct Edge 

Source
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: EdgeId

Unique identifier

§source: NodeId

Source node

§target: NodeId

Target node

§weight: f64

Edge weight (simple scalar cost – legacy compatibility)

§multi_weight: EdgeWeight

Multi-criteria edge weight

§geometry: Option<LineString>

Geographic geometry (optional)

§bidirectional: bool

Whether 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

Source

pub fn new(id: EdgeId, source: NodeId, target: NodeId, weight: f64) -> Self

Create a new edge

Source

pub fn with_multi_weight( id: EdgeId, source: NodeId, target: NodeId, multi_weight: EdgeWeight, ) -> Self

Create a new edge with multi-criteria weight

Source

pub fn with_geometry(self, geometry: LineString) -> Self

Set the geometry for this edge

Source

pub fn bidirectional(self) -> Self

Mark the edge as bidirectional

Source

pub fn with_speed_limit(self, speed_limit: f64) -> Self

Set the speed limit

Source

pub fn with_road_class(self, road_class: RoadClass) -> Self

Set the road class

Source

pub fn add_attribute(&mut self, key: String, value: String)

Add an attribute to the edge

Source

pub fn get_attribute(&self, key: &str) -> Option<&String>

Get an attribute value

Source

pub fn travel_time(&self) -> Option<f64>

Calculate travel time based on edge length and speed limit

Source

pub fn other_node(&self, node: NodeId) -> Option<NodeId>

Returns the other endpoint of this edge given one endpoint

Source

pub fn is_self_loop(&self) -> bool

Check if this is a self-loop

Trait Implementations§

Source§

impl Clone for Edge

Source§

fn clone(&self) -> Edge

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Edge

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.