pub struct LinearThreshold {
pub adjacency: AdjList,
pub num_nodes: usize,
pub thresholds: Option<Vec<f64>>,
}Expand description
Linear Threshold (LT) diffusion model configuration.
Each node v has a threshold θ_v ∈ [0, 1] drawn at the start of each
simulation. Node v becomes active when
Σ_{u active} w(u, v) ≥ θ_v, where w(u, v) is the normalised in-edge
weight.
Fields§
§adjacency: AdjListDirected adjacency list: node → [(neighbour, weight)].
Weights represent influence of node on neighbour. They should be
normalised so that Σ_{u} w(u, v) ≤ 1 for every v.
num_nodes: usizeTotal number of nodes.
thresholds: Option<Vec<f64>>Optional fixed thresholds per node (if None, drawn uniformly per run).
Implementations§
Source§impl LinearThreshold
impl LinearThreshold
Sourcepub fn new(adjacency: AdjList, num_nodes: usize) -> Self
pub fn new(adjacency: AdjList, num_nodes: usize) -> Self
Create a new LT model with random per-run thresholds.
Sourcepub fn with_thresholds(adjacency: AdjList, thresholds: Vec<f64>) -> Result<Self>
pub fn with_thresholds(adjacency: AdjList, thresholds: Vec<f64>) -> Result<Self>
Create an LT model with fixed thresholds.
Sourcepub fn from_edges(edges: &[(usize, usize, f64)], num_nodes: usize) -> Self
pub fn from_edges(edges: &[(usize, usize, f64)], num_nodes: usize) -> Self
Build from (source, target, weight) triples.
Sourcepub fn simulate(&self, seeds: &[usize]) -> Result<SimulationResult>
pub fn simulate(&self, seeds: &[usize]) -> Result<SimulationResult>
Run a single LT simulation.
Trait Implementations§
Source§impl Clone for LinearThreshold
impl Clone for LinearThreshold
Source§fn clone(&self) -> LinearThreshold
fn clone(&self) -> LinearThreshold
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 LinearThreshold
impl RefUnwindSafe for LinearThreshold
impl Send for LinearThreshold
impl Sync for LinearThreshold
impl Unpin for LinearThreshold
impl UnsafeUnpin for LinearThreshold
impl UnwindSafe for LinearThreshold
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