function [H,q,n,m,dv_max,dc_max,dv,dc,VN_contact,CN_contact]=alist_process(file_name)
% This function is designed to reconstruct a sparse matrix from the row and column information specified in a given alist file.
%% input variable
% alist file name : file_name
%% output variable
% H : sparse matrix
%%
fid = fopen(file_name);
n = fscanf(fid,'%d',1);
m = fscanf(fid,'%d',1);
q = fscanf(fid,'%d',1);
dv_max=fscanf(fid,'%d',1);
dc_max=fscanf(fid,'%d',1);
dv=zeros(1,n);
for i=1:n
dv(i)=fscanf(fid,'%d',1);
end
dc=zeros(1,m);
for i=1:m
dc(i)=fscanf(fid,'%d',1);
end
%% contact information extract
VN_contact=fscanf(fid,'%d',[dv_max*2 n]);
CN_contact=fscanf(fid,'%d',[dc_max*2 m]);
%% reconstruct the sparse matrix H (use the VN contact information)
H=zeros(m,n);
for i=1:n
for j=1:dv(i)
H(VN_contact(2*j-1,i),i)=VN_contact(2*j,i);
end
end
%% reconstruct the sparse matrix H (use the CN contact information)
% H=zeros(m,n);
% for i=1:m
% for j=1:dc(i)
% H(i,CN_contact(2*j-1,i))=CN_contact(2*j,i);
% end
% end
end