You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: EdgesFromDist.m
    path of file: ./repos/d4m/examples/2Apps/3PerfectPowerLaw
    
    the code of the file until where you have to start completion: function v = EdgesFromDist(di,ni);
%EdgesFromDist: Compute start vertex of edge (half an edge) from a degree distribution.
%  Usage:
%     v = EdgesFromDist(di,ni)
%  Input:
%     di = vector of degrees
%     ni = vector of counts
%  Output:
%     v = vector of vertices


    
function v = EdgesFromDist(di,ni);
%EdgesFromDist: Compute start vertex of edge (half an edge) from a degree distribution.
%  Usage:
%     v = EdgesFromDist(di,ni)
%  Input:
%     di = vector of degrees
%     ni = vector of counts
%  Output:
%     v = vector of vertices

  Nd_bar = numel(di);
  A1 = sparse(1:Nd_bar,ni,di);
  A2 = fliplr(cumsum(fliplr(A1),2));
  [tmp tmp d] = find(A2);
  A3 = sparse(1:numel(d),d,1);
  A4 = fliplr(cumsum(fliplr(A3),2));
  [v tmp tmp] = find(A4);

return
end