# Displaying Vertex indices in different colour than vertices

graph1 = SetProperty[graph1, VertexLabels -> Table[i -> Placed[{Style[i, Blue],
Style[PropertyValue[{graph1, i}, VertexIndex], Red]}, {Before, After}],
{i, VertexList[graph1]}]]


does not display the indices in Red (gives an error).

is there a way to fix this?

This question is related to: Graphs: colouring vertex weights differently from vertices

Try

graph1 = SetProperty[graph1,VertexLabels->Table[i->Placed[
{Style[i,Blue],
Style[VertexIndex[graph1,i],Red]}
,{Before,After}],{i,VertexList[graph1]}]]


It turns out PropertyValue is being replaced by AnnotationValue. Even so, calling AnnotationKeys[{graph1,First@VertexList[graph1]}] shows that a graph vertex has the following inbuilt annotations (formerly properties)

{VertexCoordinates,VertexShape,VertexShapeFunction,VertexSize,VertexStyle}


VertexIndex is a function on graphs just like VertexList, vertices do not store their index.