It's the network that is compromised. If you operate enough exit and relay nodes, you can be pretty damn well sure of where the traffic originated.
Anonymity hinges on the nodes, if an entity controls most of the nodes then the network is pretty much an effective honeypot.
Given that the FBI has been incredibly vocal about their efforts to take down Tor, and the fact that it is synonymous with illegal activity (drugs and child porn); operating enough nodes to investigate and bust criminals seems right up their alley.
[1] https://gitweb.torproject.org/torspec.git/blob/HEAD:/path-sp...
It also doesn't prevent owners of relay nodes from construing the origin of traffic. It may not be as accurate assuming the user routes their traffic through uncompromised entry/exit nodes, but given the resources certain agencies have they can cross reference ISP etc traffic logs to determine the identity of tor users.