# Graph with a special condition

The graph $$H_n$$ whose vertex set consists of $$n$$-lists formed by elements on the set $$\{ 0,1,2 \}$$. There is an edge between two vertices if and only if two $$n$$-lists differ in exactly one position. I am asked to find how many edges are there in this graph. I have made an attempt, but I obtained such a simple answer that I still cannot believe this can be true. Here is my approach:
To begin with, given two $$n$$-lists, one has to see in which position do they differ: there are $$n$$ positions. Now, one has to count the different pairs of numbers that differ: there are $$3$$ possible pairs. Once counted that, it still remains to see how many $$n-1$$ lists are there using the three numbers (take into account that for both lists, the remaining positions are identical): $$3^{n-1}$$. Using the product rule, one obtains: $$3\cdot n\cdot 3^{n-1} = n\cdot 3^n$$. Is this right?

Yes, this is correct, if you want you can check it using the handshake lemma, that says that $$\sum _{x\in V}deg(x)=2|E|,$$ and is clear that fixed $$x$$ a vertex in your graph, you have that $$deg(x)=2\cdot n$$ because you fix the position they differ and you have two options to place a different number in the position you have chosen, because $$|V|=3^n$$ you get that $$3^n\cdot 2\cdot n = 2\cdot |E|,$$ which is what you get.