Causal Graphical Models with Latent Variables: Learning and Inference