12
12
13
13
@pytest .fixture (name = "graphs" )
14
14
def fixture_graphs ():
15
- return dynnode2vec .utils .generate_dynamic_graphs (
15
+ return dynnode2vec .utils .create_dynamic_graph (
16
16
n_base_nodes = 30 , n_steps = 5 , base_density = 0.02
17
17
)
18
18
19
19
20
+ def add_random_weights (graph ):
21
+ for * _ , data in graph .edges (data = True ):
22
+ data ["weight" ] = random .random ()
23
+
24
+
20
25
def test_init (graphs ):
21
26
brw = dynnode2vec .biased_random_walk .BiasedRandomWalk (graphs [0 ])
22
27
@@ -46,12 +51,11 @@ def test_generate_walk(graphs, ip, iq, weighted):
46
51
# pylint: disable=invalid-name
47
52
# make sure that tested node has at least one neighbor
48
53
graph = graphs [0 ]
49
- graph .add_edge (0 , 1 , weight = 0.5 )
54
+ graph .add_edge ("0" , "1" )
50
55
51
56
# add random weights to the graph for the weighted case
52
57
if weighted :
53
- for _ , _ , data in graph .edges (data = True ):
54
- data ["weight" ] = random .random ()
58
+ add_random_weights (graph )
55
59
56
60
brw = dynnode2vec .biased_random_walk .BiasedRandomWalk (graph )
57
61
rng = random .Random (0 )
@@ -74,8 +78,7 @@ def test_run(graphs, p, q, weighted):
74
78
75
79
# add random weights to the graph for the weighted case
76
80
if weighted :
77
- for * _ , data in graph .edges (data = True ):
78
- data ["weight" ] = random .random ()
81
+ add_random_weights (graph )
79
82
80
83
brw = dynnode2vec .biased_random_walk .BiasedRandomWalk (graph )
81
84
0 commit comments