1function dimacs10_demo (arg) 2%DIMACS10_DEMO reads in the DIMACS10 graphs. 3% Reads them in and displays them in increasing order of nnz(S). 4% Can also read in just a subset. 5% 6% Example 7% dimacs10_demo 8% dimacs10_demo (-10) ; % just the smallest 10 graphs 9% dimacs10_demo ([1 3 5 8]) ; % read just those four graphs 10% 11% See also dimacs10, ssget 12 13% Copyright 2011, Timothy A Davis 14 15lastwarn ('') ; 16index = dimacs10 ; 17[~,list] = sort (index.nnz) ; 18if (nargin > 0) 19 if (isscalar (arg) && arg < 0) 20 list = list (1:(-arg)) ; 21 else 22 list = arg ; 23 end 24end 25if (length (list) > 1) 26 fprintf ('\ndimacs10_demo: testing %d graphs\n', length (list)) ; 27end 28for id = list (:)' 29 [S name kind] = dimacs10 (id) ; 30 fprintf ('%3d %s : %s : n: %d nnz %d\n', id, name, kind, size(S,1), nnz(S)); 31 ssweb (index.ssname {id}) ; 32 clf 33 spy (S) ; 34 drawnow 35end 36 37S = dimacs10 ('adjnoun') ; 38spy (S) 39title ('clustering/adjnoun') ; 40 41% test error handling 42fail = 0 ; 43try 44 S = dimacs10 (0) ; %#ok 45 fail = 1 ; 46catch me %#ok 47end 48try 49 S = dimacs10 ('crud') ; %#ok 50 fail = 1 ; 51catch me %#ok 52end 53try 54 S = dimacs10 (1,1) ; %#ok 55 fail = 1 ; 56catch me %#ok 57end 58 59if (fail) 60 error ('test failed') ; 61end 62 63if (length (list) > 1) 64 fprintf ('\ndimacs10: all tests passed\n') ; 65end 66