# Unable to export a formatted graph?

I'm looking to export a small graph in the documentation to a vector file, such that it's appearance doesn't change.

Originally, I wanted to use the following example from the doc page of AdjacencyList[] with a single tweak to the vertex label color. Why? Because I liked the spacing it had on its labels, as you can see:

So I evaluated the cell, hoping to then add options programmatically, but simply evaluating it made the nice vertex formatting go away:

Ok, so I stepped back and just tried to export it as-is to any (vector) format at all. First, I tried converting it to graphics with the right click menu, no luck:

Then I tried saving to a variety file types, but again nothing I exported looked anything like the original graph, for example:

Interestingly, I found out that Postscript isn't even supported (it is an option and is supposed to be):

Finally, I tried the file menu option for saving a selection, but this does nothing or fails silently!

I'm at a loss that such a simple thing is evading me.

• I think a better title would be less about the export and more about the formatting. In this case the Export is seemingly distinct from the problem, even though it is why you want the problem solved. – b3m2a1 Jan 21 '18 at 5:34

The easiest way to use vertex names as the image of the vertices is

CompleteGraph[5, VertexShapeFunction -> "Name"]


As you can see, the spacing is not great. The edges overlap with the vertices. When this happens, the first thing you should try is

CompleteGraph[5, VertexShapeFunction -> "Name",
PerformanceGoal -> "Quality"]


This almost always fixes this problem. The most common use case is directed graphs where part of the arrowhead overlaps with the vertex. But I also use it in this specific situation.

If you want to tweak the spacing further, use VertexSize.

CompleteGraph[5, VertexShapeFunction -> "Name",
PerformanceGoal -> "Quality", VertexSize -> Large]


• Do you know of a simple option to set the edges to use CapForm? – M.R. Jan 21 '18 at 19:12
• @M.R. CompleteGraph[5, VertexShapeFunction -> "Name", PerformanceGoal -> "Quality", EdgeStyle -> Directive[AbsoluteThickness[5], CapForm["Round"]], VertexSize -> 0.2] – Szabolcs Jan 21 '18 at 20:04
• Ah, I see the PerformanceGoal activates the CapForm. Thanks. – M.R. Jan 21 '18 at 20:18
• One more thing - how to make the endpoints equidistant from the glyph? Perhaps that's too big a question for a comment... – M.R. Jan 21 '18 at 20:24
• @M.R. If you want it equidistant from the center of each glyph (not their bounding box), then you can use something similar to CompleteGraph[5, VertexShapeFunction -> None, PerformanceGoal -> "Quality", VertexLabels -> Placed["Name", Center], VertexLabelStyle -> Large, EdgeStyle -> Directive[AbsoluteThickness[5], CapForm["Round"]], VertexSize -> 0.2]. A bonus is that you can control the glyph style using VertexLabelStyle. – Szabolcs Jan 21 '18 at 20:30

Graph formatting has changed recently. The Box form it used to have is no longer the one it has.

So the easiest thing to do is probably just to regenerate your graph with formatting:

CompleteGraph[5,
VertexShape -> Table[n -> Graphics[Inset[Style[n, Black]]], {n, 5}],
VertexSize -> .25,
ImageSize -> 100
]


Szabolcs would know better than I, though, as to how to get that type of white-space without such fine-tuning

• Thanks! How did you find this out? – M.R. Jan 21 '18 at 5:34
• The box formatting thing? I've just looked at a bunch of the box structures when I tried to implement a click-and-drag format-able graph. Noticed that most of them in the documentation notebooks are different from the box structures that are spit out now. – b3m2a1 Jan 21 '18 at 5:35
• With this new syntax, is there an easy way to get the edge lines to have CapForm["Round"], without extracting them and using EdgeShapeFunction? – M.R. Jan 21 '18 at 5:47
• When the vertices overlap with the edges, the usual fix is PerformanceGoal -> "Quality". I learned it from @halmir. – Szabolcs Jan 21 '18 at 15:55
• @M.R. I think you should un-accept this answer in favor of Sabolcs'. His is definitely less fine-tuned. – b3m2a1 Jan 21 '18 at 23:09