rustworkx.directed_gnm_random_graph#
- directed_gnm_random_graph(num_nodes, num_edges, /, seed=None)#
Return a
directed graph, also known as an Erdős-Rényi graph.Generates a random directed graph out of all the possible graphs with
nodes and edges. The generated graph will not be a multigraph and will not have self loops.For
nodes, the maximum edges that can be returned is . Passing higher than that will still return the maximum number of edges. If , the returned graph will always be empty (no edges). When a seed is provided, the results are reproducible. Passing a seed when or has no effect, as the result will always be an empty or a complete graph respectively.This algorithm has a time complexity of
- Parameters:
num_nodes (int) – The number of nodes to create in the graph
num_edges (int) – The number of edges to create in the graph
seed (int) – An optional seed to use for the random number generator
- Returns:
A PyDiGraph object
- Return type: