1
0
Fork 0

Fix random graph generation

The previous implementation was biased towards higher vertex indices.
This commit is contained in:
Joris van Rantwijk 2024-12-07 01:50:27 +01:00
parent 8ed1d42710
commit 36be21800b
8 changed files with 33370 additions and 33275 deletions

View File

@ -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

View File

@ -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: