Flexible Manifold Learning with Optimal Graph for Image and Video Representation