I would happily friend fellow grad students. (I'm already adding potential peers I met at a welcome event.) But I would never add anyone who was currently grading me or I was currently grading. That just wouldn't smell right.
Basically, this means you have to be extra careful when you join sites that import your e-mail contacts to find relevant users.
If I am very close to a professor, I might add them once I'm well out of their classes. This has worked for me so far in undergrad. If I wasn't sure it would be okay, I'd either refrain or, if for some reason I really wanted to add them, I'd check to see if they're friends with any other students. Same policy applies with administrative officials.
Generally, if I socialize with someone, I add them on Facebook. But if we mainly have a working, professional relationship, LinkedIn is more appropriate and respectful of boundaries. But there is some cross-over, of course.
I'm the most relaxed when following people who post publicly on Twitter. People in my field tend to focus on posting relevant news and events, so there's usually no harm in following and it's a good, casual way to stay in touch.