If it was just a guy hitting on her, I'd just make eye contact. Give a smiling nod and say hello, then based on her reaction either stay for a moment and chat or just be on my way. Just because a guy hits on her doesn't mean she's into it. If she's not, stay and chat for a bit to give her an "out" then be on my way when she's covered. If she's into it I'd still say hi, but just keep walking.
If she's with a new guy, make eye contact. Say hi, shake hands with both of them. Say bye and be on my way. I'm not into going out of my way to avoid people, but I'm also not into pretending to be happy to see exes with a new guy. Just keep it cool and cordial and show a level of character that you would be proud of irrespective of what she might think.
I would've acted like I never saw her. If she was very close and turned obvious we saw each other I would've approached her, smile say hi and salute the other guy, then leave. Giving the thumbs up is weird lol