pub fn random_ungraph(
    nodes: usize,
    nedges: usize
) -> Result<HashSet<(usize, usize)>, EdgeNumberError>
Expand description

Random undirected graph.

Create and return a random undirected graph with a given number of nodes and edges. Each undirected edge {i, j} is represented by a pair of directed edges (i, j) and (j, i).

Arguments

  • nodes: number of nodes.
  • nedges: number of edges.

Returns

  • Err: if the required number of vertices is greater than the maximum possible.
  • Ok: set HashSet<(usize, usize)> of edges with usize vertex indices.

Examples

use graphalgs::generate::random_ungraph;
use petgraph::{ Graph, Directed };

let graph: Graph::<(), (), Directed, usize> = Graph::from_edges(
    random_ungraph(4, 5).unwrap()
);