The regularity method in directed graphs and hypergraphs