So it seems that determining whether an edge is in a minimum spanning tree can be reduced down to the question of whether the edge is the heaviest edge of some cycle. I know how to detect whether an edge is in a cycle, using DFS, but how to determine whether it's the heaviest edge in that cycle? Is it by just finding the cycle and picking the heaviest edge in it?
Assuming that all the edges have distinct weights, a simple and fairly elegant algorithm for doing this would be to do a modified DFS. Notice that if this edge is the heaviest edge in some cycle, then if you were to look at the graph formed by deleting all edges heavier than the current edge, there must be some path from the endpoint of the edge back to the start of the edge, because this path, combined with the edge itself, forms a cycle with the given edge being the heaviest such edge. Conversely, if there is no cycle containing the edge for which the given edge is the heaviest, then if you were to do a search in this graph from the end of the edge back to the source, you wouldn't be able to get back to the source of the edge, since otherwise you could complete it into a cycle. This gives the following simple algorithm: do a DFS in the original graph from the endpoint of the edge back to the source, but whenever you encounter an edge that is heavier than the original edge, don't process it (this simulates deleting it from the graph). If your DFS takes you from the end of the edge back to the source, then you know that there must be some cycle for which the edge is the heaviest edge, and if there is no such cycle then you won't be able to get back to the source of the edge.
In the case where the edges aren't distinct, you would do the same search as above, but you would delete all edges whose weight was greater than or equal to the weight of the current edge. The reason for this is that if there is a path from the end of the edge to the start of the edge in this transformed graph, you know for a fact that we didn't end up using any edges that have the same cost as the original edge, so any path found can be completed into a cycle where the given edge is the heaviest. If there is no path, then either
In either case, it's not the heaviest edge in the cycle.
The runtime of this algorithm is O(m + n), the time required to do a standard DFS.
Hope this helps!