gh-38535: fix issue 38527 with `spqr_tree_to_graph`
Fixes #38527.
This PR makes the comparison of edges more robust in
`spqr_tree_to_graph`, so that edges `(u, v, label)` and `(v, u, label)`
are no longer considered as distinct edges.
### :memo: Checklist
<!-- Put an `x` in all the boxes that apply. -->
- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.
### :hourglass: Dependencies
<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - #12345: short description why this is a dependency -->
<!-- - #34567: ... -->
URL: https://github.com/sagemath/sage/pull/38535
Reported by: David Coudert
Reviewer(s): cyrilbouvier