% Commands for reading the graphs into Matlab. The output is
% a sparse matrix G such that G(i, j) is the edge (or the weight of the
% edge)
% Copy-paste the appropriate code into Matlab (possibly change the name
% of the file.

% AS Graph data
[from, count, edges] = textread('ASconnlist.20020201.1800', '%d\t->\t%d\t%s', 'delimiter', '', 'bufsize', 40000);
m = zeros(max(from), 1);
m(from) = 1:length(from);
K = length(from);

G = spalloc(K, K, sum(count));
for i = 1:K
    G(m(from(i)), m(sscanf(edges{i}, ':%d'))) = 1;
end



% Italy wikipedia
[from, to] = textread('italy.edges');
M = max(max(from), max(to));
N = length(from);
G = sparse(from, to, ones(N, 1), M, M);



% France wikipedia
[from, to] = textread('france.edges', '', 'headerlines', 1);
M = max(max(from), max(to));
N = length(from);
G = sparse(from, to, ones(N, 1), M, M);



% Czech wikipedia
[from, to] = textread('czech.edges', '', 'headerlines', 1);
M = max(max(from), max(to));
N = length(from);
G = sparse(from, to, ones(N, 1), M, M);



% Data Sets for Link Analysis Ranking Experiments
[from, edges] = textread('adj_list', '%d: %s', 'delimiter', '');
K = length(edges);

G = spalloc(K, K, 3*K);

for i = 1:K
    e = str2num(edges{i}) + 1;
    G(from(i) + 1, e(1:(end - 1))) = 1;
end



% Coauthorship graph
[from, to, w] = textread('authors.graph');
M = max(max(from), max(to));
G = sparse(from, to, w, M, M);



% Power grid
edges = textread('power_unweighted','%s','delimiter','#','whitespace','\n');
K = length(edges);

G = spalloc(K, K, 13188);

for i = 1:K
    e = str2num(edges{i}) + 1;
    G(e(1), e(2:end)) = 1;
end



% AS Graph Data Sets
[e1, e2] = textread('peer.all.020515', '', 'delimiter', ':');
M = max(max(e1), max(e2));
N = length(e1);
G = sparse([e1; e2], [e2; e1], ones(2*N, 1), M, M);



% KDDCup 2003
[from, to] = textread('hep-th-citations');
[ids, foo, ind] = unique([from; to]);
N = length(from);
from = ind(1:N);
to = ind((N+1):end);
M = max(ind);
G = sparse(from, to, ones(N, 1), M, M);
