% fpalmostadelman.m June 2007
% Amber Shoecraft, Jim Dickson 
% This program is correct to our knowledge for the Adelman graph less the
% edges from 6->4 and from 4->2. This is not an easily generalized program
% for all graphs so it is built to run without inputs for this specific graph.
% There is a modified version of this code that is intended to work for the
% Adelman graph.  
counter=0;
fp=zeros(1,13);
v1=[-1 1;-1 2;-1 3];
v2=[1 5;1 4;12 5;12 4];
v3=[4 6;4 7];
v4=[2 8;11 8];
v6=[7 10;7 9];
v7=[5 12;5 11;10 12;10 11;8 12;8 11];
superv=[v1;v2;v3;v4;v6;v7];
for i=1:2
    for j=4:7
        for k=8:9
            for m=10:11
                for n=12:13
                    for o=14:19
                        g=perms([j k m n o]);
                        for b=1:size(g,1)
                            c=find(g(b,:)==13);
                            if c==5 
                                ord=[i g(b,:)];
                                superlistv=superv(ord,:)';
                                superlistv(:);
                                sl=superlistv(:)';
                                if length(sl)-length(unique(sl))==sum(sl==[sl(2:12) sl(1)]);
                                    counter=counter+1;
                                    fp(counter,:)=zeros(1,13);
                                    e=ones(1,length(sl));
                                    usl=sl(logical(e-(sl==[sl(2:12) sl(1)])));
                                    fp(counter,1:length(usl))=usl;
                                end
                            elseif isempty(c)
                                ord=[i g(b,:)];
                                superlistv=superv(ord,:)';
                                superlistv(:);
                                sl=[superlistv(:)' 9];
                                if length(sl)-length(unique(sl))==sum(sl==[sl(2:13) sl(1)]);  
                                    counter=counter+1;
                                    fp(counter,:)=zeros(1,13);
                                    e=ones(1,length(sl));
                                    usl=sl(logical(e-(sl==[sl(2:13) sl(1)])));
                                    fp(counter,1:length(usl))=usl;
                                end
                                ord=[i g(b,:)];
                                superlistv=superv(ord,:)';
                                superlistv(:);
                                sl=[superlistv(:)' 3] ;
                                if length(sl)-length(unique(sl))==sum(sl==[sl(2:13) sl(1)]);    
                                    counter=counter+1;
                                    fp(counter,:)=zeros(1,13);
                                    e=ones(1,length(sl));
                                    usl=sl(logical(e-(sl==[sl(2:13) sl(1)])));
                                    fp(counter,1:length(usl))=usl;
                                end
                            end
                        end
                    end
                end
            end
        end
    end
end
counter 
ufp=unique(fp, 'rows')
T8=length(find(ufp(:,9)==0))*6144
T9=(length(find(ufp(:,10)==0))-length(find(ufp(:,9)==0)))*992
T10=(length(find(ufp(:,11)==0))-length(find(ufp(:,10)==0))-length(find(ufp(:,9)==0)))*168
T11=(length(find(ufp(:,12)==0))-length(find(ufp(:,11)==0))-length(find(ufp(:,10)==0))-length(find(ufp(:,9)==0)))*24
T12=(length(find(ufp(:,13)==0))-length(find(ufp(:,12)==0))-length(find(ufp(:,11)==0))-length(find(ufp(:,10)==0))-length(find(ufp(:,9)==0)))*2
falsepositves=T8+T9+T10+T11+T12