[LockingDependencyAnalyzer] Ensure vertex exists before detaching it

Closes https://github.com/CocoaPods/CocoaPods/issues/2779.