Issue with displaying a tree graph after deleting a vertex

I think this might be a bug in Mathematica's VertexDelete, or maybe the "LayeredEmbedding" GraphLayout.

To work around it, use Graph[VertexDelete[...], GraphLayout -> "SpringElectricalEmbedding"].

Alternatively, use IGExpressionTree[..., GraphRoot -> Automatic]. The problem has to do with the GraphRoot option, which here is meant to ensure that the tree is drawn with the correct root. You can ensure the correct root in another way:

g = IGExpressionTree[{{{1, 2}, {{3, 4}, {5, 6}}}, 7}, 
  VertexLabels -> "Name", GraphRoot -> Automatic, 
  GraphLayout -> {"LayeredEmbedding", "RootVertex" -> {}}]

This has a problem too, unfortunately: applying IndexGraph to the result won't render in Mathematica 11.3 and earlier as the vertex name for the root vertex was hard coded. In v12.0, this is no longer a problem, so perhaps I should change IGraph/M to use this method in M12.0+.


vc = AssociationThread[VertexList @ g, GraphEmbedding @ g]; 
SetProperty[VertexDelete[g, _?(VertexOutDegree[g, #] == 0 &)], 
  VertexCoordinates -> {v_ :> vc[v]}]

also works (per amator2357's confirmation in the comments).