If it was me and I stumbled into my ex (thankfully it probably won't happen to me as we have no common friends and not in same workplace or uni) I would act really friendly and bubbly to show I have moved on and am in a really good place. Wouldn't go out of my way to initiate a convo but if there was one I would just talk about general stuff, what I have been up to, what subjects I am taking this semester etc and just show some general interest in him, how's the family etc.
Just act natural and friendly or if you are not on friendly terms with him then just ignore him altogether. But usually the best thing is to show how much better off you are without him (even if you don't feel that way).
Some people are drains and some are radiators... Keep clear of the drains and hug the radiators!