Ok, I understand. Thanks for the follow up.
You can also try a reward system. Each day she doesn't give a hug to someone in public, she gets a predetermined reward. It can be anything you both agree is fun and exciting to her, and that you feel would be a good motivator for her.
Also, try sending her to school with something she can substitute for hugs. Maybe a small stuffed animal (if it's ok with the school teacher), or something with good textile sensation, like a fuzzy key chain. Let her know that each time she feels the need to hug, she is to use this item to distract herself.
Both of these techniques are based in behavior modification and should work if your daughter's problem is behavior based.
If all else fails and you see no progress within the next few months, have your daughter see a child therapist for an evaluation. My bet is that this behavior can either be redirected or she will grow out of it. However, there may be a small chance there is something else going on here. With the lack of other symptoms, I highly doubt it, but it can't hurt to rule it out. What matters here is what your daughter feels like if she doesn't hug. The concern is that it has turned into a compulsion and in that case, a therapist can be a big help in solving her problem. Her doctor or your local community mental health facility can provide referrals if you need one.
You are doing what you can at this point so try not to worry. Most children at that age are more forgiving of others' behavior differences than at later ages so by the time the problem works itself out, the behavior will be long forgotten by her classmates.