pub struct SIRModel {
pub adjacency: AdjList,
pub beta: f64,
pub gamma: f64,
pub num_nodes: usize,
}Expand description
SIR epidemic model (Susceptible–Infected–Recovered).
At each discrete time step:
- Every
Infectednode infects eachSusceptibleneighbour with probabilitybeta. - Every
Infectednode transitions toRecoveredwith probabilitygamma.
Fields§
§adjacency: AdjListAdjacency list (undirected: each edge stored in both directions).
beta: f64Infection probability per edge per step.
gamma: f64Recovery probability per step.
num_nodes: usizeTotal number of nodes.
Implementations§
Source§impl SIRModel
impl SIRModel
Sourcepub fn from_edges(
edges: &[(usize, usize)],
num_nodes: usize,
beta: f64,
gamma: f64,
) -> Result<Self>
pub fn from_edges( edges: &[(usize, usize)], num_nodes: usize, beta: f64, gamma: f64, ) -> Result<Self>
Build from (source, target) edge list (unweighted).
Sourcepub fn simulate(&self, initial_infected: &[usize]) -> Result<SimulationResult>
pub fn simulate(&self, initial_infected: &[usize]) -> Result<SimulationResult>
Run a single SIR simulation from initial infected set.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SIRModel
impl RefUnwindSafe for SIRModel
impl Send for SIRModel
impl Sync for SIRModel
impl Unpin for SIRModel
impl UnsafeUnpin for SIRModel
impl UnwindSafe for SIRModel
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more