A Characterization of Markov Equivalence Classes for Directed Acyclic Graphs with Latent Variables