When do deadlocks occur?
All 4 conditions must be satisfied at the same time.


Hold and Wait
Non-preemption of resources
Mutual Exclusion
Circular wait


In case of single instance of resources: 

Cycle in resource allocation graph represents deadlock.

In case of multiple instance of resources: 

Cycle in RAG doesn't mean deadlock. 
You must check in the same way as you did. Let me write clear steps.


We need to identify a process, in the cycle, which can execute without any dependency and execute that.
Release the resources held by process. 
Next check the process which has all the resources to execute and execute completely and release the resources held by it.
Keep doing till all the processes are executed. 
If you can't execute all the processes this way, then there is deadlock.


Hope that helps!