sparsify the graph