Given an ordering τ=(v1,v2,...,vn) on the vertices in V, we associate a map fτ:V→Z as follows: fτ(v) is equal to the number of vertices in V that are ordered preceding v. We claim that fτ is good.
Each edge is counted exactly once in ∑v∈Vfτ(v), for an edge e∈E with vertices u,v∈V such that u is ordered before v in τ; then e is counted once in fτ(v). Thus,
v∈V∑fτ(v)=∣E∣.
For any nonempty subset A⊆V of all red vertices, choose v∈A with the most preceding orderings in τ. Then by definition, fτ(v) is not greater than the number of vertices adjacent to v that are not colored into red. We have verified that fτ is good.
Conversely, given any good map f:V→Z, we claim that f=fτ for some ordering τ of V.
First, let the red vertex set A=V. By the condition (2) in the problem, there exists v∈A such that f(v)≤0, and denote one of such vertices by v1. Assuming that we have already chosen v1,...,vk from V, if k<n, set the red vertex set A=V−{v1,...,vk}. By the condition (2) in the problem, there exists v∈A such that f(v) is less than or equal to the number of vertices in {v1,...,vk} that are adjacent to v. Denote one of such vertices by vk+1. Continuing in this way, we order the vertices by τ=(v1,v2,...,vn). By the construction we have f(v)≤fr(v) for any v∈V. By the condition (1) in the problem, we have
∣E∣=v∈V∑f(v)≤v∈V∑fr(v)=∣E∣,
and therefore f(v)=fr(v) for any v∈V.
We have shown that for any ordering τ, fr is good, and any good map f is fr for some τ. Since the number of orderings on V is n!, we see that m(G)≤n! (note that two distinct orderings may result in the same map).
Next, we prove that n≤m(G). Assume at the moment that G is connected. Pick arbitrarily v1∈V. By the connectivity, we may choose v2∈V−{v1} such that v2 is adjacent to v1, and again we may choose v3∈V−{v1,v2} such that v3 is adjacent to at least one of v1,v2. Continuing in this way, we get an ordering τ=(v1,v2,...,vn) such that vk is adjacent to at least one of the vertices preceding it under ordering τ, for any 2≤k≤n. Thus, fr(v1)=0 and fr(vk)>0 for 2≤k≤n. Since v1 may be arbitrary, we have at least n good maps.
In general, if G is a union of its connected components G1,...,Gk, since each vertex is adjacent to at least another vertex, each component has at least two vertices, denote by n1,...,nk≥2 the number of vertices of these components. For each Gi, we have at least ni good maps on its vertices, i=1,...,k. It is easy to see that patching good maps on Gi's together results in a good map on G, and thus
m(G)≥n1n2⋯nk≥n1+n2+⋯+nk=n.
We conclude that n≤m(G)≤n!.