@@ -118,16 +118,33 @@ test_that("`hits_score()` works -- authority", {
118118 x
119119 }
120120
121- g1 <- sample_pa(100 , m = 10 )
121+ g1 <- make_graph(
122+ c(1 , 3 , 1 , 6 , 1 , 10 , 2 , 1 , 3 , 1 , 4 , 2 , 4 , 7 , 4 , 9 , 5 , 4 , 5 , 6 , 5 , 8 , 6 , 3 ,
123+ 7 , 1 , 7 , 5 , 7 , 6 , 7 , 10 , 8 , 4 , 9 , 6 , 10 , 5 , 10 , 7 ),
124+ directed = TRUE )
122125 A <- as_adj(g1 , sparse = FALSE )
123126 s1 <- eigen(t(A ) %*% A )$ vectors [, 1 ]
124127 s2 <- hits_scores(g1 )$ authority
128+ expect_equal(
129+ s2 ,
130+ c(0.519632767970952 , 0.0191587307007462 , 0.327572049088003 ,
131+ 0.238728053455971 , 0.449690304629051 , 1 , 0.0966933781044594 ,
132+ 0.204851318050036 , 0.0191587307007462 , 0.653243552177761 )
133+ )
125134 expect_equal(mscale(s1 ), mscale(s2 ), ignore_attr = TRUE )
126135
127- g2 <- sample_gnp(100 , 2 / 100 )
136+ g2 <- make_graph(
137+ c(1 , 2 , 1 , 4 , 2 , 3 , 2 , 4 , 3 , 1 , 3 , 5 , 4 , 3 , 5 , 1 , 5 , 2 ),
138+ directed = TRUE
139+ )
128140 A <- as_adj(g2 , sparse = FALSE )
129141 s1 <- eigen(t(A ) %*% A )$ vectors [, 1 ]
130142 s2 <- hits_scores(g2 )$ authority
143+ expect_equal(
144+ s2 ,
145+ c(0.763521118433368 , 1 , 0.546200349457202 ,
146+ 0.918985947228995 , 0.28462967654657 )
147+ )
131148 expect_equal(mscale(s1 ), mscale(s2 ), ignore_attr = TRUE )
132149
133150})
@@ -143,16 +160,33 @@ test_that("`hits_scores()` works -- hub", {
143160 x
144161 }
145162
146- g1 <- sample_pa(100 , m = 10 )
163+ g1 <- make_graph(
164+ c(1 , 3 , 1 , 6 , 1 , 10 , 2 , 1 , 3 , 1 , 4 , 2 , 4 , 7 , 4 , 9 , 5 , 4 , 5 , 6 , 5 , 8 , 6 , 3 ,
165+ 7 , 1 , 7 , 5 , 7 , 6 , 7 , 10 , 8 , 4 , 9 , 6 , 10 , 5 , 10 , 7 ),
166+ directed = TRUE )
147167 A <- as_adj(g1 , sparse = FALSE )
148168 s1 <- eigen(A %*% t(A ))$ vectors [, 1 ]
149169 s2 <- hits_scores(g1 )$ hub
170+ expect_equal(
171+ s2 ,
172+ c(0.755296579522977 , 0.198139015063149 , 0.198139015063149 ,
173+ 0.0514804231207635 , 0.550445261472941 , 0.124905139108053 ,
174+ 1 , 0.0910284037021176 , 0.381305851509012 , 0.208339295395331 )
175+ )
150176 expect_equal(mscale(s1 ), mscale(s2 ), ignore_attr = TRUE )
151177
152- g2 <- sample_gnp(100 , 2 / 100 )
178+ g2 <- make_graph(
179+ c(1 , 2 , 1 , 4 , 2 , 3 , 2 , 4 , 3 , 1 , 3 , 5 , 4 , 3 , 5 , 1 , 5 , 2 ),
180+ directed = TRUE
181+ )
153182 A <- as_adj(g2 , sparse = FALSE )
154183 s1 <- eigen(A %*% t(A ))$ vectors [, 1 ]
155184 s2 <- hits_scores(g2 )$ hub
185+ expect_equal(
186+ s2 ,
187+ c(1 , 0.763521118433368 , 0.546200349457203 ,
188+ 0.28462967654657 , 0.918985947228995 )
189+ )
156190 expect_equal(mscale(s1 ), mscale(s2 ), ignore_attr = TRUE )
157191
158192})
0 commit comments