pub struct GraphonSampler {
pub n: usize,
pub graphon: Box<dyn Fn(f64, f64) -> f64>,
}Expand description
Samples a simple graph from a graphon W : [0,1]² → [0,1].
A graphon is represented as a symmetric function. We discretize by n sample points.
Fields§
§n: usizeNumber of vertices to sample.
graphon: Box<dyn Fn(f64, f64) -> f64>The graphon function W(x, y) ∈ [0, 1]; must satisfy W(x,y) = W(y,x).
Implementations§
Source§impl GraphonSampler
impl GraphonSampler
Sourcepub fn new(n: usize, graphon: Box<dyn Fn(f64, f64) -> f64>) -> Self
pub fn new(n: usize, graphon: Box<dyn Fn(f64, f64) -> f64>) -> Self
Create a new sampler for a given graphon function and vertex count.
Sourcepub fn sample_deterministic(&self) -> UndirectedGraph
pub fn sample_deterministic(&self) -> UndirectedGraph
Sample a graph: vertex i gets label (i+0.5)/n, edge (i,j) included with prob W(xi, xj). Uses a deterministic threshold for reproducibility (threshold = 0.5).
Sourcepub fn sample_at_threshold(&self, p: f64) -> UndirectedGraph
pub fn sample_at_threshold(&self, p: f64) -> UndirectedGraph
Sample by thresholding at a given value p ∈ [0, 1].
Auto Trait Implementations§
impl Freeze for GraphonSampler
impl !RefUnwindSafe for GraphonSampler
impl !Send for GraphonSampler
impl !Sync for GraphonSampler
impl Unpin for GraphonSampler
impl UnsafeUnpin for GraphonSampler
impl !UnwindSafe for GraphonSampler
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