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: WW_test.m
    path of file: ./repos/RFM/function/other
    
    the code of the file until where you have to start completion: function   [W,R] = WW_test(X,Y)

% Implementation of the multivariate Wald Wolfovitz test
% (Matlab functions version)
% by J. Rigas 2010

% X, Y  -->  the multivariate samples to be compared
% R     -->  disjoint subtrees that result

    
function   [W,R] = WW_test(X,Y)

% Implementation of the multivariate Wald Wolfovitz test
% (Matlab functions version)
% by J. Rigas 2010

% X, Y  -->  the multivariate samples to be compared
% R     -->  disjoint subtrees that result
% W     -->  expresses the level of significance for the multivariate samples
%            X,Y to come from different distribution   

[m,Mm] = size(X); [n,Nn] = size(Y);
N = m+n;
TOTAL = [X;Y];

% d = dmatrix(TOTAL);
 d = squareform(pdist(TOTAL));
S = sparse(d);

[Tree,pred] = graphminspantree(S);      % Tree is in sparse matrix form 

[nodes1 nodes2 weights] = find(Tree);   % find edge nodes and weights
edges = [nodes2 nodes1];

for i=1:N                               % find the degree of each node in 
    di(i) = length(find(edges==i));     % the overall MST
end