function [lambda, x_star] = ADMM_regularization_path(samples, y, c, connection_matrix, nbSamplePerNode)
% 
% 
n = length(connection_matrix) % nbNode
% For each node i, apply the ADMM steps while the residuals are still big.

% Return the x_i (classifiers)

%initialization -- solve for lambda = 0:
for i=1:n
    start = (i-1)*nbSamplePerNode + 1;
    stop = start + nbSamplePerNode - 1;
    [x_init{i}, z_init{i}, u_init{i}] = node_solver(samples(start:stop, :), y(start:stop), c, connection_matrix(:,i));
end

lambda(1) = 0.0;
lambda(2) = 0.001;
alpha = 10; % 
lambdaMax = (1e3) + 1;
i=2;
x_star = {};
z_star = {};
u_star = {};

x_star{1} = x_init;

%regularization path: run for different values of lambda until
%lambda_critical, where there's no further change in x_star
while (lambda(i) <= lambdaMax)
    if (i == 2)
        [x_star{i}, z_star{i}, u_star{i}] = ADMM_convex_solver(samples, y, connection_matrix, lambda(i), c, x_init, z_init, u_init, nbSamplePerNode);
    else
        [x_star{i}, z_star{i}, u_star{i}] = ADMM_convex_solver(samples, y, connection_matrix, lambda(i), c, x_star{i-1}, z_star{i-1}, u_star{i-1}, nbSamplePerNode);
    end
    lambda(i+1) = lambda(i) * alpha; 
    i = i+1
end

% Remove the last unused lambda
lambda(end) = [];
lambda = lambda';
end