Retaining vertex labels

Hello,
With

g = Graph[{"alice" -> "bertram", "carl" -> "bertram"}, VertexLabels -> "Name"]

I get a graph with meaningful labels but with

LayeredGraphPlot[g, VertexLabeling -> True]

the labels are replaced with 1,2,3. How can I keep my names for the vertices as names rather than indices?

Mathematica had a set of functions for graph plotting before it had the Graph[] data type. So now we have two separate and slightly different ways to visualize graphs. LayeredGraphPlot is one of the older set.

If you use the new method, then the names will be retained. You just need to set the GraphLayout option:

SetProperty[g, GraphLayout -> "LayeredEmbedding"] // Show

I used Show as a workaround for the cut off labels around the edges, otherwise it’s not necessary. What it does is that it converts the graph to graphics.

thx, that works for me