Finite, undirected graphs without self-loops are considered in the paper. The goal is to find a protocol for local computation which, starting with a uniform labelling of graph nodes, eventually terminates with a labelling being an enumeration of nodes. It is known from (Litovsky et al., 1993) that for some ( ambiguous ) graphs of the considered family such a protocol does not exist; in the present paper a protocol is constructed which is the best in the sense that, for a given graph, it either enumerates nodes of the graph, or supplies a proof of ambiguity of the graph. It is proved that for any graph there exists a computation terminating with any a priori given enumeration of its nodes. It is also proved that after successful termination individual nodes know this fact. The proposed protocol can be used for election a leader out of nodes of graphs; in this way it generalizes existing algorithms. The protocol is called distributed, since remote nodes of the processed graph can communicate only by sending messages.