# Is it possible to make more room in a graph layout for my VertexRenderingFunction?

Consider the graph produced by:

M = {{0, 0, 1, 0}, {1, 0, 0, 1}, {1, 1, 0, 0}, {0, 1, 0, 0}};
GraphPlot[M, DirectedEdges -> True,
VertexRenderingFunction -> ({EdgeForm[Black], LightRed,
Disk[#1, {.7, .1}], Black, Text[Subscript["C", #2], #1]} &)]


Is it possible to tweak the layout so that more room is left around the vertices for use by the VertexRenderingFunction? (I want to be able to put more text in each of the labels.)

-

Generally I'd recommend using Graph instead of GraphPlot. One way to solve your specific problem is to affect VertexCoordinates to scale your graph:

M = {{0, 0, 1, 0}, {1, 0, 0, 1}, {1, 1, 0, 0}, {0, 1, 0, 0}};
Manipulate[ AdjacencyGraph[M, DirectedEdges -> True, VertexShapeFunction ->
({EdgeForm[Black], LightRed, Disk[#1, {.7, .1}], Black,
Text[Subscript["C", #2], #1]} &),  VertexCoordinates -> scale
AbsoluteOptions[AdjacencyGraph[M], VertexCoordinates][[2]]], {{scale, 2}, .1, 3}]


-
Much cleaner, thanks! I had to dig a bit to figure out what scale was multiplying, but it was worth it! –  Kaelin Colclasure May 2 '12 at 0:51
The arrows between nodes C2 and C4 are reversed ... is this a bug in the graph layout? –  StackExchanger May 6 '12 at 5:41

This does the job in a rather brute-force manner:

stretch = {1.5, 1};
GraphPlot[M,
EdgeRenderingFunction -> ({Black, Line[Map[#*stretch &, #1]]} &),
VertexRenderingFunction -> ({EdgeForm[Black], LightRed,
Disk[#1*stretch, {.5, .1}], Black,
Text[Subscript["C", #2], #1*stretch]} &)]


The downside is you have to do both edge and vertex rendering. I'll leave this question open, hoping someone has a better solution.

-

How about changing the AspectRatio?

M = {{0, 0, 1, 0}, {1, 0, 0, 1}, {1, 1, 0, 0}, {0, 1, 0, 0}};
GraphPlot[M, DirectedEdges -> True,
VertexRenderingFunction -> ({EdgeForm[Black], LightRed,
Disk[#1, {.4, .1}], Black, Text[Subscript["C", #2], #1]} &),
AspectRatio -> 0.2]


-
Hmm, AspectRatio was the first option I tried, but my Mathematica (8.0.4 on Mac OS X) does not render it like you've shown here. Instead I just get a flatter version of the first diagram, with the ovals still overlapping. –  Kaelin Colclasure May 2 '12 at 0:26
yuck. The arrows coalesce to form a skewed 6pt star! –  R. M. May 2 '12 at 0:35