Fix random graph generation
The previous implementation was biased towards higher vertex indices.
This commit is contained in:
parent
8ed1d42710
commit
36be21800b
|
@ -46,8 +46,12 @@ def make_random_graph(
|
|||
if 3 * m < n * (n - 2) // 2:
|
||||
# Simply add random edges until we have enough.
|
||||
while len(edge_set) < m:
|
||||
x = rng.randint(0, n - 2)
|
||||
y = rng.randint(x + 1, n - 1)
|
||||
x = rng.randint(0, n - 1)
|
||||
y = rng.randint(0, n - 2)
|
||||
if y < x:
|
||||
(x, y) = (y, x)
|
||||
else:
|
||||
y += 1
|
||||
edge_set.add((x, y))
|
||||
|
||||
else:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -195,8 +195,12 @@ def make_random_graph(
|
|||
if 3 * m < n * (n - 2) // 2:
|
||||
# Simply add random edges until we have enough.
|
||||
while len(edge_set) < m:
|
||||
x = rng.randint(0, n - 2)
|
||||
y = rng.randint(x + 1, n - 1)
|
||||
x = rng.randint(0, n - 1)
|
||||
y = rng.randint(0, n - 2)
|
||||
if y < x:
|
||||
(x, y) = (y, x)
|
||||
else:
|
||||
y += 1
|
||||
edge_set.add((x, y))
|
||||
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue