1function test94
2%TEST94 test pagerank
3
4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
5% SPDX-License-Identifier: Apache-2.0
6
7addpath ('../Demo/MATLAB') ;
8T = load ('../Demo/Matrix/west0067') ;
9n = max (max (T (:, 1:2))) + 1 ;
10A = sparse (1+T(:,1), 1+T(:,2), T(:,3), n, n) ;
11
12A = spones (A) ;
13assert (isequal (A, spones (A)))
14
15n = size (A, 1) ;
16A = spones (A + speye (n)) ;
17
18rng default
19tic ;
20[r, ir] = dpagerank (A) ;
21toc
22
23rng default
24tic ;
25[r2, ir2, iters] = dpagerank2 (A) ;
26toc
27iters
28
29ir_diff = length (find (ir ~= ir2))
30
31C.matrix = A ;
32C.class = 'logical' ;
33
34tic ;
35[r3, ir3] = GB_mex_dpagerank (C) ;
36toc
37t = grbresults
38
39ir_diff = length (find (ir2 ~= ir3))
40
41% summary = [((r2-r3)')./(r2')  ir2' ir3' ir2'-ir3'] ;
42
43C.is_csc = false ;
44
45for method = [0 1001 1003 1004 1005]
46    fprintf ('------------------ method: %d\n', method) ;
47    tic ;
48    [r4, ir4] = GB_mex_dpagerank (C, method) ;
49    toc
50    t = grbresults
51    assert (norm (r4 - r3) < 1e-5) ;
52    assert (isequal (ir3, ir4)) ;
53end
54
55% k = min (300, n) ;
56% summary (1:k,:)
57
58fprintf ('test94: all tests passed\n') ;
59
60