My lecturer in homological algebra, Hal Schenck, has some advice on this http://www.math.uiuc.edu/~schenck/grad.html (item II in the list). I quote the relevant paragraph:
"1) Compatibility.
It is really important that you and your advisor get along well; grad school is difficult enough without having a chilly (or worse, hostile) relationship with your advisor. The best time to figure this out is BEFORE you ask someone if they'll work with you. One way to determine this is by taking a course with the person, and seeing how you interact when you go to office hours to ask questions. It goes without saying that you should make sure you do a good job in the class, because if you do poorly, it is likely that the potential advisor will not be interested in taking you on as a student.
2) Track record and reputation.
It is important that your advisor be respected as a scholar. You will quickly find that one of the first questions mathematicians ask a graduate student is: "and who is your advisor?". You may also want to find out how many theses the professor has directed, and how many students have dropped out (this should be done tactfully, of course, by talking to former students or the director of graduate studies).
3) Good thesis topic.
Most professors supervising dissertations have a set of problems that they think might make an appropriate thesis; you should ask about this, 'cause getting a bad problem can cause you to waste years of your life."