function parents(s,p,orders)
idList = [s.id];
for i = 1:length(s)
ancestor = s(i).id;
while true
parentPosition = find(idList == ancestor);
if isempty(parentPosition)
%disp('deleted entry')
break
else
parent = s(parentPosition).based_on;
if (parent ~= 0)
ancestor = parent;
else
break
end
end
end
s(i).adam = ancestor;
end
%%
nColors = 6;
adams = [s.adam];
bins = min(idList):max(idList);
xx = hist(adams,bins);
[null,bigOnesInd] = sort(xx);
foundingFathers = bins(bigOnesInd(end-nColors+1:end));
%%
clf
drawnow
box on
colors = flipud(prism(nColors));
x = [s.date];
y = normalize([s.score],orders,min([p.score]),max([p.score]));
for i = 1:length(s)
if s(i).passed
flag = find(s(i).adam==foundingFathers);
if isempty(flag)
color = .8*ones(1,3);
flag = 7;
else
color = colors(flag,:);
end
h(flag) = line(x(i),y(i),'color',color,'marker','.','Tag',num2str(s(i).id));
if (s(i).based_on == 0)
else
parent = (idList == s(i).based_on);
if s(parent).passed
line([x(parent) x(i)], ...
[y(parent) y(i)], ...
'color',color, ...
'Tag',[num2str(s(parent).id) ' to ' num2str(s(i).id)]);
end
% if s(i).based_on == 11227
% line(x(i),y(i),'markeredgecolor','k','marker','o');
% end
end
end
end
set(gca,'yscale','log')
datetick
title('The Six Biggest Clans')
xlabel('submission time')
ylabel('score (normalized log scale)')
for i = length(foundingFathers):-1:1
relatives = find(adams == foundingFathers(i));
labels{i} = ...
sprintf('%.0f passed, %.0f failed', ...
sum([s(relatives).passed]), ...
sum(~[s(relatives).passed]));
end
h = h([end-1:-1:1 end]);
labels = labels(end:-1:1);
labels{7} = 'other';
%legend(h,labels,3)
set(datacursormode(gcf),'UpdateFcn',@(empt,obj){get(obj.Target,'Tag')})
set(gca,'ylim',[0 max(y([s.isLeader]))])