I meant for when we hit the query for second time it would remove the relationship. And hitting the query again it will create the relationship. What's here I am not able to understand why is it returning 2 instead of 1?
I don't understand how that's supposed to work, the last MATCH won't match unless there are two :LIKES relationships between the nodes, I don't think this is doing what you think it's doing. Also, there's no way two separate nodes would have the same graph id. I think you probably put that in as a placeholder.
This would work instead.
MATCH (u:User), (p:Post)
WHERE id(u) = 123 AND id(p) = 456 // better to lookup by property instead
MERGE (u)-[r:LIKES]->(p)
ON MATCH SET r.toDelete = true
WITH r
WHERE r.toDelete // which is only set to true when we matched to an existing relationship
DELETE r