@@ -13,14 +13,16 @@ def random_graph(
13
13
vertices_number : int , probability : float , directed : bool = False
14
14
) -> dict :
15
15
"""
16
- Function that generates a random graph
16
+ Generate a random graph
17
17
@input: vertices_number (number of vertices),
18
18
probability (probability that a generic edge (u,v) exists),
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.seed(1)
22
23
>>> random_graph(4, 0.5)
23
24
{0: [1], 1: [0, 2, 3], 2: [1, 3], 3: [1, 2]}
25
+ >>> random.seed(1)
24
26
>>> random_graph(4, 0.5, True)
25
27
{0: [1], 1: [2, 3], 2: [3], 3: []}
26
28
"""
@@ -33,7 +35,6 @@ def random_graph(
33
35
if probability <= 0 :
34
36
return graph
35
37
36
- random .seed (1 )
37
38
# for each couple of nodes, add an edge from u to v
38
39
# if the number randomly generated is greater than probability probability
39
40
for i in range (vertices_number ):
@@ -48,7 +49,7 @@ def random_graph(
48
49
49
50
def complete_graph (vertices_number : int ) -> dict :
50
51
"""
51
- Function that generates a complete graph with vertices_number vertices.
52
+ Generate a complete graph with vertices_number vertices.
52
53
@input: vertices_number (number of vertices),
53
54
directed (False if the graph is undirected, True otherwise)
54
55
@example:
0 commit comments