Variational formalism of general relativity