function [G,Gc] = generateEnvGraph(environment_size, rho, move_size, obstacle_points, env_step_size)

xbdd = environment_size(1:2);
ybdd = environment_size(3:4);

dx = 0.1 ; % fix this as a parameter later

[X,Y] = meshgrid(xbdd(1):env_step_size:xbdd(2), ybdd(1):env_step_size:ybdd(2));
G_points = [reshape(X,[],1), reshape(Y,[],1)];

% check for obstacle collisions
rm_index = zeros(size(G_points,1),1);
for i=1:size(G_points,1)
    if ~isempty(obstacle_points)
        dists = sqrt((obstacle_points(:,1) - G_points(i,1)).^2 + (obstacle_points(:,2) - G_points(i,2)).^2);
    else
        dists = [];
    end
    if any(dists <= dx)
        rm_index(i) = i; % delete this entry because it's too close to obstacles
    end
end
G_points(rm_index(rm_index ~= 0),:) = []; 
env_nodes = size(G_points, 1);

% build adjacency matrix for G (this is the MOVEMENT adjacency)
adjacency = zeros(env_nodes);
for i=1:env_nodes
    dists = sqrt((G_points(:,1) - G_points(i,1)).^2 + (G_points(:,2) - G_points(i,2)).^2);
    if any(dists <= move_size)
        close_nodes = find(dists <= move_size);
        for j=1:size(close_nodes,1)
            if close_nodes(j) == i
                continue;
            end
            [collision_flag, ~] = checkCollisions(G_points(i,:), G_points(close_nodes(j),:), dx, obstacle_points);
            if ~collision_flag
                adjacency(i,close_nodes(j)) = 1;
            end
        end
    end
end

% build adjacency matrix for G (this is the COMMUNICATION adjacency)
adjacency_c = zeros(env_nodes);
for i=1:env_nodes
    dists = sqrt((G_points(:,1) - G_points(i,1)).^2 + (G_points(:,2) - G_points(i,2)).^2);
    if any(dists <= rho)
        close_nodes = find(dists <= rho);
        for j=1:size(close_nodes,1)
            if close_nodes(j) == i
                continue;
            end
            [collision_flag, ~] = checkCollisions(G_points(i,:), G_points(close_nodes(j),:), dx, obstacle_points);
            if ~collision_flag
                adjacency_c(i,close_nodes(j)) = 1;
            end
        end
    end
end

G = struct('N', size(G_points,1), 'nodes', [G_points, (1:size(G_points,1))'], 'adj', adjacency);
Gc = struct('N', size(G_points,1), 'nodes', [G_points, (1:size(G_points,1))'], 'adj', adjacency_c);

end

