pub struct LinkSpace<P = ()> { /* private fields */ }Expand description
Generic link-based network space.
Implementations§
Source§impl<P> LinkSpace<P>
impl<P> LinkSpace<P>
Sourcepub fn add_link(
&mut self,
from: NodeId,
to: NodeId,
geometry: LinkGeometry,
properties: P,
) -> Result<LinkId, LinkSpaceError>
pub fn add_link( &mut self, from: NodeId, to: NodeId, geometry: LinkGeometry, properties: P, ) -> Result<LinkId, LinkSpaceError>
Add a directed link from from to to with geometry and per-link properties.
Sourcepub fn link_geometry(&self, link_id: LinkId) -> Option<&LinkGeometry>
pub fn link_geometry(&self, link_id: LinkId) -> Option<&LinkGeometry>
Immutable access to link geometry.
Sourcepub fn link_geometry_mut(
&mut self,
link_id: LinkId,
) -> Option<&mut LinkGeometry>
pub fn link_geometry_mut( &mut self, link_id: LinkId, ) -> Option<&mut LinkGeometry>
Mutable access to link geometry.
Sourcepub fn link_properties(&self, link_id: LinkId) -> Option<&P>
pub fn link_properties(&self, link_id: LinkId) -> Option<&P>
Immutable access to per-link properties.
Sourcepub fn link_properties_mut(&mut self, link_id: LinkId) -> Option<&mut P>
pub fn link_properties_mut(&mut self, link_id: LinkId) -> Option<&mut P>
Mutable access to per-link properties.
Sourcepub fn link_endpoints(&self, link_id: LinkId) -> Option<(NodeId, NodeId)>
pub fn link_endpoints(&self, link_id: LinkId) -> Option<(NodeId, NodeId)>
Source and destination nodes of a link as (from, to).
Sourcepub fn outgoing_links(&self, node: NodeId) -> &[LinkId] ⓘ
pub fn outgoing_links(&self, node: NodeId) -> &[LinkId] ⓘ
Outgoing link IDs from a node.
Sourcepub fn incoming_links(&self, node: NodeId) -> &[LinkId] ⓘ
pub fn incoming_links(&self, node: NodeId) -> &[LinkId] ⓘ
Incoming link IDs to a node.
Sourcepub fn agents_on_link(&self, link_id: LinkId) -> usize
pub fn agents_on_link(&self, link_id: LinkId) -> usize
Number of agents currently on a link.
Sourcepub fn agent_ids_on_link(&self, link_id: LinkId) -> &[AgentId] ⓘ
pub fn agent_ids_on_link(&self, link_id: LinkId) -> &[AgentId] ⓘ
Agent IDs currently on a link, ordered by position (upstream first).
Sourcepub fn link_length(&self, link_id: LinkId) -> Option<f64>
pub fn link_length(&self, link_id: LinkId) -> Option<f64>
Link length in meters.
Sourcepub fn set_link_exit_blocked(&mut self, link_id: LinkId, blocked: bool)
pub fn set_link_exit_blocked(&mut self, link_id: LinkId, blocked: bool)
Set whether a link’s exit is blocked by downstream logic.
Sourcepub fn link_exit_blocked(&self, link_id: LinkId) -> bool
pub fn link_exit_blocked(&self, link_id: LinkId) -> bool
Whether a link’s exit is currently blocked.
Sourcepub fn agent_position(&self, id: AgentId) -> Option<(LinkId, f64)>
pub fn agent_position(&self, id: AgentId) -> Option<(LinkId, f64)>
Get an agent’s current link and position.
Sourcepub fn add_agent_to_link(
&mut self,
id: AgentId,
link_id: LinkId,
position: f64,
) -> Result<(), LinkSpaceError>
pub fn add_agent_to_link( &mut self, id: AgentId, link_id: LinkId, position: f64, ) -> Result<(), LinkSpaceError>
Place an agent on a link at a specific position.
Sourcepub fn remove_agent(&mut self, id: AgentId) -> Result<(), LinkSpaceError>
pub fn remove_agent(&mut self, id: AgentId) -> Result<(), LinkSpaceError>
Remove an agent from the network.
Sourcepub fn advance_agent(
&mut self,
id: AgentId,
distance: f64,
) -> Result<f64, LinkSpaceError>
pub fn advance_agent( &mut self, id: AgentId, distance: f64, ) -> Result<f64, LinkSpaceError>
Advance an agent’s position on its current link by distance meters.
Sourcepub fn agent_at_link_end(&self, id: AgentId) -> bool
pub fn agent_at_link_end(&self, id: AgentId) -> bool
Check if an agent has reached the downstream end of its link.
Sourcepub fn transfer_agent(
&mut self,
id: AgentId,
to_link: LinkId,
) -> Result<(), LinkSpaceError>
pub fn transfer_agent( &mut self, id: AgentId, to_link: LinkId, ) -> Result<(), LinkSpaceError>
Transfer an agent from the end of its current link to the start of a new link.
Sourcepub fn total_agents(&self) -> usize
pub fn total_agents(&self) -> usize
Total number of agents in the network.
Sourcepub fn all_agent_ids(&self) -> Vec<AgentId> ⓘ
pub fn all_agent_ids(&self) -> Vec<AgentId> ⓘ
All agent IDs in the network.