As a police officer, I don't shake hands with the vast majority of the folks I deal with at work. I'm not an absolutist about this tactic, and don't have problems shaking hands with those folks I've judged to be "normal" (ie: most burglary victims, etc).
Because of my work habits, I've found myself less inclined to shake hands outside of work. I'll certainly do so in social settings, or when being introduced to someone, or conducting business with a person. But, my inclination to shake hands with a person on the street isn't so high. I was also raised in an environment where real men shook hands, and it was considered an insult not to. However, the streets aren't where the real men are found!
As others have mentioned, an untimely and unsolicited handshake from a stranger on a big city street could mean a few things. I'd break these down as follows:
1) Nothing... not likely when a stranger approaches for no obvious reason and wishes to shake your hands.
2) A precursor to an attack... This is certainly possible, but not necessarily the most likely outcome.
3) To slow you down, engage you, and drive you to interact with that person... A classic panhandler's tactic, and I see it on a daily basis with the bums in my precinct.
4) A start to a non-violent criminal scam (pick-pocketing, etc)... likelihood often depends on where you are in the world.
Avoiding handshakes in the street-bum situations is often my preference, though many folks just go along with it. To avoid the handshake, consider a few tactics:
1) Ignore the extended hand, look the person in the eye, and give a simple "Can I help you?" response. They'll state their case, and you'll respond by saying that you're busy, not interested, etc.
2) Tell them you have the flu, and don't want to get them sick.
3) Tell them you don't need anything, and go on about your business.
Here is rule of thumb. If a guy comes to you with an extended hand straight off the get go. Dont Shake. If you have been talking to the guy for a short period of time and he either goes to introduce himself or the conversation has ended and the Hand is extended. It should be OK to shake.
I was about to add a drawn out explanation of this point when I noticed that someone had already stated it more simply than I could have. This is good advice for on-street encounters! Obviously things are quite different in a business environment, etc.