function kf = list_kfollowers(A,q,k) init_kfol(A,k); kf = list_kfollowers_rec(A,q,k); return function kf = list_kfollowers_rec(A,q,k) global KFOL % KFOL{q,k} are the k-followers of q if ~isequal(KFOL{q,k+1},{-1}) % already computed this value kf = KFOL{q,k+1}; else kf = {}; [qq1,ss1] = get_ndelta(A,q); for i=1:length(qq1) R = qq1{i}; for r=R kf1 = list_kfollowers_rec(A,r,k-1); for j=1:length(kf1) kf1{j} = [ss1(i) kf1{j}]; end kf = [kf kf1]; end end kf = unique(kf); KFOL{q,k+1} = kf; end return function init_kfol(A,K) global KFOL % KFOL{q,k} are the k-followers of q KFOL = {}; for q=A.Q KFOL{q,1} = {''}; for k=2:K+1 KFOL{q,k} = {-1}; end end return function kf = list_kfollowers_old(A,q,k) % lists all the k-followers of q in A % conceptually simple but terribly wasteful -- do not use kf = {}; if (k==0) kf{end+1} = ''; else [qq1,ss1] = get_ndelta(A,q); for i=1:length(qq1) R = qq1{i}; for r=R kf1 = list_kfollowers(A,r,k-1); for j=1:length(kf1) kf1{j} = [ss1(i) kf1{j}]; end kf = [kf kf1]; end end end kf = unique(kf); return