Deadlock detection and recovery occurs after system into deadlock situation. Resource allocation graph (RAG) is used as deadlock detection algorithm.
For single instance type resources when a cycle exists in the resource allocation graph then deadlock situation occurred otherwise no deadlock.
For multiple instances type resources when a cycle exists in the resource allocation graph then deadlock may occurred, then Banker's algorithm to check that deadlock is occurred or not. If there is no cycle exists in the resources allocation graph (RAG), then is no deadlock in the system.