Common graphs and digraphs generators (Cython)¶
AUTHORS:
 David Coudert (2012)

sage.graphs.graph_generators_pyx.
RandomGNP
(n, p, directed=False, loops=False)¶ Return a random graph or a digraph on \(n\) nodes.
Each edge is inserted independently with probability \(p\).
INPUT:
n
– number of nodes of the digraphp
– probability of an edgedirected
– boolean (default:False
); whether the random graph is directed or undirected (default)loops
– boolean (default:False
); whether the random digraph may have loops or not. This value is used only whendirected == True
.
REFERENCES:
EXAMPLES:
sage: from sage.graphs.graph_generators_pyx import RandomGNP sage: set_random_seed(0) sage: D = RandomGNP(10, .2, directed=True) sage: D.num_verts() 10 sage: D.edges(labels=False) [(0, 2), (0, 5), (1, 5), (1, 7), (4, 1), (4, 2), (4, 9), (5, 0), (5, 2), (5, 3), (5, 7), (6, 5), (7, 1), (8, 2), (8, 6), (9, 4)]