Setting up the graph for solving closure problem