function x=gpfsp(Pk)
% generate a permutation from P_t
% generation using node transitions
[n,m]=size(Pk); % n==m
x(1)=1;
Pkp=Pk;
for k=1:(n-1),
Pkp(:,x(k))=zeros(n,1);
for i=1:n,
	if(sum(Pkp(i,:)~=0)),
	Pkp(i,:)=Pkp(i,:)/sum(Pkp(i,:));
end
end
% now generate X(k+1) from the X(k)th ROW of Pkp(?) or Pk
     r=rand(1);
     cc=0;
     c=0;
	      while(r>cc),
	   c=c+1;
cc=cc+Pk(x(k),c);
end
	  x(k+1)=c;
Pk=Pkp;
          
end

