GraphPlot

GraphPlot[g]

generates a plot of the graph g.

GraphPlot[{e1,e2,}]

generates a plot of the graph with edges ei.

GraphPlot[{,w[ei],}]

plots ei with features defined by the symbolic wrapper w.

GraphPlot[{vi 1vj 1,}]

uses rules vikvjk to specify the graph g.

GraphPlot[m]

uses the adjacency matrix m to specify the graph g.

Details and Options

  • GraphPlot attempts to place vertices to give a well-laid-out version of the graph.
  • GraphPlot supports the same vertices and edges as Graph.
  • The following special wrappers can be used for the edges ei:
  • Annotation[ei,label]provide an annotation
    Button[ei,action]define an action to execute when the element is clicked
    EventHandler[ei,]define a general event handler for the element
    Hyperlink[ei,uri]make the element act as a hyperlink
    Labeled[ei,]display the element with labeling
    PopupWindow[ei,cont]attach a popup window to the element
    StatusArea[ei,label]display in the status area when the element is moused over
    Style[ei,opts]show the element using the specified styles
    Tooltip[ei,label]attach an arbitrary tooltip to the element
  • GraphPlot has the same options as Graphics, with the following additions and changes:
  • DataRangeAutomaticthe range of vertex coordinates to generate
    DirectedEdgesFalsewhether to interpret Rule as DirectedEdge
    EdgeLabelsNonelabels and placements for edges
    EdgeLabelStyleAutomaticstyle to use for edge labels
    EdgeShapeFunctionAutomaticgenerate graphic shapes for edges
    EdgeStyleAutomaticstyles for edges
    GraphLayoutAutomatichow to lay out vertices and edges
    GraphHighlight{}vertices and edges to highlight
    GraphHighlightStyleAutomaticstyle for highlight
    MethodAutomaticmethod to use
    PerformanceGoalAutomaticaspects of performance to try to optimize
    PlotStyleAutomaticgraphics directives to determine styles
    PlotThemeAutomaticoverall theme for the graph
    VertexCoordinatesAutomaticcoordinates for vertices
    VertexLabelsNonelabels and placements for vertices
    VertexLabelStyleAutomaticstyle to use for vertex labels
    VertexShapeAutomaticgraphic shape for vertices
    VertexShapeFunctionAutomaticgenerate graphic shapes for vertices
    VertexSizeAutomaticsize of vertices
    VertexStyleAutomaticstyles for vertices
  • With the setting VertexCoordinates->Automatic, the embedding of vertices and routing of edges is computed automatically, based on the setting for GraphLayout.
  • Possible special embeddings for GraphLayout include:
  • "BipartiteEmbedding"vertices on two parallel lines
    "CircularEmbedding"vertices on a circle
    "CircularMultipartiteEmbedding"vertices on segments of a circle
    "DiscreteSpiralEmbedding"vertices on a discrete spiral
    "GridEmbedding"vertices on a grid
    "LinearEmbedding"vertices on a line
    "MultipartiteEmbedding"vertices on several parallel lines
    "SpiralEmbedding"vertices on a 3D spiral projected to 2D
    "StarEmbedding"vertices on a circle with a center
  • Possible structured embeddings for layered graphs such as trees and directed acyclic graphs include:
  • "BalloonEmbedding"vertices on a circle with the center at the parent vertex
    "RadialEmbedding"vertices on a circular segment
    "LayeredDigraphEmbedding"vertices on parallel lines for directed acyclic graphs
    "LayeredEmbedding"vertices on parallel lines
  • Possible optimizing embeddings all minimize a quantity and include:
  • "HighDimensionalEmbedding"energy for spring-electrical in high dimension
    "PlanarEmbedding"number of edge crossings
    "SpectralEmbedding"weighted sum of squares distances
    "SpringElectricalEmbedding"energy with edges as springs and vertices as charges
    "SpringEmbedding"energy with edges as springs
    "TutteEmbedding"number of edge crossings and distance to neighbors
  • Possible settings for PlotTheme include common base themes:
  • "Business"a bright, modern look appropriate for business presentations or infographics
    "Detailed"identify data by employing labels and tooltips
    "Marketing"elegant, eye-catching design suitable for marketing needs
    "Minimal"simple graph
    "Monochrome"single-color design
    "Scientific"candid design useful for analyzing detailed data with labels and tooltips
    "Web"clean, bold design suitable for a consumer website or blog
    "Classic"historical design of graph to remain compatible with existing uses
  • Graph features themes affect plot of vertices and edges. Feature themes include:
  • "LargeGraph"large graph
    "ClassicLabeled"classic graph
    "IndexLabeled"index-labeled graph

Examples

open allclose all

Basic Examples  (3)

Plot a graph:

Plot a graph specified by edge rules:

Plot a graph specified by its adjacency matrix:

Scope  (11)

Graph Specification  (6)

Specify a graph using a graph:

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:

Graph Styling  (5)

Give labels for some edges:

Give vertex labels:

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:

Options  (71)

DataRange  (1)

Specify the range of vertex coordinates:

DirectedEdges  (1)

Show the direction of edges:

GraphLayout  (66)

"BalloonEmbedding"  (6)

Place each vertex in an enclosing circle centered at its parent vertex:

"BalloonEmbedding" works best for tree graphs:

Use the option "EvenAngle"->True to place vertices evenly in an enclosing circle:

With the setting "OptimalOrder"->True, the vertex ordering optimizes the angular resolution and the aspect ratio:

Use the option "RootVertex"->v to set the root vertex:

Use "SectorAngles"->s to control the size of each sector:

"BipartiteEmbedding"  (1)

Place vertices on two vertical lines based on a bipartite partition:

"CircularEmbedding"  (2)

Place vertices on a circle:

Use the option "Offset"->offset to specify the offset angles:

"CircularMultipartiteEmbedding"  (2)

Place vertices on polygon lines based on a vertex partition:

Use "VertexPartition"->partition to specify a partition of vertices:

"DiscreteSpiralEmbedding"  (3)

Place vertices on a discrete spiral:

"DiscreteSpiralEmbedding" works best for path graphs:

With the setting "OptimalOrder"->True, vertices are reordered so that they lie nicely on a discrete spiral:

"GridEmbedding"  (2)

Place vertices on a grid:

Use "Dimension"->dim to specify a dimension of a grid:

"HighDimensionalEmbedding"  (2)

Place vertices in high dimension according to spring-electrical embedding and project down:

Use "RandomSeed"->int to specify a seed for the random number generator that computes the initial vertex placement:

"LayeredEmbedding"  (6)

Place vertices in several layers in such a way as to minimize edges between nonadjacent layers:

"LayeredEmbedding" works best for tree graphs:

Use the option "LayerSizeFunction"->func to specify the relative height:

Use the option "RootVertex"->v to set the root vertex:

Use the option "LeafDistance"->d to specify the leaf distance:

Use the option "Orientation"->o to draw a tree with different orientations:

"LayeredDigraphEmbedding"  (3)

Place vertices in a series of layers:

Use the option "RootVertex"->v to set the root vertex:

Use the option "Orientation"->o to draw a tree with different orientations:

"LinearEmbedding"  (2)

Place vertices on a line:

Use the option "Method"->m to specify the algorithm:

"MultipartiteEmbedding"  (2)

Place vertices on multiple line grids based on a vertex partition:

Use "VertexPartition"->partition to specify a partition of vertices:

"PlanarEmbedding"  (1)

Place vertices on a plane without an edge crossing:

"RadialEmbedding"  (2)

Place vertices in concentric circles:

Use the option "RootVertex"->v to set the root vertex:

"RandomEmbedding"  (1)

Place vertices randomly:

"SpectralEmbedding"  (2)

Place vertices so the weighted sum of squares of mutual distances is minimized:

Use the option "RelaxationFactor"->r to get the layout based on a relaxed Laplace matrix:

"SpiralEmbedding"  (2)

Place vertices on a spiral:

With the setting "OptimalOrder"->True, vertices are reordered so that they lie on the spiral nicely:

"SpringElectricalEmbedding"  (12)

Place vertices so that they minimize mechanical and electrical energy when each vertex has a charge and each edge corresponds to a spring:

With the setting "EdgeWeighted"->True, edge weights are used:

Use the option "EnergyControl"->e to specify limitations on the total energy of the system during minimization:

Use "InferentialDistance"->d to specify a cutoff distance beyond which the interaction between vertices is assumed to be nonexistent:

Use "MaxIteration"->it to specify a maximum number of iterations to be used in attempting to minimize the energy:

Use "Multilevel"->method to specify a method used during a recursive procedure of coarsening a graph:

With the setting "Octree"->True, an octree data structure (in three dimensions) or a quadtree data structure (in two dimensions) is used in the calculation of repulsive force:

Use "RandomSeed"->int to specify a seed for the random number generator that computes the initial vertex placement:

Use "RepulsiveForcePower"->r to control how fast the repulsive force decays over distance:

Use "StepControl"->method to define how step length is modified during energy minimization:

Use "StepLength"->r to specify the initial step length used in moving the vertices around:

Use "Tolerance"->r to specify the tolerance used in terminating the energy minimization process:

"SpringEmbedding"  (10)

Place vertices so that they minimize mechanical energy when each edge corresponds to a spring:

With the setting "EdgeWeighted"->True, edge weights are used:

Use the option "EnergyControl"->e to specify limitations on the total energy of the system during minimization:

Use "InferentialDistance"->d to specify a cutoff distance beyond which the interaction between vertices is assumed to be nonexistent:

Use "MaxIteration"->it to specify a maximum number of iterations to be used in attempting to minimize the energy:

Use "Multilevel"->method to specify a method used during a recursive procedure of coarsening a graph:

Use "RandomSeed"->int to specify a seed for the random number generator that computes the initial vertex placement:

Use "StepControl"->method to define how step length is modified during energy minimization:

Use "StepLength"->r to specify the initial step length used in moving the vertices around:

Use "Tolerance"->r to specify the tolerance used in terminating the energy minimization process:

"StarEmbedding"  (3)

Place vertices on a star shape:

Use the option "Offset"->offset to specify the offset angles:

Use the option "Center"->center to specify the center:

"TutteEmbedding"  (2)

Place vertices without crossing edges and minimize the sum of distances to neighbors:

"TutteEmbedding" works for 3-connected planar graphs only:

PlotStyle  (3)

Specify an overall style for the graph:

PlotStyle can be combined with VertexShapeFunction, which has higher priority:

PlotStyle can be combined with EdgeShapeFunction, which has higher priority:

Applications  (27)

Basic Applications  (3)

Label vertices and edges:

Plot a graph with "BalloonEmbedding":

Visualize large graphs:

Graph Theory  (5)

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:

Linguistic or Geographic Data  (3)

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:

Number Properties  (11)

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:

Sparse Test Matrices  (3)

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:

Finite State Diagrams  (2)

A finite state diagram describing the C preprocessor:

A finite state diagram for string matching:

Properties & Relations  (6)

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 VertexCoordinates 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:

Introduced in 2007
 (6.0)
 |
Updated in 2019
 (12.0)