Looking for a query that eliminates near-repeats
My sense is that you're doing something wrong and need better tooling like PostGIS and PgRouting just from the problem you're describing but perhaps something like this will work,

SELECT DISTINCT
  greatest(name1, name2),
  least(name1, name2),
  greatest(x1,x2),
  least(x1,x2)
FROM tbl;


If you're using PostGIS then you can use spatial equality,

SELECT max(coalesce(t1.name,t2.name))
FROM table AS t1
JOIN table AS t2
  ON ST_Equals(t1.line,t2.line)
GROUP BY ST_Equals(t1.line,t2.line);


If you're using PgRouting none of this matters because the edges become the same anyway. Edges are bidirectional.