I've been on both sides of this, i've had the annoying dogs tagging along, and i've also had to shout at people to please stop walking so i can get my dog back.
(i got a right mouthful about training my dogs from that lady, 'fraid i got rather stroppy with her and explained that i was TRYING to and that she wasn't helping.
) When other dogs follow me i tend to follow the owners lead, if they ignore it so will i, but if they're trying and struggling to get them back then i'll stop and wait.
I've also had ownerless dogs follow me, one followed me all the way (along roads!) to my friends house so we called the dog warden, the other one i followed and it went home to a bloke stood in his garden waiting for it, seems he lets his dog out unattended to go and crap on the field.
next time i see it i'm taking it home to call the dog warden, serves the owner right.