removing redundant edges from graphs