Color Specified Vertices in LayeredGraphPlot
You can use the option "Orientation"
with "LayeredDigraphEmbedding"
layout:
Graph[edges,
GraphLayout -> {"LayeredDigraphEmbedding", "Orientation" -> Left},
VertexSize -> .6,
VertexLabelStyle -> 16,
VertexStyle -> {_ :> Directive[White, EdgeForm[Darker[Blue]]], S -> Red, T -> Green},
VertexLabels -> Placed["Name", Center],
EdgeStyle -> Directive[Black, Arrowheads[{{0.03, .8}}]],
ImageSize -> Large]
Alternatively, wrap the desired vertices with Style
Graph[VertexList[edges] /.{S -> Style[S, Red], T -> Style[T, Green]}, edges,
GraphLayout -> {"LayeredDigraphEmbedding", "Orientation" -> Left},
VertexSize -> .6,
VertexLabelStyle -> 16,
VertexStyle -> Directive[White, EdgeForm[Darker[Blue]]],
VertexLabels -> Placed["Name", Center],
EdgeStyle -> Directive[Black, Arrowheads[{{0.03, .8}}]],
ImageSize -> Large]
same picture
In the specific case requested, by writing:
edges = {S -> R9, S -> R4, S -> R1, R1 -> R2, R2 -> R3, R3 -> R4,
R4 -> R5, R5 -> R6, R6 -> T, R9 -> T, T -> S};
color = ConstantArray[RGBColor[1, 1, 1], 150];
fct[t_] := color[[Total[ToCharacterCode[ToString[t]]]]]
fct[S] = LightRed;
fct[R9] = LightBlue;
LayeredGraphPlot[edges, Left, VertexLabeling -> True,
EdgeRenderingFunction -> ({Black, Arrowheads[0.03],
Arrow[#1, 0.4]} &),
VertexRenderingFunction -> ({fct[#2], EdgeForm[Darker[Blue]],
Disk[#, .4], Black, Text[#2,#1]}&)]
I get:
which is what is desired.
Wanting to satisfy the needs requested in the comments, by writing:
edges = {S -> R9, S -> R4, S -> R1, R1 -> R2, R2 -> R3, R3 -> R4,
R4 -> R5, R5 -> R6, R6 -> T, R9 -> T, T -> S};
colorules = {{"S", "T", LightRed},
{"R1", "R3", "R5", "R9", LightBlue},
{"R2", "R4", "R6", LightGreen}};
fct[t_] := Last[colorules[[Position[colorules, ToString[t]][[1, 1]]]]]
LayeredGraphPlot[edges, Left, VertexLabeling -> True,
EdgeRenderingFunction -> ({Black, Arrowheads[0.03],
Arrow[#1, 0.4]} &),
VertexRenderingFunction -> ({fct[#2], EdgeForm[Darker[Blue]],
Disk[#, .4], Black, Text[#2,#1]}&)]
I get:
which is what is desired.