# Draw a de Bruijn graph with random vertex size

I am trying to draw a graph that looks like below,

This the code I have so far,

DeBruijnGraph[4, 2, EdgeShapeFunction -> "Line", GraphLayout -> Automatic,
VertexLabels -> Table[i -> {RandomChoice[{A, C, T, G}],
RandomChoice[{A, C, T, G}]}, {i, 20}], VertexSize ->
RandomReal[0, 1],   VertexStyle -> Blue]


But I don't get a similiar graph above. Can someone give me a suggestion to graph it? Thanks

The following changes to your code will produce the desired graph:

1. Change GraphLayout to "SpringElectricalEmbedding" instead of Automatic
2. Instead of using a list of symbols like {A, C, G, T}, use strings and concatenate them for the labels.
3. 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}]},
SelfLoopStyle -> All,
Method -> "SpringElectricalEmbedding",
MultiedgeStyle -> 0.2,
PlotStyle -> Lighter@Orange,
VertexRenderingFunction -> Function[{center, label},
Black, Text[label /. vertexLabels, center + Min[1.75 radius, 0.25] {Cos[Pi/4], Sin[Pi/4]}]}
]
],
VertexLabeling -> True,

• @Silvia Good catch! I couldn't get it to work with EdgeShapeFunction but I knew it was possible using the older GraphPlot, so I've updated my answer with a perfect-circle self-loop version :) – rm -rf Nov 16 '15 at 5:40
• Then +1 :) (Totally forgot GraphPlot!) – Silvia Nov 16 '15 at 5:46