[][src]Struct net_ensembles::er_c::ErEnsembleC

pub struct ErEnsembleC<T, R> where
    T: Node,
    R: Rng
{ /* fields omitted */ }

Implements Erdős-Rényi graph ensemble

  • variable number of edges
  • targets a connectivity

Sampling

Other

Implementations

impl<T, R> ErEnsembleC<T, R> where
    T: Node + SerdeStateConform,
    R: Rng
[src]

pub fn new(n: usize, c_target: f64, rng: R) -> Self[src]

Initialize

create new ErEnsembleC with:

  • n vertices
  • target connectivity c_target
  • rng is consumed and used as random number generator in the following
  • internally uses Graph<T>::new(n)
  • generates random edges according to ER model

pub fn make_connected(&mut self)[src]

Experimental! Connect the connected components

  • adds edges, to connect the connected components
  • panics if no vertices are in the graph
  • intended as starting point for a markov chain, if you require connected graphs
  • do not use this to independently (simple-) sample connected networks, as this will skew the statistics
  • This is still experimental, this member might change the internal functionallity resulting in different connected networks, without prior notice
  • This member might be removed in braking releases

pub fn target_connectivity(&self) -> f64[src]

returns target connectivity

Explanation

The target connectivity c_target is used to calculate the probability p, that any two vertices i and j (where i != j) are connected.

p = c_target / (N - 1) where N is the number of vertices in the graph

pub fn set_target_connectivity(&mut self, c_target: f64)[src]

  • set new value for target connectivity

Note

  • will only set the value (and probability), which will be used from now on
  • if you also want to create a new sample, call randomize afterwards

pub fn sort_adj(&mut self)[src]

Sort adjecency lists

If you depend on the order of the adjecency lists, you can sort them

Performance

  • internally uses pattern-defeating quicksort as long as that is the standard
  • sorts an adjecency list with length d in worst-case: O(d log(d))
  • is called for each adjecency list, i.e., self.vertex_count() times

Trait Implementations

impl<T, R> AsRef<GenericGraph<T, NodeContainer<T>>> for ErEnsembleC<T, R> where
    T: Node,
    R: Rng
[src]

impl<T, R> Borrow<GenericGraph<T, NodeContainer<T>>> for ErEnsembleC<T, R> where
    T: Node,
    R: Rng
[src]

impl<T: Clone, R: Clone> Clone for ErEnsembleC<T, R> where
    T: Node,
    R: Rng
[src]

impl<T: Debug, R: Debug> Debug for ErEnsembleC<T, R> where
    T: Node,
    R: Rng
[src]

impl<'de, T, R> Deserialize<'de> for ErEnsembleC<T, R> where
    T: Node,
    R: Rng,
    T: Deserialize<'de>,
    R: Deserialize<'de>, 
[src]

impl<T, R> GraphIteratorsMut<T, GenericGraph<T, NodeContainer<T>>, NodeContainer<T>> for ErEnsembleC<T, R> where
    T: Node + SerdeStateConform,
    R: Rng
[src]

impl<T, R> HasRng<R> for ErEnsembleC<T, R> where
    T: Node,
    R: Rng
[src]

fn rng(&mut self) -> &mut R[src]

Access RNG

If, for some reason, you want access to the internal random number generator: Here you go

fn swap_rng(&mut self, rng: R) -> R[src]

Swap random number generator

  • returns old internal rng

impl<T, R> MarkovChain<ErStepC, ErStepC> for ErEnsembleC<T, R> where
    T: Node + SerdeStateConform,
    R: Rng
[src]

fn m_step(&mut self) -> ErStepC[src]

Markov step

  • use this to perform a markov step, e.g., to create a markov chain
  • result ErStepC can be used to undo the step with self.undo_step(result)

fn undo_step(&mut self, step: ErStepC) -> ErStepC[src]

Undo a markcov step

  • adds removed edge, or removes added edge, or does nothing
  • if it returns an Err value, you probably used the function wrong

Important:

Restored graph is the same as before the random step except the order of nodes in the adjacency list might be shuffled!

fn undo_step_quiet(&mut self, step: ErStepC)[src]

Undo a markov step

  • adds removed edge, or removes added edge, or does nothing
  • if it returns an Err value, you probably used the function wrong

Important:

Restored graph is the same as before the random step except the order of nodes in the adjacency list might be shuffled!

impl<T, R> Serialize for ErEnsembleC<T, R> where
    T: Node,
    R: Rng,
    T: Serialize,
    R: Serialize
[src]

impl<T, R> SimpleSample for ErEnsembleC<T, R> where
    T: Node + SerdeStateConform,
    R: Rng
[src]

fn randomize(&mut self)[src]

Randomizes the edges according to Er probabilities

  • this is used by ErEnsembleC::new to create the initial topology
  • you can use this for sampling the ensemble
  • runs in O(vertices * vertices)

impl<T, R> WithGraph<T, GenericGraph<T, NodeContainer<T>>> for ErEnsembleC<T, R> where
    T: Node + SerdeStateConform,
    R: Rng
[src]

Auto Trait Implementations

impl<T, R> RefUnwindSafe for ErEnsembleC<T, R> where
    R: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, R> Send for ErEnsembleC<T, R> where
    R: Send,
    T: Send

impl<T, R> Sync for ErEnsembleC<T, R> where
    R: Sync,
    T: Sync

impl<T, R> Unpin for ErEnsembleC<T, R> where
    R: Unpin,
    T: Unpin

impl<T, R> UnwindSafe for ErEnsembleC<T, R> where
    R: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<S, Res, A> Metropolis<S, Res> for A where
    A: MarkovChain<S, Res>, 
[src]

impl<T> SerdeStateConform for T where
    T: Serialize
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,