Learning graphical models from the Glauber dynamics