function eset = new_edges( cluster, graph ) % returns the set of new edges to be added to graph based on cluster N = length(cluster); eset = cell(1,N-1); % at most n-1 edges possible given n nodes j = 1; for i=1:N, thisn = cluster(i); others = setdiff( cluster, thisn ); for o=others, if graph(thisn,o) == 1 %disp(sprintf('already an edge between %d,%d',thisn,o)); % already an edge else edge = [thisn, o]; eset{j} = edge; j = j+1; end; end; end; % shrink eset if j == 1, eset = []; else cset = cell(1,j-1); for i=1:j-1, cset{i} = eset{i}; end; eset = cset; end;