1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
function gbtest64
%GBTEST64 test GrB.pagerank
% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
% SPDX-License-Identifier: Apache-2.0
% load west0479 ; %#ok<*LOAD>
load west0479_correct ; %#ok<*LOAD>
west0479 = Problem.A ;
W = abs (west0479) ;
W (1,:) = 0 ;
A = digraph (W) ;
G = GrB (W) ;
R = GrB (W, 'by row') ;
r1 = centrality (A, 'pagerank') ;
r2 = GrB.pagerank (G) ;
assert (norm (r1-r2) < 1e-12) ;
r1 = centrality (A, 'pagerank') ;
r2 = GrB.pagerank (R) ;
assert (norm (r1-r2) < 1e-12) ;
r1 = centrality (A, 'pagerank', 'Tolerance', 1e-8) ;
r2 = GrB.pagerank (G, struct ('tol', 1e-8)) ;
assert (norm (r1-r2) < 1e-12) ;
lastwarn ('') ;
warning ('off', 'MATLAB:graphfun:centrality:PageRankNoConv') ;
warning ('off', 'GrB:pagerank') ;
r1 = centrality (A, 'pagerank', 'MaxIterations', 2) ;
[msg, id] = lastwarn ; %#ok<*ASGLU>
r2 = GrB.pagerank (G, struct ('maxit', 2)) ;
[msg, id] = lastwarn ;
assert (isequal (id, 'GrB:pagerank')) ;
assert (norm (r1-r2) < 1e-12) ;
lastwarn ('') ;
r1 = centrality (A, 'pagerank', 'FollowProbability', 0.5) ;
r2 = GrB.pagerank (G, struct ('damp', 0.5)) ;
assert (norm (r1-r2) < 1e-12) ;
r1 = GrB.pagerank (G, struct ('weighted', true)) ;
r2 = GrB.pagerank (R, struct ('weighted', true)) ;
assert (norm (r1-r2) < 1e-12) ;
fprintf ('gbtest64: all tests passed\n') ;
|