EDIT: I adjusted the vertices to have labels that are integers (like the weights). Can the answer be adapted to this case?
I use simultaneous display of vertices and weights (this topic is related to another question posted here)
I display vertices via the following code (only included for completeness)
vf[{xc_, yc_}, name_, {w_, h_}] :=
Block[{xmin = xc - w, xmax = xc + w, ymin = yc - h, ymax = yc + h},
Polygon[{{xmin, ymin}, {xmax, ymax}, {xmin, ymax}, {xmax, ymin}}]];
The graph edges are specified as:
relations = {2 -> 6, 2 -> 7, 5 -> 6, 5 -> 7, 3 -> 2}
The following code has a part that colors the vertex labels red
labeling[relations_, weights_] :=
Graph[relations,
VertexCoordinates ->
ReflectionTransform[{0, -1}]@GraphEmbedding[Graph[relations]],
VertexLabelStyle -> Directive[Red, 15],
VertexWeight -> weights, VertexShapeFunction -> vf]
g = labeling[relations, {1, 2, 3, 4, 5}];
The vertices xi and their weights are simultaneously displayed by:
g = SetProperty[
g, {VertexLabels ->
Table[i ->
Placed[{i, PropertyValue[{g, i}, VertexWeight]}, {Before,
After}], {i, VertexList[g]}]}]
How can I display the weights in blue, but keep the vertices xi in red?
VertexLabelStyle allows me to set the colour red for vertex labels (displaying both vertices xi and their weigths red in the graph).
There is no VertexLabelStyle to set colours of weights (I believe).
I need to manipulate the weights and vertices separately in the graph, i.e. sometimes move the vertices (xi) which are to remain red and sometimes move the weights (integers) which need to remain blue.