1
$\begingroup$
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

$\endgroup$
1
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.