Skip to content

Commit 6ee751b

Browse files
committed
fixed doctest and solved consistency issues
1 parent 6204ab0 commit 6ee751b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

graphs/random_graph_generator.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ def random_graph(
1919
directed (if True: graph will be a directed graph,
2020
otherwise it will be an undirected graph)
2121
@examples:
22-
>>> random_graph(4, 1)
23-
{0: [1, 2, 3], 1: [0, 2, 3], 2: [0, 1, 3], 3: [0, 1, 2]}
24-
>>> random_graph(4, 1, True)
25-
{0: [1, 2, 3], 1: [0, 2, 3], 2: [0, 1, 3], 3: [0, 1, 2]}
22+
>>> random_graph(4, 0.5)
23+
{0: [1], 1: [0, 2, 3], 2: [1, 3], 3: [1, 2]}
24+
>>> random_graph(4, 0.5, True)
25+
{0: [1], 1: [2, 3], 2: [3], 3: []}
2626
"""
2727
graph = {i: [] for i in range(vertices_number)}
2828

@@ -33,6 +33,7 @@ def random_graph(
3333
if probability <= 0:
3434
return graph
3535

36+
random.seed(1)
3637
# for each couple of nodes, add an edge from u to v
3738
# if the number randomly generated is greater than probability probability
3839
for i in range(vertices_number):
@@ -47,7 +48,7 @@ def random_graph(
4748

4849
def complete_graph(vertices_number: int) -> dict:
4950
"""
50-
function that generates a complete graph with vertices_number vertices
51+
Function that generates a complete graph with vertices_number vertices.
5152
@input: vertices_number (number of vertices),
5253
directed (False if the graph is undirected, True otherwise)
5354
@example:

0 commit comments

Comments
 (0)