def __call__(self): # list of chronologically sorted list of shots graph = self._threads_graph() threads = [sorted(cc) for cc in nx.connected_components(graph)] annotation = Annotation() labelGenerator = getLabelGenerator() # chronologically sorted threads (based on their first shot) for thread in sorted(threads, key=lambda thread: thread[0]): label = next(labelGenerator) for shot in thread: annotation[shot] = label return annotation.smooth()