function smooth_info = smooth_info_const(isosurface_vf, sigma)

% find the degree for each vertex (degree) and the maximum degree (max_degree)
% using the code from mni_getmesh.m by Dr. Moo K. Chung

disp('calculating degree...')

degree=zeros(size(isosurface_vf.vertices,1),1);
for j=1:size(isosurface_vf.faces,1)
    degree(isosurface_vf.faces(j,:))=degree(isosurface_vf.faces(j,:))+1;
end
max_degree=max(degree);

% find the neighbors for each vertex (nbr)
% using the code from mni_getmesh.m by Dr. Moo K. Chung

disp('finding neighbor information...')

nbr=zeros(size(isosurface_vf.vertices,1),max_degree);
for i_tri=1:size(isosurface_vf.faces,1)
    for j=1:3
        cur_point = isosurface_vf.faces(i_tri,j);
        for k=1:3
            if (j ~= k)
                nbr_point= isosurface_vf.faces(i_tri,k);
                if find(nbr(cur_point,:)==nbr_point)
                    ;
                else
                    n_nbr = min(find(nbr(cur_point,:) == 0));
                    nbr(cur_point,n_nbr) = nbr_point;
                end;
            end;
        end;
    end;
end;

%discrete heat kernel (K)

disp('calculating heat kernel...')

K=inline('exp(-x/(4*sigma))/sum(exp(-x/(4*sigma)))');
% For publications [1] and [2], change this line to
% K=inline('exp(-x/(2*sigma^2))/sum(exp(-x/(2*sigma^2)))');

%kernel weight computation (weight)

n_vertex=size(nbr,1);
weight=zeros(n_vertex,max_degree);

for i=1:n_vertex    
    current_nbr=nbr(i,nbr(i,:)~=0);
    pipo=(isosurface_vf.vertices(current_nbr,:))'-kron(ones(1,size(current_nbr,2)),(isosurface_vf.vertices(i,:))');
    distance=sum(pipo.*pipo);
    weight(i,1:(size(distance,2)+1))=K(sigma,[0 distance]);
end;
clear pipo;
clear distance;

% find the indices of faces around each vertex (face_around_vertex)

disp('finding the faces around each vertex...')

face_around_vertex = zeros(n_vertex,max_degree);
for i=1:size(isosurface_vf.faces,1)
    current_faces = isosurface_vf.faces(i,:);
    for j=1:3
        face_around_vertex(current_faces(1,j),min(find(face_around_vertex(current_faces(1,j),:)==0))) = i;
    end
end

% output

smooth_info.weight = weight;
smooth_info.face_around_vertex = face_around_vertex;
smooth_info.nbr = nbr;
smooth_info.degree = degree;
