First, we show that the determinant of a given matrix can be expanded by its principal minors together with a set of arbitrary parameters. The enumeration of Hamiltonian cycles and paths in a graph is then carried out by an algebraic method. Three types of nonalgebraic representation are formulated. The first type is given in terms of the determinant and permanent of a parametrized adjacent matrix. The second type is presented by a determinantal function of multivariables, each variable having domain 0, 1. Formulas of the third type are expressed by spanning trees of subgraphs. When applying the formulas to a complete multipartite graph, one can easily find the results.