[SPARK-3650] Fix TriangleCount handling of reverse edges

This PR causes the TriangleCount algorithm to remove self-edges, direct edges from low-id to high-id (canonical direction), and then remove duplicate edges, before running the triangle count algorithm.