Trait fera_graph::choose::Choose
source · pub trait Choose: WithEdge {
fn choose_vertex<R: Rng>(&self, rng: R) -> Option<Vertex<Self>>;
fn choose_out_neighbor<R: Rng>(
&self,
v: Vertex<Self>,
rng: R
) -> Option<Vertex<Self>>;
fn choose_edge<R: Rng>(&self, rng: R) -> Option<Edge<Self>>;
fn choose_out_edge<R: Rng>(
&self,
v: Vertex<Self>,
rng: R
) -> Option<Edge<Self>>;
fn choose_vertex_iter<R: Rng>(&self, rng: R) -> ChooseVertexIter<'_, Self, R> ⓘ { ... }
fn choose_out_neighbor_iter<R: Rng>(
&self,
v: Vertex<Self>,
rng: R
) -> ChooseOutNeighborIter<'_, Self, R> ⓘ { ... }
fn choose_edge_iter<R: Rng>(&self, rng: R) -> ChooseEdgeIter<'_, Self, R> ⓘ { ... }
fn choose_out_edge_iter<R: Rng>(
&self,
v: Vertex<Self>,
rng: R
) -> ChooseOutEdgeIter<'_, Self, R> ⓘ { ... }
fn random_walk<R: Rng>(&self, rng: R) -> RandomWalk<'_, Self, R> ⓘ { ... }
}
Expand description
A graph from which vertices and edges can be randomly selected.
See the module documentation for examples.
Required Methods
sourcefn choose_vertex<R: Rng>(&self, rng: R) -> Option<Vertex<Self>>
fn choose_vertex<R: Rng>(&self, rng: R) -> Option<Vertex<Self>>
Returns a random vertex of this graph or None
if the graph has no vertices.
sourcefn choose_out_neighbor<R: Rng>(
&self,
v: Vertex<Self>,
rng: R
) -> Option<Vertex<Self>>
fn choose_out_neighbor<R: Rng>(
&self,
v: Vertex<Self>,
rng: R
) -> Option<Vertex<Self>>
Returns a random neighbor vertex of v
or None
if v
has no neighbors.
sourcefn choose_edge<R: Rng>(&self, rng: R) -> Option<Edge<Self>>
fn choose_edge<R: Rng>(&self, rng: R) -> Option<Edge<Self>>
Returns a random edge of this graph or None
if the graph has no edges.
Provided Methods
sourcefn choose_vertex_iter<R: Rng>(&self, rng: R) -> ChooseVertexIter<'_, Self, R> ⓘ
fn choose_vertex_iter<R: Rng>(&self, rng: R) -> ChooseVertexIter<'_, Self, R> ⓘ
Returns an iterator that repeatedly calls choose_vertex
.
sourcefn choose_out_neighbor_iter<R: Rng>(
&self,
v: Vertex<Self>,
rng: R
) -> ChooseOutNeighborIter<'_, Self, R> ⓘ
fn choose_out_neighbor_iter<R: Rng>(
&self,
v: Vertex<Self>,
rng: R
) -> ChooseOutNeighborIter<'_, Self, R> ⓘ
Returns an iterator that repeatedly calls choose_out_neighbor(v)
.
sourcefn choose_edge_iter<R: Rng>(&self, rng: R) -> ChooseEdgeIter<'_, Self, R> ⓘ
fn choose_edge_iter<R: Rng>(&self, rng: R) -> ChooseEdgeIter<'_, Self, R> ⓘ
Returns an iterator that repeatedly calls choose_edge
.
sourcefn choose_out_edge_iter<R: Rng>(
&self,
v: Vertex<Self>,
rng: R
) -> ChooseOutEdgeIter<'_, Self, R> ⓘ
fn choose_out_edge_iter<R: Rng>(
&self,
v: Vertex<Self>,
rng: R
) -> ChooseOutEdgeIter<'_, Self, R> ⓘ
Returns an iterator that repeatedly calls choose_out_edge(v)
.
sourcefn random_walk<R: Rng>(&self, rng: R) -> RandomWalk<'_, Self, R> ⓘ
fn random_walk<R: Rng>(&self, rng: R) -> RandomWalk<'_, Self, R> ⓘ
Returns a iterator that produces a sequence of random edges that forms a walk, that is, the target vertex of the previous edge is the source vertex of the next edge.