#12362: Improvement of GNP generators for graphs and digraphs
-----------------------------------------------+----------------------------
Reporter: dcoudert | Owner: jason, ncohen,
rlm
Type: enhancement | Status: closed
Priority: minor | Milestone: sage-5.0
Component: graph theory | Resolution: fixed
Keywords: directed graphs, generators | Work issues:
Report Upstream: N/A | Reviewers: Nathann Cohen
Authors: David Coudert | Merged in: sage-5.0.beta9
Dependencies: | Stopgaps:
-----------------------------------------------+----------------------------
Comment (by ncohen):
Here's the code of RandomGNP in beta8
{{{
if seed is None:
seed = current_randstate().long_seed()
if p == 1:
return graphs.CompleteGraph(n)
import networkx
if fast:
G = networkx.fast_gnp_random_graph(n, p, seed=seed)
else:
G = networkx.gnp_random_graph(n, p, seed=seed)
return graph.Graph(G)
}}}
and in beta14
{{{
if n < 0:
raise ValueError("The number of nodes must be positive or
null.")
if 0.0 > p or 1.0 < p:
raise ValueError("The probability p must be in [0..1].")
if seed is None:
seed = current_randstate().long_seed()
if p == 1:
return graphs.CompleteGraph(n)
if method == 'networkx':
import networkx
if fast:
G = networkx.fast_gnp_random_graph(n, p, seed=seed)
else:
G = networkx.gnp_random_graph(n, p, seed=seed)
return graph.Graph(G)
elif method == "Sage":
# We use the Sage generator
from sage.graphs.graph_generators_pyx import RandomGNP as
sageGNP
return sageGNP(n, p)
else:
raise ValueError("'method' must be equal to 'networkx' or to
'Sage'.")
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12362#comment:42>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.