Knowing what is safe is what's not is such a tough call. I prefer to limit my boys' interactions to mostly dogs close to their size. One exception is our neighbor's Collie. He is the gentlest, relaxed dog, and I trust his human completely. She is an advanced dog trainer.
I have learned to be on guard even with smaller dogs. Puppies usually want to paw at my boys' faces. Not good with their sharp nails! We have some crazy mini Doxies nearby who acted like they wanted to latch onto my boys' faces, bite.
Max was friends with a Westie, but at some point they started challenging each other. Whenever you see the dogs go nose to nose, locking eyes, they are challenging one another. Tail wagging can be a battle flag too, not always a sign of happiness.
Ears down and back can be a sign of deference or fear.
I wouldn't be comfortable with my boys running free with big dogs. Too much risk for an unintended accident.
My boys always love other Yorkies.