function [f,lam] = crudeMillerTolliver(a,tol,maxits)
% function [f,lam] = crudeMillerTolliver(a,tol,maxits)
%

if (nargin < 2),
    tol = .001;
end

if (nargin < 3),
    maxits = 10;
end


sigma = min(sum(a))/10^5;
psi = @(x)(x.^2 ./ (1+x.^2));

lam2 = 1;
lam = [];

iter = 0;

while and((lam2 > tol),(iter < maxits)),

  l = diag(sum(a)) - a;
  di = diag(sparse(1./sum(a)));
  nl = di* l;
  [v,e] = eigs(nl+sigma*speye(length(a)),2,'sm'); e = e - sigma;
  f = v(:,2);
  
  lam2 = e(2,2);
  lam = [lam, lam2];
  
  [ai,aj,av] = find(a);
  aw = av .* psi((f(ai).^2 + f(aj).^2) ./ ((f(ai)-f(aj)).^2));
  a = sparse(ai,aj,aw);

  iter = iter + 1;
  
end

