graphs.random_graph_generator

URL: https://en.wikipedia.org/wiki/Random_graph

Functions

complete_graph(→ dict)

Generate a complete graph with vertices_number vertices.

random_graph(→ dict)

Generate a random graph

Module Contents

graphs.random_graph_generator.complete_graph(vertices_number: int) dict

Generate a complete graph with vertices_number vertices. @input: vertices_number (number of vertices),

directed (False if the graph is undirected, True otherwise)

@example: >>> complete_graph(3) {0: [1, 2], 1: [0, 2], 2: [0, 1]}

graphs.random_graph_generator.random_graph(vertices_number: int, probability: float, directed: bool = False) dict

Generate a random graph @input: vertices_number (number of vertices),

probability (probability that a generic edge (u,v) exists), directed (if True: graph will be a directed graph,

otherwise it will be an undirected graph)

@examples: >>> random.seed(1) >>> random_graph(4, 0.5) {0: [1], 1: [0, 2, 3], 2: [1, 3], 3: [1, 2]} >>> random.seed(1) >>> random_graph(4, 0.5, True) {0: [1], 1: [2, 3], 2: [3], 3: []}