Struct net_ensembles::er_m::ErEnsembleM[][src]

pub struct ErEnsembleM<T: Node, R> { /* fields omitted */ }
Expand description

Implements Erdős-Rényi graph ensemble

Constant number of edges

  • Note simple sampling of this ensemble is somewhat inefficient right now - I might change it in the future, though that will change the results of the simple sampling (Not on average of cause)
  • for simple sampling look at SimpleSample trait
  • for markov steps look at MarkovChain trait

Other

Save and load example

  • only works if feature "serde_support" is enabled
  • Note: "serde_support" is enabled by default
  • I need the #[cfg(feature = "serde_support")] to ensure the example does compile if
  • you can do not have to use serde_json, look here for more info you opt out of the default feature
use net_ensembles::traits::*; // I recommend always using this
use serde_json;
use rand_pcg::Pcg64;
use net_ensembles::{ErEnsembleM, EmptyNode, rand::SeedableRng};
use std::fs::File;

let rng = Pcg64::seed_from_u64(95);
// create Erdős-Rényi ensemble with 200 vertices and 600 edges
let er_ensemble = ErEnsembleM::<EmptyNode, Pcg64>::new(200, 600, rng);

#[cfg(feature = "serde_support")]
{
    // storing the ensemble in a file:

    let er_m_file = File::create("store_ER_m.dat")
          .expect("Unable to create file");

    // or serde_json::to_writer(er_m_file, &er_ensemble);
    serde_json::to_writer_pretty(er_m_file, &er_ensemble);

    // loading ensemble from file:

    let mut read = File::open("store_ER_m.dat")
        .expect("Unable to open file");

    let er: ErEnsembleM::<EmptyNode, Pcg64> = serde_json::from_reader(read).unwrap();
}

Implementations

Initialize

create new ErEnsembleM graph with:

  • n vertices
  • m edges
  • 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

Return total number of edges

Trait Implementations

Performs the conversion.

Immutably borrows from an owned value. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Returns a reference to the element stored in the specified node or None if out of Bounds

Returns a mutable reference to the element stored in the specified node or None if out of Bounds

For a save alternative see get_contained Read more

Returns a mutable reference to the element stored in the specified node Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

  • use function f to create labels depending on the index
  • for valid dot_options use dot_options! macro and take a look at module dot_constants
  • Read more

  • create dot file with empty labels
  • default implementation uses dot_from_indices
  • Read more

  • same as self.dot(), but returns a String instead
  • same as self.dot_from_indices but returns String instead
  • same as self.dot_with_indices but returns String instead
  • use index as labels for the nodes
  • default implementation uses dot_from_indices
  • Read more

  • iterate over mutable additional information of neighbors of vertex index
  • iterator returns &mut T
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • iterate over mutable additional information of neighbors of vertex index
  • iterator returns (index_neighbor: usize, neighbor: &mut T)
  • sort_adj will affect the order
  • panics if index out of bounds
  • Read more

  • get iterator over mutable additional information stored at each vertex in order of the indices
  • iterator returns a Node (for example EmptyNode or whatever you used)
  • Read more

    Access RNG

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

    Swap random number generator
    • returns old internal rng
    • undo a markov step, return result-state
    • if you want to undo more than one step see undo_steps
    • undo a markov step, panic on invalid result state
    • for undoing multiple steps see undo_steps_quiet
    Markov step
    • use this to perform a markov step
    • for doing multiple mc steps at once, use m_steps

    Markov steps Read more

    Markov steps without return Read more

    Accumulating markov step Read more

    Accumulating markov steps Read more

    Accumulating markov steps Read more

    Undo markov steps Read more

    Undo markov steps Read more

    Serialize this value into the given Serde serializer. Read more

    Randomizes self according to model

    do the following times times: Read more

    do the following times times: Read more

    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

  • access additional information at index
  • mutable access to additional information at index
  • returns reference to the underlying topology aka, the GenericGraph
  • use this to call functions regarding the topology
  • Read more

    Auto Trait Implementations

    Blanket Implementations

    Gets the TypeId of self. Read more

    Immutably borrows from an owned value. Read more

    Mutably borrows from an owned value. Read more

    Cast from Self to T

    Try converting from Self to T

    Cast to integer, truncating Read more

    Cast to the nearest integer Read more

    Cast the floor to an integer Read more

    Cast the ceiling to an integer Read more

    Try converting to integer with truncation Read more

    Try converting to the nearest integer Read more

    Try converting the floor to an integer Read more

    Try convert the ceiling to an integer Read more

    Convert from T to Self

    Try converting from T to Self

    Performs the conversion.

    Performs the conversion.

    The alignment of pointer.

    The type for initializers.

    Initializes a with the given initializer. Read more

    Dereferences the given pointer. Read more

    Mutably dereferences the given pointer. Read more

    Drops the object pointed to by the given pointer. Read more

    The resulting type after obtaining ownership.

    Creates owned data from borrowed data, usually by cloning. Read more

    🔬 This is a nightly-only experimental API. (toowned_clone_into)

    Uses borrowed data to replace owned data, usually by cloning. Read more

    The type returned in the event of a conversion error.

    Performs the conversion.

    The type returned in the event of a conversion error.

    Performs the conversion.