Removes unreachable commits from the graph.