Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Mathematica 9, a graph is returned as an object with head Graph:

In[1]:= CompleteGraph[8] // Head
Out[1]= Graph

Right-clicking on a Graph object brings a menu with the option "Convert to Graphics". Selecting this option returns a new object which has head Graphics. I need to do this programmatically, but I haven't found any command that, applied to CompleteGraph[8] (to put an example), returns an object with head Graphics, with a plot of the graph.

Is there a command in Mathematica to convert a Graph to a Graphics?

share|improve this question
up vote 22 down vote accepted

Well, just after I had posted the question, I found a very simple way to do it:

In[1]:= Show[CompleteGraph[8]] // Head
Out[1]= Graphics
share|improve this answer

Contextual menu bindings are defined in the file here:

  "SystemFiles", "FrontEnd", "TextResources", ""}]

Examining the contents of that file, you can discover that the "Convert to Graphics" contextual menu item maps to the Mathematica command GraphComputation`GraphConvertToGraphics. Thus, for example,

  Graph[{1 -> 2, 2 -> 3, 3 -> 1}]] // Head

(* Out: Graphics *)

I actually prefer your Show technique, which is more natural and more likely to remain stable between versions, but it is nice to know how to find what commands these contextual menu items map to.

share|improve this answer
+1 Thanks. I imagine that Show probably calls GraphConvertToGraphics internally. – becko May 11 '13 at 16:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.