What is the difference (in purpose) between Graph and GraphPlot? Which function is bested suited to which tasks?

Background: I just spent the last two hours trying to make this graph readable:

trans = Uncompress@
Graph[DeleteDuplicates@trans, VertexLabels -> Placed["Name", Center], 
 VertexShapeFunction -> "Capsule", VertexSize -> 1, 
 VertexLabelStyle -> Large, 
 EdgeShapeFunction -> 
  GraphElementData["ShortUnfilledArrow", "ArrowSize" -> 0.02]]


Then I discovered that GraphPlot produces much more readable results:

 DeleteDuplicates@trans /. (DirectedEdge[a_, b_] -> Rule[a, b]), 
 VertexLabeling -> True, DirectedEdges -> True]


which prompted me to wonder: what's the point of Graph?

Of course I noticed this, while related, which asks about the Combinatorica package.

  • 3
    $\begingroup$ Graph is not simply a way to plot graphs. It is a whole new data type on which you can perform lots of operations. It just happens to be displayed as its visualization. $\endgroup$
    – Szabolcs
    Commented Jun 4, 2012 at 18:38

1 Answer 1


First of all Graph is more recent functionality. Now try this:

GraphPlot[{1 -> 2}] // Head


and then this

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


Basically while GraphPlot and GraphPlot3D both return pure graphic objects, Graph returns true graph which contains all information about the graph and can be computed with. For example:

 AdjacencyMatrix[g] // Normal

{{0, 1}, {0, 0}}

Because they can be computed with, there is wide functionality built around Graph objects which GraphPlot does not have - from graph theory to visualization and styling.

Also to get more feel for the difference you can try AtomQ, which is the function that yields True if expression cannot be divided into subexpressions, and yields False otherwise, - as paraphrased from form Documentation Center.



Compare with

 AtomQ[GraphPlot[{1 -> 2}]]


Which can be also hinted from:

 g // InputForm

Graph[{1, 2}, {DirectedEdge[1, 2]}]

and this:

 GraphPlot[{1 -> 2}] // InputForm

Graphics[Annotation[GraphicsComplex[{{1., 0.}, {0., 8.979318433952318*^-11}}, {{RGBColor[0.5, 0., 0.], Line[{{1, 2}}]}, {RGBColor[0, 0, 0.7], Tooltip[Point1, 1], Tooltip[Point2, 2]}}, {}], VertexCoordinateRules -> {{1., 0.}, {0., 8.979318433952318*^-11}}], FrameTicks -> None, PlotRange -> All, PlotRangePadding -> Scaled[0.1], AspectRatio -> Automatic]

Good thing to know is that built-in GraphData return Graph object on default:

GraphData /@ GraphData["Hypotraceable"]

enter image description here

And another cool consequence of the above is that you can even copy and paste the visual representations returned by Graph and compute them:

enter image description here

Besides GraphData there are many other functions that return Graph objects, such as CompleteGraph, GraphComplement, CayleyGraph, Subgraph and so on.

Another thing to know is that Graph objects have their own right-click menu alowing one to deal with the graph interactively (sample workflow is shown below):

GraphData["IcosahedralGraph", "LineGraph"]

enter image description here

  • 8
    $\begingroup$ LayeredGraphPlot still often produces much better results than the equivalent Graph-based solution. Fortunately GraphPlot does work with Graph objects---you might want to mention this! $\endgroup$
    – Szabolcs
    Commented Jun 4, 2012 at 18:40
  • $\begingroup$ @Szabolcs Yes, thanks, I surely will add more info, - gathering it ;-) In meantime if anyone want's to see something relative added in this post - please comment. $\endgroup$ Commented Jun 4, 2012 at 18:48
  • 1
    $\begingroup$ @VitaliyKaurov your answer covers what is the purpose of defining and using a graph object. But in terms of Graph visualization I see there is significant overlap between Graph and GraphPlot. The name "GraphPlot" suggests that this function specializes on plotting the graph. Perhaps another answer should highlight what are the advantages of plotting, visualizing graphs with GraphPlot, instead of Graph. And isn't it possible to merge functionality of GraphPlot into Graph ? I have also noticed that GraphPlot drawing is part of Graph Visualization. $\endgroup$ Commented Mar 5, 2016 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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