The bvgraph class makes working with enormous graph adjacency matrices in Matlab a snap.
The class implements an interface to BVGraph files (http://webgraph.dsi.unimi.it) that emulates a Matlab sparse matrix.
http://cnets.indiana.edu/groups/nan/webgraph/
http://code.google.com/p/py-web-graph/
For example,
>> G = bvgraph(‘data/wb-cs.stanford’);
>> size(G);
>> y = G*rand(size(G,1),1);
are all valid operations. See the “bvgraph example” file for a more exhaustive explanation.
The goal of the library is to support computing PageRank with a 1 billion link graph and 120 million nodes possible inside Matlab with only 2 GB of memory. To load the matrix itself on a 64-bit platform would take around 10 GB of memory. As the “huge graphs” example shows, the bvgraph class achieves this goal.
To find additional datasets, see http://law.dsi.unimi.it/index.php?option=com_include&Itemid=65
The software was tested on
Matlab 2007b on amd64 Ubuntu 7.04
Matlab 2007a on amd64 Ubuntu 7.04
Matlab 2006b on amd64 Ubuntu 7.04
Matlab R14SP3 on qemu (i686) Ubuntu 6.06.1
Matlab 2007b on i686 Ubunutu 5.10
Matlab 7.0 on i386 Windows
Matlab 2007a on i386 Windows
Matlab 2007a on qemu (x86_64) WinXP64
Cite As
David Gleich (2023). bvgraph (https://www.mathworks.com/matlabcentral/fileexchange/16248-bvgraph), MATLAB Central File Exchange. Retrieved.
function bvg = bvgraph(filename,optionsu)
options = struct('load_type', 'online','trans',0);
if exist('optionsu','var')
options = merge_structs(optionsu,options);
error('bvgraph:invalidParameter','unknown load type: %s', options.load_type);
if ~exist([filename '.graph'], 'file')
error('bvgraph:fileNotFound', ...
'The file %s.graph does not seem to exist!', filename);
if ~exist([filename '.properties'], 'file')
error('bvgraph:fileNotFound', ...
'The properties file %s.properties does not seem to exist!', filename);
if offset_step > 0 && ~exist([filename '.offsets'], 'file')
error('bvgraph:fileNotFound', ...
'The offsets file %s.offsets does not seem to exist!', filename);
[n,nz,smem,gmem,offsetmem] = bvgfun('load',filename,offset_step);
bvg = struct('n',n,'nz',nz,'smem',smem,'gmem',gmem,'offsetmem',offsetmem,...
'offset_step', offset_step, 'filename', filename, ...
'class', '', 'transp', transp);
bvg = class(bvg, 'bvgraph');
%%%%%%%%%%%%%%%%%%%%%
[filepath filename] = fileparts(mfilename('fullpath'));
input(['Press any key to download the GPL protected codes\n' ...
'or Ctrl-C to stop here\n']);
urlwrite('http://wilkinson.stanford.edu/~dgleich/codes/bvgraph-1.2-src.zip',...
fprintf(['Eek! Getting the source failed!!\n' ...
'Please send mithandor@gmail.com an email immediately\n']);
fprintf('I''m so sorry, but is not going to compile without the source.\n');
unzip('bvgraph-1.2-src.zip');
%%%%%%%%%%%%%%%%%%%%%
G = bvgraph('../data/wb-cs.stanford');
fprintf('The library was already compiled!\n');
if strcmp(s.identifier, 'bvgfun:notCompiled')
fprintf('The library is now compiled!\n');
error('bvgraph:compileError','the library could not automatically compile!');
G = bvgraph('../data/wb-cs.stanford');
if norm(G*x - A*x) > eps(1)
error(msgid, 'the sparse routine example failed');
G = bvgraph('../data/wb-cs.stanford');
error(msgid,'there was an error multiplying two vectors');
G2 = bvgraph('../data/wb-cs.stanford',struct('offline',1));
if ~isequal(x1,y1) || ...
error(msgid,'there was an error with the offline graph');
error(msgid, 'bvgraph did not report the correct type');
error(msgid, 'bvgraph did not pretend to be a logical');
error(msgid, 'bvgraph did not return the correct number of non-zeros');
error(msgid,'istrans reported the incorrect transpose state');
error(msgid,'istrans reported the incorrect transpose state');
error(msgid,'sum returned incorrect results');
if ~isequal(d_A_1, d_G_1)
error(msgid,'sum1 returned incorrect results');
if ~isequal(d_A_2, d_G_2)
error(msgid,'sum2 returned incorrect results');
error(msgid,'sum returned incorrect results');
if ~isequal(d_A_1, d_G_1)
error(msgid,'sum1 returned incorrect results');
if ~isequal(d_A_2, d_G_2)
error(msgid,'sum2 returned incorrect results');
G = bvgraph('../data/wb-cs.stanford');
P = sparse(i, j, v(i)./d(i), size(A,1), size(A,2));
y_G = substochastic_mult(G,x);
if norm(y_P-y_G,inf) > 100*eps(1)
error(msgid,'stochastic_mult results are not correct to 100*eps');
y_Gt = substochastic_mult(G',x);
if norm(y_Pt-y_Gt,inf) > 100*eps(1)
error(msgid,'stochastic_mult(tranpose) results are not correct to 100*eps');