This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

GraphPlot

GraphPlot
generates a plot of the graph in which vertex is connected to vertex .
GraphPlot
associates labels with edges in the graph.
GraphPlot[m]
generates a plot of the graph represented by the adjacency matrix m.
  • GraphPlot attempts to place vertices to give a well laid-out version of the graph.
  • The vertex names and the labels can be any expressions.
  • 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 given in tooltips, so long as the number of vertices is not too large.
  • Tooltip can be used to specify an alternative tooltip for a vertex. Tooltip specifies a tooltip for an edge.
  • With VertexRenderingFunction->f, each vertex is rendered with the graphics primitives given by , where is the position where the vertex is being placed, and is its name.
  • With EdgeRenderingFunction->g, each edge is rendered with the graphics primitives given by , where , are the beginning and ending points of the edge, , are the beginning and ending vertices, and the is any label specified for the edge.
  • 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 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.
  • 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 , , , , , and . The method lays out all vertices on a single line.
Plot a network from rules for connections:
Show the directions of edges:
Include labels for vertices:
Show labels for edges:
Draw a graph specified by its adjacency matrix:
Include self-loops and multiedges:
Plot a network from rules for connections:
In[1]:=
Click for copyable input
Out[1]=
Show the directions of edges:
In[2]:=
Click for copyable input
Out[2]=
Include labels for vertices:
In[3]:=
Click for copyable input
Out[3]=
Show labels for edges:
In[4]:=
Click for copyable input
Out[4]=
 
Draw a graph specified by its adjacency matrix:
In[1]:=
Click for copyable input
Out[1]=
Include self-loops and multiedges:
In[2]:=
Click for copyable input
Out[2]=
Specify a graph using a rule list:
Specify a graph using a dense adjacency matrix:
Specify a graph using a sparse adjacency matrix:
Use GraphData for collections of graphs:
Use ExampleData for collections of sparse matrices:
Give labels for some edges:
Give vertex labels:
Do not show multiedges or self-loops:
Show edges as arrows:
Plot a disconnected graph using different packing methods:
For very large graphs, it is often better not to draw vertices at all:
Multiclick to move vertices in a graph:
Use different methods to get different layouts:
Plot graphs generated by Combinatorica:
Use Method->None to preserve the embedding provided by Combinatorica:
Show the direction of edges:
By default edge labels are shown:
Display the edge label as a tooltip:
Display the edge label both explicitly and as a tooltip:
Draw vertices only:
Draw edges using gray arrows and self-loops using red arrows:
Apply a number of methods on the Petersen graph:
Spread multiple edges by a specified scaled distance:
Packing disconnected components using different methods:
Use different PlotRangePadding around the graph:
Specify an overall style for the graph:
PlotStyle can be combined with VertexRenderingFunction, which has higher priority:
PlotStyle can be combined with EdgeRenderingFunction, which has higher priority:
Draw self-loops with a specified scaled diameter:
Explicitly specify all vertex coordinates:
Explicitly specify only coordinates and automatically compute the coordinate:
Show vertex labels:
Show vertex labels as tooltips only:
Show vertex labels as tooltips only if the graph is small:
Show vertex labels both explicitly and as tooltips:
Show no vertices:
Render vertices using a predefined graphic:
Plot a complete graph on 10 nodes:
Plot a random graph on 10 nodes:
A random graph with 1% of possible edges filled in:
A graph describing a simple relation:
Draw the graph of a random permutation:
Generate a network of "nearby" words in a dictionary:
A word graph, with edges between adjacent letters in a word:
Show the adjacent countries in South America:
Numbers that have a common divisor:
Numbers that have no common divisor:
Link a number to another with a 1 bit inserted:
Link a number to another with a 0 bit inserted:
Link a number to another with 1 bit deleted:
Link a number to another that is one bit different:
Link a number to another that is one bit reversed:
Link a number to another that is one bit rotated right:
Link a number to another that is one bit rotated left:
Link a number to itself but with the last bit dropped:
Link a number to itself but with the first bit dropped:
A sparse test matrix related to a structure from NASA's Langley Research Center:
A sparse test matrix related to a finite element model of a geodesic dome:
Use ArrayPlot or MatrixPlot to display sparse matrices:
A finite state diagram describing the C preprocessor:
A finite state diagram for string matching:
Use LayeredGraphPlot for hierarchical-style drawing of directed graphs:
Use TreePlot for different types of tree drawing:
Use GraphPlot3D to draw graphs in 3D:
Use GraphData for an extensive collection of predefined graphs and properties:
Get the connectivity and plot it:
Use VertexCoordinateRules to use the embedding provided by GraphData:
Use PolyhedronData for a large collection of polyhedra and properties:
Compare to a predefined embedding:
Use ExampleData for a large collection of sparse matrices:
GraphPlot supports graphs defined by Combinatorica:
Set option Method->None to use the embedding provided by Combinatorica:
Symmetries of large graphs may not be preserved by default:
Use explicit methods to preserve symmetries:
GraphPlot may produce a drawing that is different from those defined in GraphData:
Layouts produced by GraphPlot may be platform dependent and therefore may produce different layouts:
Graphs from simple relations:
Make a graph of the relationship between subexpressions:
New in 6