Trait fera_graph::builder::WithBuilder
source · pub trait WithBuilder: WithEdge {
type Builder: Builder<Graph = Self>;
fn builder(num_vertices: usize, num_edges: usize) -> Self::Builder { ... }
fn new_with_edges<I>(n: usize, edges: I) -> Self
where
I: IntoIterator<Item = (usize, usize)>,
{ ... }
fn new_empty(n: usize) -> Self { ... }
fn new_complete(n: usize) -> Self
where
Self: WithEdge<Kind = Undirected>,
{ ... }
fn new_complete_binary_tree(h: u32) -> Self
where
Self: WithEdge<Kind = Undirected>,
{ ... }
fn new_regular<R: Rng>(d: usize, n: usize, rng: R) -> Option<Self>
where
Self: WithEdge<Kind = Undirected>,
{ ... }
fn new_random_tree<R: Rng>(n: usize, rng: R) -> Self { ... }
fn new_random_tree_with_diameter<R: Rng>(
n: u32,
d: u32,
rng: R
) -> Option<Self> { ... }
fn new_gn<R>(n: usize, rng: R) -> Self
where
Self::Kind: UniformEdgeKind,
R: Rng,
{ ... }
fn new_gn_connected<R: Rng>(n: usize, rng: R) -> Self
where
Self::Kind: UniformEdgeKind,
{ ... }
fn new_gnm<R>(n: usize, m: usize, rng: R) -> Option<Self>
where
Self::Kind: UniformEdgeKind,
R: Rng,
{ ... }
fn new_gnm_connected<R: Rng>(n: usize, m: usize, rng: R) -> Option<Self>
where
Self::Kind: UniformEdgeKind,
{ ... }
}
Expand description
A graph that has a Builder
.
See the module documentation for examples.
Required Associated Types
Provided Methods
sourcefn builder(num_vertices: usize, num_edges: usize) -> Self::Builder
fn builder(num_vertices: usize, num_edges: usize) -> Self::Builder
Creates a new builder for a graph of this type with n
vertices and initial capacity for
m
edges.
sourcefn new_with_edges<I>(n: usize, edges: I) -> Selfwhere
I: IntoIterator<Item = (usize, usize)>,
fn new_with_edges<I>(n: usize, edges: I) -> Selfwhere
I: IntoIterator<Item = (usize, usize)>,
sourcefn new_complete(n: usize) -> Selfwhere
Self: WithEdge<Kind = Undirected>,
fn new_complete(n: usize) -> Selfwhere
Self: WithEdge<Kind = Undirected>,
Creates a complete graph with n
vertices.
A complete graph has an edge between each pair of vertices.
sourcefn new_complete_binary_tree(h: u32) -> Selfwhere
Self: WithEdge<Kind = Undirected>,
fn new_complete_binary_tree(h: u32) -> Selfwhere
Self: WithEdge<Kind = Undirected>,
Creates a graph that is a complete binary tree with height h
.
In complete binary tree all interior vertices have two children an all leaves have the same depth.
sourcefn new_regular<R: Rng>(d: usize, n: usize, rng: R) -> Option<Self>where
Self: WithEdge<Kind = Undirected>,
fn new_regular<R: Rng>(d: usize, n: usize, rng: R) -> Option<Self>where
Self: WithEdge<Kind = Undirected>,
Creates a new d
-regular graph.
Return None
if d >= n
of if d * n
is not even.
sourcefn new_random_tree<R: Rng>(n: usize, rng: R) -> Self
fn new_random_tree<R: Rng>(n: usize, rng: R) -> Self
Creates a graph with n
vertices that is a tree, that is, is connected and acyclic.
The graph has n - 1
edges if n > 0
or zero edges if n = 0
.
sourcefn new_random_tree_with_diameter<R: Rng>(n: u32, d: u32, rng: R) -> Option<Self>
fn new_random_tree_with_diameter<R: Rng>(n: u32, d: u32, rng: R) -> Option<Self>
Similar to [new_random_tree
] but creates a tree with diameter d
. Returns None
if the diameter is invalid.
sourcefn new_gn<R>(n: usize, rng: R) -> Selfwhere
Self::Kind: UniformEdgeKind,
R: Rng,
fn new_gn<R>(n: usize, rng: R) -> Selfwhere
Self::Kind: UniformEdgeKind,
R: Rng,
Creates a random graph with n
vertices.
sourcefn new_gn_connected<R: Rng>(n: usize, rng: R) -> Selfwhere
Self::Kind: UniformEdgeKind,
fn new_gn_connected<R: Rng>(n: usize, rng: R) -> Selfwhere
Self::Kind: UniformEdgeKind,
Creates a random connected graph with n
vertices.
sourcefn new_gnm<R>(n: usize, m: usize, rng: R) -> Option<Self>where
Self::Kind: UniformEdgeKind,
R: Rng,
fn new_gnm<R>(n: usize, m: usize, rng: R) -> Option<Self>where
Self::Kind: UniformEdgeKind,
R: Rng,
Creates a random graph with n
vertices and m
edges.
Returns None
with m
exceeds the maximum number of edges.
sourcefn new_gnm_connected<R: Rng>(n: usize, m: usize, rng: R) -> Option<Self>where
Self::Kind: UniformEdgeKind,
fn new_gnm_connected<R: Rng>(n: usize, m: usize, rng: R) -> Option<Self>where
Self::Kind: UniformEdgeKind,
Creates a random connected graph (weakly connected if Self
is a digraph) with n
vertices and m
edges.
Returns None
if m
exceeds the maximum number of edges or if m
is less than n - 1
.