generates a plot of the graph g.

GraphPlot[{vi 1vj 1,vi 2vj 2,}]
generates a plot of the graph in which vertex vik is connected to vertex vjk.

GraphPlot[{{vi 1vj 1,lbl1},}]
associates labels lblk with edges in the graph.

generates a plot of the graph represented by the adjacency matrix m.

Details and OptionsDetails and Options

  • GraphPlot attempts to place vertices to give a well laid-out version of the graph.
  • The vertex names vk and the labels lblk can be any expressions.
  • With the default setting DirectedEdges->False, edges are drawn as ordinary lines. With DirectedEdges->True, edges are drawn as arrows.
  • GraphPlot has the same options as Graphics, with the following additions and changes:
  • DataRangeAutomaticthe range of vertex coordinates to generate
    DirectedEdgesFalsewhether to show edges as directed arrows
    EdgeLabelingTruewhether to include labels given for edges
    EdgeRenderingFunctionAutomaticfunction to give explicit graphics for edges
    FrameFalsewhether to draw a frame around the plot
    FrameTicksNonewhat ticks to include on the frame
    MethodAutomaticthe method used to lay out the graph
    MultiedgeStyleAutomatichow to draw multiple edges between vertices
    PackingMethodAutomaticmethod to use for packing components
    PlotRangePaddingAutomatichow much padding to put around the plot
    PlotStyleAutomaticoverall graphics directives for vertices and edges
    SelfLoopStyleAutomatichow to draw edges linking a vertex to itself
    VertexCoordinateRulesAutomaticrules for explicit vertex coordinates
    VertexLabelingAutomaticwhether to show vertex names as labels
    VertexRenderingFunctionAutomaticfunction to give explicit graphics for vertices
  • With the default setting VertexLabeling->Automatic, vertices are displayed as points, with their names vk given in tooltips, so long as the number of vertices is not too large.
  • Tooltip[vk,vlab] can be used to specify an alternative tooltip for a vertex. Tooltip[vi->vj,lbl] specifies a tooltip for an edge.
  • Explicit settings for VertexRenderingFunction and EdgeRenderingFunction override settings for VertexLabeling, EdgeLabeling, and DirectedEdges.
  • With VertexRenderingFunction->f, each vertex is rendered with the graphics primitives given by f[rk,vk], where rk is the position where the vertex is being placed, and vk is its name.
  • With EdgeRenderingFunction->g, each edge is rendered with the graphics primitives given by g[{ri,,rj},{vi,vj},lblij], where ri, rj are the beginning and ending points of the edge, vi, vj are the beginning and ending vertices, and the lblij is any label specified for the edge.
  • The graphics primitives obtained by applying EdgeRenderingFunction and VertexRenderingFunction are in effect directly spliced into the graphic generated by GraphPlot. Inset can be used to insert an arbitrary expression.
  • In the graphics generated by GraphPlot, edges are effectively drawn first, and vertices afterwards.
  • With the default setting DataRange->Automatic, coordinates are chosen so that the average length of the edges in the graph is approximately 1.
  • In VertexCoordinateRules, an explicit rule vk->{xk,yk} specifies coordinates for a vertex. If any coordinate is given as Automatic, it is found automatically. Vertices for which no rules are specified are taken to have automatically generated x and y positions.
  • The graph does not need to be connected. Disconnected components are typically arranged so as to fill area roughly uniformly.
  • When a graph is specified by an adjacency matrix, the names of its vertices are taken to be successive integers starting at 1.
  • The adjacency matrix m in GraphPlot[m] can be a SparseArray object.
  • With the default setting MultiedgeStyle->Automatic, multiple edges are not shown if the graph is specified by an adjacency matrix.
  • Possible settings for Method include "CircularEmbedding", "RandomEmbedding", "HighDimensionalEmbedding", "RadialDrawing", "SpringEmbedding", and "SpringElectricalEmbedding". The method "LinearEmbedding" lays out all vertices on a single line.
  • With Method->Automatic, GraphPlot normally uses the "SpringElectricalEmbedding" method, though it uses the "RadialDrawing" method if the graph is a tree.
  • GraphPlot returns a Graphics object.

ExamplesExamplesopen allclose all

Basic Examples  (2)Basic Examples  (2)

Plot a network from rules for connections:

Click for copyable input

Show the directions of edges:

Click for copyable input

Include labels for vertices:

Click for copyable input

Show labels for edges:

Click for copyable input

Draw a graph specified by its adjacency matrix:

Click for copyable input

Include self-loops and multiedges:

Click for copyable input
Introduced in 2007
| Updated in 2014