Common graphs and digraphs generators (Cython)¶
AUTHORS:
- David Coudert (2012) 
- sage.graphs.graph_generators_pyx.RandomGNP(n, p, directed=False, loops=False, seed=None, immutable=False)[source]¶
- 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 digraph
- p– probability of an edge
- directed– 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 when- directed == True
- seed– a- random.Randomseed or a Python- intfor the random number generator (default:- None)
- immutable– boolean (default:- False); whether to return an immutable or mutable (di)graph.
 - REFERENCES: - EXAMPLES: - sage: from sage.graphs.graph_generators_pyx import RandomGNP sage: D = RandomGNP(10, .2, directed=True, seed=0) sage: D.num_verts() 10 sage: D.edges(sort=True, labels=False) [(0, 3), (0, 6), (1, 7), (1, 9), (4, 6), (4, 7), (5, 4), (5, 6), (5, 8), (5, 9), (6, 3), (7, 2), (7, 9), (8, 5), (9, 1), (9, 5)] - >>> from sage.all import * >>> from sage.graphs.graph_generators_pyx import RandomGNP >>> D = RandomGNP(Integer(10), RealNumber('.2'), directed=True, seed=Integer(0)) >>> D.num_verts() 10 >>> D.edges(sort=True, labels=False) [(0, 3), (0, 6), (1, 7), (1, 9), (4, 6), (4, 7), (5, 4), (5, 6), (5, 8), (5, 9), (6, 3), (7, 2), (7, 9), (8, 5), (9, 1), (9, 5)]