Yes, you are right. But now that I am thinking about it more I realize that the problem is not too interesting. Let me make it a little more complicated
Let's say you have 4 nodes with
bidirectional edges as shown in the image.
You are at node 1 and your goal is to visit all of the nodes. So, for example, you could take this path:
1 2 1 4 3
or
1 4 3 4 1 2
Further, let's say I want to omit printing the node that I have already visited. So, for the above two routes, I will print:
1 2 4 3
and
1 4 3 2
Now, between the above two sequences, the first sequence 1 2 4 3 is preferable to the second one 1 4 3 2 because 1 2 4 3 is is smaller (if compared lexicographically as a whole) .