function [time1, time2, nodes] = mst_test(N)
% N number of network nodes
% time1 MST CPU time
% time2 Heuristic method CPU time
% nodes the set of core nodes

U = rand(N);
%A = ((U*U')/norm(U)).*(1-eye(N));
A = triu(U',1)+tril(U,-1);
S_A = sparse(A);
tic
[Tree, pred] = graphminspantree(S_A);
time1 = toc;
T = nnz(Tree);
F = full(Tree);
v = ((F+F') > 0) .* (ones(N,1)*(1:N));
d = sum( v>0 );
clear F T A U S_A Tree pred 

tic;
nodes_checked = zeros(1,N);
core_nodes = zeros(N,1);
while sum(nodes_checked) < N
    [mmax, current_node] = max(d);
    l = mmax(1); %(1) because they can be more than one
    nodes_checked(current_node(1)) = 1; %I checked the core node  
    core_nodes(current_node(1)) = 1; % I noted the core node
    neigh = find(v(current_node(1),:)); %Find neighbors
    nodes_checked(neigh) = 1; % Check neighbors (neihbors can still be vore nodes)
    d(current_node(1)) = 0; % remove core node from network
    d(neigh) = d(neigh) - 1; % remove core node from neighborhoods
    v(neigh,current_node(1)) = 0;   
end
nodes = length(find(core_nodes));
time2 = toc;

end

