I'd say never hug a dog that's not yours, because it is a very invasive and even threatening kind of thing. And with dogs that are yours it'd depend on them personally. Right now I have a foster and he dislikes getting hugs, loves cuddles but no hugs. My first foster however loved all attention and handling, he would initiate lots of physical affection any second I stopped moving. Sorry for such a non-conclusive answer, but yeah "it depends" is my experience so far.