pub struct NetworkReliability {
pub source: usize,
pub terminal: usize,
}Expand description
Two-terminal network reliability estimator.
Estimates P(source s can reach terminal t) under independent edge
failures via Monte Carlo sampling.
Each simulation trial:
- For each edge
(u, v, p), keep the edge with probabilityp. - Run BFS to check whether
scan reacht.
The estimate converges at rate O(1/√N) where N is the number of trials.
Fields§
§source: usizeSource node index.
terminal: usizeTerminal (target) node index.
Implementations§
Source§impl NetworkReliability
impl NetworkReliability
Sourcepub fn new(source: usize, terminal: usize) -> Self
pub fn new(source: usize, terminal: usize) -> Self
Create a two-terminal reliability estimator.
Sourcepub fn monte_carlo(
&self,
adj: &Array2<f64>,
num_trials: usize,
seed: Option<u64>,
) -> Result<f64>
pub fn monte_carlo( &self, adj: &Array2<f64>, num_trials: usize, seed: Option<u64>, ) -> Result<f64>
Trait Implementations§
Source§impl Clone for NetworkReliability
impl Clone for NetworkReliability
Source§fn clone(&self) -> NetworkReliability
fn clone(&self) -> NetworkReliability
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for NetworkReliability
impl RefUnwindSafe for NetworkReliability
impl Send for NetworkReliability
impl Sync for NetworkReliability
impl Unpin for NetworkReliability
impl UnsafeUnpin for NetworkReliability
impl UnwindSafe for NetworkReliability
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