pub struct IndependentCascade {
pub adjacency: AdjList,
pub num_nodes: usize,
}Expand description
Independent Cascade (IC) diffusion model configuration.
Each active node u attempts to activate every inactive neighbour v with
probability p(u, v) stored as the edge weight. Each edge is tried at
most once.
Fields§
§adjacency: AdjListAdjacency list: node → [(neighbour, propagation_probability)].
num_nodes: usizeTotal number of nodes in the graph.
Implementations§
Source§impl IndependentCascade
impl IndependentCascade
Sourcepub fn new(adjacency: AdjList, num_nodes: usize) -> Self
pub fn new(adjacency: AdjList, num_nodes: usize) -> Self
Create a new IC model.
§Arguments
adjacency— directed adjacency list with propagation probabilities as weights.num_nodes— number of nodes (needed for result reporting).
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 an IC model from a vec of (source, target, probability) triples.
Sourcepub fn simulate(&self, seeds: &[usize]) -> Result<SimulationResult>
pub fn simulate(&self, seeds: &[usize]) -> Result<SimulationResult>
Run a single IC simulation from the given seed set.
Trait Implementations§
Source§impl Clone for IndependentCascade
impl Clone for IndependentCascade
Source§fn clone(&self) -> IndependentCascade
fn clone(&self) -> IndependentCascade
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 IndependentCascade
impl RefUnwindSafe for IndependentCascade
impl Send for IndependentCascade
impl Sync for IndependentCascade
impl Unpin for IndependentCascade
impl UnsafeUnpin for IndependentCascade
impl UnwindSafe for IndependentCascade
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