# Drawing finite-state automata without using VertexRenderingFunction

In the tutorial entitled "Hierarchical Drawing of Directed Graphs" in Mathematica 12, there is an example of how to draw a graph with several properties I want, but it uses an option called VertexRenderingFunction which is superseded by VertexShapeFunction:

LayeredGraphPlot[{1 -> 2, 2 -> 3, 3 -> 4, 4 -> 5, 5 -> 6, 6 -> 7,
7 -> 8, 8 -> 1, 1 -> 9, 2 -> 9, 3 -> 10, 4 -> 10, 6 -> 11, 5 -> 11,
7 -> 12, 8 -> 12}, Left,
VertexRenderingFunction -> ({EdgeForm[Black], Yellow, Disk[#1, 0.2],
Black, Text[#2, #1]} &)]


Since I'm trying to draw a finite-state automaton, I want a graph with directed arrows between nodes, where the nodes are circles containing a small number (the state number), as well as labels on the edges. I'm only trying to display acyclic automata at this point.

Trying to get VertexShapeFunction to do these things somehow suppressed the directed arrows; what is the proper way to do this? Ideally there would be the usual notations for the start state and final states as well. Thanks

You can use the default vertex shape (Disk) and use the option VertexLabels (that is, no need to use VertexShapeFunction):

edges = {1 -> 2, 2 -> 3, 3 -> 4, 4 -> 5, 5 -> 6, 6 -> 7, 7 -> 8, 8 -> 1,
1 -> 9, 2 -> 9, 3 -> 10, 4 -> 10, 6 -> 11, 5 -> 11, 7 -> 12, 8 -> 12};

LayeredGraphPlot[edges, Left,
VertexLabels -> Placed["Name", Center],
VertexStyle -> Yellow,
VertexSize -> Large] If you need to use VertexShapeFunction you can add the option PerformanceGoal -> "Quality":

LayeredGraphPlot[edges, Left,
VertexShapeFunction -> ({EdgeForm[Black], Yellow, Disk[#1, 0.2], Black, Text[#2, #1]}&),
PerformanceGoal -> "Quality"] Update: Using DiscreteMarkovProcess with Graph

dmp = DiscreteMarkovProcess[1, Graph[edges]];


Absorbing and transient nodes are automatically styled when dmp is used as the first argument of Graph:

g1 = SimpleGraph @ Graph[dmp,
GraphLayout -> {"LayeredDigraphEmbedding", "Orientation" -> Left}] You can change the style of any node (say, vertex 1) using SetProperty:

SetProperty[g1, VertexStyle -> {1 -> Red}] 