In this paper, the finite-time consensus for arbitrary undirected graphs is discussed. We develop a parametric distributed algorithm as a function of a linear operator defined on the underlying graph and provide a necessary and sufficient condition guaranteeing weighted average consensus in K steps, where K is the number of distinct eigenvalues of the underlying operator. Based on the novel framework of generalized consensus meaning that consensus is reached only by a subset of nodes, we show that the finite-time weighted average consensus can always be reached by a subset corresponding to the non-zero variables of the eigenvector associated with a simple eigenvalue of the operator. It is interesting that the final consensus state is shown to be freely adjustable if a smaller subset of consensus is admitted. Numerical examples, including synthetic and real-world networks, are presented to illustrate the theoretical results. Our approach is inspired by the recent method of successive nulling of eigenvalues by Safavi and Khan.