@@ -19,10 +19,10 @@ def random_graph(
19
19
directed (if True: graph will be a directed graph,
20
20
otherwise it will be an undirected graph)
21
21
@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: []}
26
26
"""
27
27
graph = {i : [] for i in range (vertices_number )}
28
28
@@ -33,6 +33,7 @@ def random_graph(
33
33
if probability <= 0 :
34
34
return graph
35
35
36
+ random .seed (1 )
36
37
# for each couple of nodes, add an edge from u to v
37
38
# if the number randomly generated is greater than probability probability
38
39
for i in range (vertices_number ):
@@ -47,7 +48,7 @@ def random_graph(
47
48
48
49
def complete_graph (vertices_number : int ) -> dict :
49
50
"""
50
- function that generates a complete graph with vertices_number vertices
51
+ Function that generates a complete graph with vertices_number vertices.
51
52
@input: vertices_number (number of vertices),
52
53
directed (False if the graph is undirected, True otherwise)
53
54
@example:
0 commit comments