# Vertices, their labels, and how to refer to them?

In the examples I have seen, graph vertices in Mathematica are usually explicit small integers. However, Wolfram documentation says that vertices can be any arbitrary expression (eg., george, x^2, London, 5).

Nevertheless, it seems that vertices are always referred to by number, that is, by the position of the vertex expression in VertexList[gr]. This can be confusing. For example, if I build a graph like this, using nonconsecutive vertex numbers,

Graph[1<->2, 2<->10, 10<->3, 3<->4]


then I still have to refer to the vertices as if I had made each vertex number equal to its creation order, as if I had built the graph with strictly consecutive vertex numbers:

Graph[1<->2, 2<-3 ,3<->4, 4<->1]


Am I understanding this correctly?

g1 = Graph[{1 <-> 2, 2 <-> 10, 10 <-> 3, 3 <-> 4}, VertexLabels -> "Name"]

g2 = Graph[{1 <-> 2, 2 <-> 10, 10 <-> 3, 3 <-> 4},

• But if I write: codeg1 = Graph[{1 <-> 2, 2 <-> 10, 10 <-> 3, 3 <-> 4}, VertexLabels -> "Name"]; GraphPlot[g1,VertexLabeling->True] then the result uses only the digits 1 through 8. That is, at the very least, confusing, don't you think? Jul 12, 2012 at 17:24