The following changes to your code will produce the desired graph:
- Change
GraphLayout
to "SpringElectricalEmbedding"
instead of Automatic
- Instead of using a list of symbols like
{A, C, G, T}
, use strings and concatenate them for the labels.
VertexSize
with a single value uses the same size for all vertices. Instead, use VertexShapeFunction
with a random disk radius to achieve the same effect.
The resulting code:
DeBruijnGraph[4, 2,
EdgeShapeFunction -> "Line",
GraphLayout -> "SpringElectricalEmbedding",
VertexLabels -> Table[i -> Row@RandomChoice[{"A", "C", "T", "G"}, 2], {i, 20}],
VertexShapeFunction -> ({Opacity@0.5, Blue, Disk[#, RandomReal[{0.05, 0.2}]]}&)
]

If you want to get perfect circles for the self-loops, it might be easier to use the older GraphPlot
instead of the newer Graph
-style functions.
adjMatrix = AdjacencyMatrix@DeBruijnGraph[4, 2];
With[{vertexLabels = Table[i -> Row@RandomChoice[{"A", "C", "T", "G"}, 2], {i, 20}]},
GraphPlot[adjMatrix,
SelfLoopStyle -> All,
Method -> "SpringElectricalEmbedding",
MultiedgeStyle -> 0.2,
PlotStyle -> Lighter@Orange,
VertexRenderingFunction -> Function[{center, label},
With[{radius = RandomReal[{0.05, 0.2}]},
{Opacity@0.5, FaceForm@Blue, EdgeForm@Black, Disk[center, radius],
Black, Text[label /. vertexLabels, center + Min[1.75 radius, 0.25] {Cos[Pi/4], Sin[Pi/4]}]}
]
],
VertexLabeling -> True,
PlotRangePadding -> None
]
]
