Trim redundant edges