The matrix is simple - matched icons on the ports is a winning combination.
Video in requires matching cable and port on the sending mac. (If all don't match, it won't work.)
Display mirroring (where an iMac can receive video input) only works thunderbolt to thunderbolt or displayport to displayport and isn't backwards compatible where
The backwards compatibility between the formats only works when a displayport monitor will work whenis connected to a thunderbolt mac.