In this paper, we formulate and investigate a generalized consensus algorithm which makes an attempt to unify distributed averaging and maximizing algorithms considered in the literature. Each node iteratively updates its state as a time-varying weighted average of its own state, the minimal state, and the maximal state of its neighbors. In Part I of the paper, time-dependent graphs are studied. This part of the paper focuses on state-dependent graphs. We use a μ-nearest-neighbor rule, where each node interacts with its μ nearest smaller neighbors and the μ nearest larger neighbors. It is shown that μ+1 is a critical threshold on the total number of nodes for the transit from finite-time to asymptotic convergence for averaging, in the absence of node self-confidence. The threshold is 2µ if each node chooses to connect only to neighbors with unique values. The results characterize some similarities and differences between distributed averaging and maximizing algorithms.