Skip to main content

TopologyGraph

Struct TopologyGraph 

Source
pub struct TopologyGraph { /* private fields */ }
Expand description

Lazy-rebuilt connectivity graph for topology queries.

Tracks which stops are reachable from which, via which groups/lines. Rebuilt from ElevatorGroup data when marked dirty.

Implementations§

Source§

impl TopologyGraph

Source

pub fn new() -> Self

Create a new topology graph (starts dirty so the first query triggers a rebuild).

Source

pub const fn mark_dirty(&mut self)

Mark the graph as needing rebuild.

Source

pub const fn is_dirty(&self) -> bool

Whether the graph needs rebuild.

Source

pub fn rebuild(&mut self, groups: &[ElevatorGroup])

Rebuild the graph from current group/line topology.

Source

pub fn reachable_stops_from(&self, stop: EntityId) -> Vec<EntityId>

All stops reachable from a given stop (BFS).

Returns every reachable stop except the origin. If the origin has no outgoing edges the result is empty.

Source

pub fn transfer_points(groups: &[ElevatorGroup]) -> Vec<EntityId>

Stops that appear in two or more groups (transfer points).

This inspects group membership directly and does not require the adjacency graph.

Source

pub fn shortest_route(&self, from: EntityId, to: EntityId) -> Option<Route>

Find the shortest route from one stop to another (BFS on groups).

Returns None if to is unreachable from from, or if from == to. Each edge traversal becomes one RouteLeg; consecutive stops sharing the same group naturally coalesce into a single leg when the caller chooses to, but the raw path is returned as individual per-hop legs so the consumer can decide on merging strategy.

Trait Implementations§

Source§

impl Debug for TopologyGraph

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for TopologyGraph

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> 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, 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.