@@ -10,97 +10,133 @@ def test_db(load_graph):
10
10
assert db .version ()
11
11
12
12
13
+ def test_load_graph_from_nxadb ():
14
+ graph_name = "KarateGraph"
15
+
16
+ db .delete_graph (graph_name , drop_collections = True , ignore_missing = True )
17
+
18
+ G_nx = nx .karate_club_graph ()
19
+
20
+ _ = nxadb .Graph (
21
+ graph_name = graph_name ,
22
+ incoming_graph_data = G_nx ,
23
+ default_node_type = "person" ,
24
+ )
25
+
26
+ assert db .has_graph (graph_name )
27
+ assert db .has_collection ("person" )
28
+ assert db .has_collection ("person_to_person" )
29
+ assert db .collection ("person" ).count () == len (G_nx .nodes )
30
+ assert db .collection ("person_to_person" ).count () == len (G_nx .edges )
31
+
32
+ db .delete_graph (graph_name , drop_collections = True )
33
+
34
+
13
35
def test_bc (load_graph ):
14
36
G_1 = nx .karate_club_graph ()
15
37
G_2 = nxadb .Graph (incoming_graph_data = G_1 )
38
+ G_3 = nxadb .Graph (graph_name = "KarateGraph" )
16
39
17
40
r_1 = nx .betweenness_centrality (G_1 )
18
41
r_2 = nx .betweenness_centrality (G_2 )
19
42
r_3 = nx .betweenness_centrality (G_1 , backend = "arangodb" )
20
43
r_4 = nx .betweenness_centrality (G_2 , backend = "arangodb" )
44
+ r_5 = nx .betweenness_centrality .orig_func (G_3 )
21
45
22
- assert len (r_1 ) == len (r_2 ) == len (r_3 ) == len (r_4 ) > 0
46
+ assert len (r_1 ) == len (G_1 )
47
+ assert r_1 == r_2
48
+ assert r_2 == r_3
49
+ assert r_3 == r_4
50
+ assert len (r_1 ) == len (r_5 )
23
51
24
52
try :
25
53
import phenolrs
26
54
except ModuleNotFoundError :
27
55
return
28
56
29
- G_3 = nxadb .Graph (graph_name = "KarateGraph" )
30
- r_5 = nx .betweenness_centrality (G_3 )
31
-
32
57
G_4 = nxadb .Graph (graph_name = "KarateGraph" )
33
- r_6 = nxadb .betweenness_centrality (G_4 , pull_graph_on_cpu = False )
58
+ r_6 = nx .betweenness_centrality (G_4 )
34
59
35
- G_5 = nxadb .DiGraph (graph_name = "KarateGraph" )
36
- r_7 = nx .betweenness_centrality (G_5 )
60
+ G_5 = nxadb .Graph (graph_name = "KarateGraph" )
61
+ r_7 = nxadb .betweenness_centrality (G_5 , pull_graph_on_cpu = False )
37
62
38
- # assert r_5 == r_6 # this is acting strange. I need to revisit
39
- assert r_6 == r_7
40
- assert len (r_5 ) == len (r_6 ) == len (r_7 ) > 0
63
+ G_6 = nxadb .DiGraph (graph_name = "KarateGraph" )
64
+ r_8 = nx .betweenness_centrality (G_6 )
65
+
66
+ # assert r_6 == r_7 # this is acting strange. I need to revisit
67
+ assert r_7 == r_8
68
+ assert len (r_6 ) == len (r_7 ) == len (r_8 ) == len (G_4 ) > 0
41
69
42
70
43
71
def test_pagerank (load_graph ):
44
72
G_1 = nx .karate_club_graph ()
45
-
46
73
G_2 = nxadb .Graph (incoming_graph_data = G_1 )
74
+ G_3 = nxadb .Graph (graph_name = "KarateGraph" )
47
75
48
76
r_1 = nx .pagerank (G_1 )
49
77
r_2 = nx .pagerank (G_2 )
50
78
r_3 = nx .pagerank (G_1 , backend = "arangodb" )
51
79
r_4 = nx .pagerank (G_2 , backend = "arangodb" )
80
+ r_5 = nx .pagerank .orig_func (G_3 )
52
81
53
- assert len (r_1 ) == len (r_2 ) == len (r_3 ) == len (r_4 ) > 0
82
+ assert len (r_1 ) == len (G_1 )
83
+ assert r_1 == r_2
84
+ assert r_2 == r_3
85
+ assert r_3 == r_4
86
+ assert len (r_1 ) == len (r_5 )
54
87
55
88
try :
56
89
import phenolrs
57
90
except ModuleNotFoundError :
58
91
return
59
92
60
- G_3 = nxadb .Graph (graph_name = "KarateGraph" )
61
- r_5 = nx .pagerank (G_3 )
62
-
63
93
G_4 = nxadb .Graph (graph_name = "KarateGraph" )
64
- r_6 = nxadb .pagerank (G_4 , pull_graph_on_cpu = False )
94
+ r_6 = nx .pagerank (G_4 )
95
+
96
+ G_5 = nxadb .Graph (graph_name = "KarateGraph" )
97
+ r_7 = nxadb .pagerank (G_5 , pull_graph_on_cpu = False )
65
98
66
- G_5 = nxadb .DiGraph (graph_name = "KarateGraph" )
67
- r_7 = nx .pagerank (G_5 )
99
+ G_6 = nxadb .DiGraph (graph_name = "KarateGraph" )
100
+ r_8 = nx .pagerank (G_6 )
68
101
69
- assert len (r_5 ) == len (r_6 ) == len (r_7 ) == len (G_4 )
102
+ assert len (r_6 ) == len (r_7 ) == len (r_8 ) == len (G_4 ) > 0
70
103
71
104
72
105
def test_louvain (load_graph ):
73
106
G_1 = nx .karate_club_graph ()
74
-
75
107
G_2 = nxadb .Graph (incoming_graph_data = G_1 )
108
+ G_3 = nxadb .Graph (graph_name = "KarateGraph" )
76
109
77
110
r_1 = nx .community .louvain_communities (G_1 )
78
111
r_2 = nx .community .louvain_communities (G_2 )
79
112
r_3 = nx .community .louvain_communities (G_1 , backend = "arangodb" )
80
113
r_4 = nx .community .louvain_communities (G_2 , backend = "arangodb" )
114
+ r_5 = nx .community .louvain_communities .orig_func (G_3 )
81
115
82
116
assert len (r_1 ) > 0
83
117
assert len (r_2 ) > 0
84
118
assert len (r_3 ) > 0
85
119
assert len (r_4 ) > 0
120
+ assert len (r_5 ) > 0
86
121
87
122
try :
88
123
import phenolrs
89
124
except ModuleNotFoundError :
90
125
return
91
126
92
- G_3 = nxadb .Graph (graph_name = "KarateGraph" )
93
- r_5 = nx .community .louvain_communities (G_3 )
94
-
95
127
G_4 = nxadb .Graph (graph_name = "KarateGraph" )
96
- r_6 = nxadb .community .louvain_communities (G_4 , pull_graph_on_cpu = False )
128
+ r_6 = nx .community .louvain_communities (G_4 )
129
+
130
+ G_5 = nxadb .Graph (graph_name = "KarateGraph" )
131
+ r_7 = nxadb .community .louvain_communities (G_5 , pull_graph_on_cpu = False )
97
132
98
- G_5 = nxadb .DiGraph (graph_name = "KarateGraph" )
99
- r_7 = nx .community .louvain_communities (G_5 )
133
+ G_6 = nxadb .DiGraph (graph_name = "KarateGraph" )
134
+ r_8 = nx .community .louvain_communities (G_6 )
100
135
101
136
assert len (r_5 ) > 0
102
137
assert len (r_6 ) > 0
103
138
assert len (r_7 ) > 0
139
+ assert len (r_8 ) > 0
104
140
105
141
106
142
def test_shortest_path (load_graph ):
0 commit comments