Define return values for a function that is not of type Boolean

I have a function with more than two possible return values.

A simplified example is the following function that classifies vertices of a graph according to their degrees:

VertexRole[g_, v_] := Which[
VertexDegree[g, v] == 2, MediocreVertex,
VertexDegree[g, v] == 3, GoodVertex
]


However, defining the function in this way would be bad practice since the symbols BadVertex etc. are undefined. Furthermore, I want to evaluate expressions such as

VertexRole[graph, vertex] == BadVertex


Defining BadVertex to be a number (e.g. 42) would also be bad since I actually want

BadVertex == x


to evaluate to False for all x other than BadVertex.

Therefore BadVertex etc. should be symbols similar to True, False, Automatic, All, None. How can I implement that?

[One could use a string as the return value (e.g. "BadVertex"), but that kind of misses the syntactical point I am trying to make. I am rather looking for something that resembles the enum type in C.]

• Why do you think using undefined symbols is a bad practice? Jul 4 '16 at 15:10
• Why not output a string or some number that encodes your desired output if you insist on not making new symbols? Jul 4 '16 at 15:18
• @happyfish Because undefined symbols are not Protected. Jul 4 '16 at 15:18
• @Deniz No, user defined symbols are not protected unless you do it manually. You can also protect a undefined symbol, if you are referring undefined as not having own values, down values , etc. Jul 4 '16 at 15:22
• Rather than repeated evaluation of VertexDegree[g, v] you might want to consider using Switch Jul 4 '16 at 17:15

• manually Protect those symbols on the off chance that for some reason I accidentally assigned them values (though this is not necessary for them to work),
• assign them ::usage messages so they register correctly into the system (and therefore display in black instead of blue, and
• use === (i.e. SameQ) instead of == (i.e. Equal) if I wanted to make it very explicit that "BadVertex == x should evaluate to False for all x other than BadVertex".
• One might sometimes consider using MatchQ[] instead of ===, but that depends on the application. Jul 4 '16 at 17:19