Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graphs.RandomRegular(3,10) often returns a graph on 0 vertices #5932

Closed
williamstein opened this issue Apr 29, 2009 · 6 comments
Closed

graphs.RandomRegular(3,10) often returns a graph on 0 vertices #5932

williamstein opened this issue Apr 29, 2009 · 6 comments

Comments

@williamstein
Copy link
Contributor

The docstring for graphs.RandomRegular says

Returns a random d-regular graph on n vertices, or returns False on
failure.

However, try calling it a few times with input 3,10 and with probability about 25% you'll get back an empty graph!:

sage: graphs.RandomRegular(3,10)
Graph on 0 vertices

sage: [len(graphs.RandomRegular(3,10)) for _ in range(1000)].count(0)
232

Component: graph theory

Author: Robert Miller

Reviewer: Jason Grout

Merged: sage-4.1.1.alpha0

Issue created by migration from https://trac.sagemath.org/ticket/5932

@rlmill
Copy link
Mannequin

rlmill mannequin commented Apr 29, 2009

comment:1

This is a bug in NetworkX. Their docstring says:

Definition:     networkx.random_regular_graph(d, n, seed=None)
Source:
def random_regular_graph(d, n, seed=None):
    """Return a random regular graph of n nodes each with degree d, G_{n,d}.
    Return False if unsuccessful.

@rlmill rlmill mannequin added the s: needs review label Jul 16, 2009
@rlmill
Copy link
Mannequin

rlmill mannequin commented Jul 16, 2009

Attachment: trac_5932.patch.gz

@jasongrout
Copy link
Member

comment:3

The fix looks correct, the file passes doctests, and everything looks great!

@jasongrout
Copy link
Member

Reviewer: Jason Grout

@jasongrout
Copy link
Member

Author: Robert Miller

@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Jul 19, 2009

Merged: sage-4.1.1.alpha0

@sagetrac-mvngu sagetrac-mvngu mannequin closed this as completed Jul 19, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants