---
title: "GraphPlot"
language: "en"
type: "Symbol"
summary: "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[{v i 1 -> v j 1, ...}] uses rules vik -> vjk to specify the graph g. GraphPlot[m] uses the adjacency matrix m to specify the graph g."
keywords: 
- circular embedding
- digraph layout
- draw a graph
- graph drawing
- graph embedding
- graph layout
- graph visualization
- high-dimensional embedding
- linear embedding
- network layout
- network visualization
- plot a graph
- radial drawing
- random embedding
- spring-electrical embedding
- spring embedding
- plot a permutation
- plot a finite relation
- plot a sparse array
- CircularEmbedding
- RandomEmbedding
- HighDimensionalEmbedding
- RadialDrawing
- SpringEmbedding
- SpringElectricalEmbedding
- LinearEmbedding
- gplot
canonical_url: "https://reference.wolfram.com/language/ref/GraphPlot.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Graph Visualization"
    link: "https://reference.wolfram.com/language/guide/GraphVisualization.en.md"
  - 
    title: "Computational Geometry"
    link: "https://reference.wolfram.com/language/guide/ComputationalGeometry.en.md"
  - 
    title: "Computational Systems"
    link: "https://reference.wolfram.com/language/guide/ComputationalSystemsAndDiscovery.en.md"
  - 
    title: "Data Visualization"
    link: "https://reference.wolfram.com/language/guide/DataVisualization.en.md"
  - 
    title: "Social Network Analysis"
    link: "https://reference.wolfram.com/language/guide/SocialNetworks.en.md"
  - 
    title: "Scientific Data Analysis"
    link: "https://reference.wolfram.com/language/guide/ScientificDataAnalysis.en.md"
  - 
    title: "Graph Layouts"
    link: "https://reference.wolfram.com/language/guide/GraphLayouts.en.md"
---
# 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[{vi1 -> vj1, …}] uses rules vik -> vjk 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.

[image]

* ``GraphPlot`` supports the same vertices and edges as ``Graph``.

* The following special wrappers can be used for the edges Subscript[``e``, ``i``]:

|                       |                                                            |
| --------------------- | ---------------------------------------------------------- |
| 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: []

|                     |           |                                             |
| ------------------- | --------- | ------------------------------------------- |
| DataRange           | Automatic | the range of vertex coordinates to generate |
| DirectedEdges       | False     | whether to interpret Rule as DirectedEdge   |
| EdgeLabels          | None      | labels and label placements for edges       |
| EdgeLabelStyle      | Automatic | style to use for edge labels                |
| EdgeShapeFunction   | Automatic | generate graphic shapes for edges           |
| EdgeStyle           | Automatic | styles for edges                            |
| GraphLayout         | Automatic | how to lay out vertices and edges           |
| GraphHighlight      | {}        | vertices and edges to highlight             |
| GraphHighlightStyle | Automatic | style for highlight                         |
| Method              | Automatic | method to use                               |
| PerformanceGoal     | Automatic | aspects of performance to try to optimize   |
| PlotStyle           | Automatic | graphics directives to determine styles     |
| PlotTheme           | Automatic | overall theme for the graph                 |
| VertexCoordinates   | Automatic | coordinates for vertices                    |
| VertexLabels        | None      | labels and label placements for vertices    |
| VertexLabelStyle    | Automatic | style to use for vertex labels              |
| VertexShape         | Automatic | graphic shape for vertices                  |
| VertexShapeFunction | Automatic | generate graphic shapes for vertices        |
| VertexSize          | Automatic | size of vertices                            |
| VertexStyle         | Automatic | styles 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:

|         |                                 |                                         |
| ------- | ------------------------------- | --------------------------------------- |
| [image] | "BipartiteEmbedding"            | vertices on two parallel lines          |
| [image] | "CircularEmbedding"             | vertices on a circle                    |
| [image] | "CircularMultipartiteEmbedding" | vertices on segments of a circle        |
| [image] | "DiscreteSpiralEmbedding"       | vertices on a discrete spiral           |
| [image] | "GridEmbedding"                 | vertices on a grid                      |
| [image] | "LinearEmbedding"               | vertices on a line                      |
| [image] | "MultipartiteEmbedding"         | vertices on several parallel lines      |
| [image] | "SpiralEmbedding"               | vertices on a 3D spiral projected to 2D |
| [image] | "StarEmbedding"                 | vertices on a circle with a center      |

* Possible structured embeddings for layered graphs such as trees and directed acyclic graphs include:

|         |                           |                                                           |
| ------- | ------------------------- | --------------------------------------------------------- |
| [image] | "BalloonEmbedding"        | vertices on a circle with the center at the parent vertex |
| [image] | "RadialEmbedding"         | vertices on a circular segment                            |
| [image] | "LayeredDigraphEmbedding" | vertices on parallel lines for directed acyclic graphs    |
| [image] | "LayeredEmbedding"        | vertices on parallel lines                                |

* Possible optimizing embeddings all minimize a quantity and include:

|         |                             |                                                      |
| ------- | --------------------------- | ---------------------------------------------------- |
| [image] | "HighDimensionalEmbedding"  | energy for spring-electrical in high dimension       |
| [image] | "PlanarEmbedding"           | number of edge crossings                             |
| [image] | "SpectralEmbedding"         | weighted sum of squares distances                    |
| [image] | "SpringElectricalEmbedding" | energy with edges as springs and vertices as charges |
| [image] | "SpringEmbedding"           | energy with edges as springs                         |
| [image] | "TutteEmbedding"            | number of edge crossings and distance to neighbors   |

* Possible settings for ``PlotTheme`` include common base themes:

|         |              |                                                                              |
| ------- | ------------ | ---------------------------------------------------------------------------- |
| [image] | "Business"   | a bright, modern look appropriate for business presentations or infographics |
| [image] | "Detailed"   | identify data by employing labels and tooltips                               |
| [image] | "Marketing"  | elegant, eye-catching design suitable for marketing needs                    |
| [image] | "Minimal"    | simple graph                                                                 |
| [image] | "Monochrome" | single-color design                                                          |
| [image] | "Scientific" | candid design useful for analyzing detailed data with labels and tooltips    |
| [image] | "Web"        | clean, bold design suitable for a consumer website or blog                   |
| [image] | "Classic"    | historical design of graph to remain compatible with existing uses           |

* Graph features themes affect plot of vertices and edges. Feature themes include:

|         |                  |                     |
| ------- | ---------------- | ------------------- |
| [image] | "LargeGraph"     | large graph         |
| [image] | "ClassicLabeled" | classic graph       |
| [image] | "IndexLabeled"   | index-labeled graph |

### List of all options

|                        |                 |                                                                                    |
| ---------------------- | --------------- | ---------------------------------------------------------------------------------- |
| AlignmentPoint         | Center          | the default point in the graphic to align with                                     |
| AspectRatio            | Automatic       | ratio of height to width                                                           |
| Axes                   | False           | whether to draw axes                                                               |
| AxesLabel              | None            | axes labels                                                                        |
| AxesOrigin             | Automatic       | where axes should cross                                                            |
| AxesStyle              | {}              | style specifications for the axes                                                  |
| Background             | None            | background color for the plot                                                      |
| BaselinePosition       | Automatic       | how to align with a surrounding text baseline                                      |
| BaseStyle              | {}              | base style specifications for the graphic                                          |
| ContentSelectable      | Automatic       | whether to allow contents to be selected                                           |
| CoordinatesToolOptions | Automatic       | detailed behavior of the coordinates tool                                          |
| DataRange              | Automatic       | the range of vertex coordinates to generate                                        |
| DirectedEdges          | False           | whether to interpret Rule as DirectedEdge                                          |
| EdgeLabels             | None            | labels and label placements for edges                                              |
| EdgeLabelStyle         | Automatic       | style to use for edge labels                                                       |
| EdgeShapeFunction      | Automatic       | generate graphic shapes for edges                                                  |
| EdgeStyle              | Automatic       | styles for edges                                                                   |
| Epilog                 | {}              | primitives rendered after the main plot                                            |
| FormatType             | TraditionalForm | the default format type for text                                                   |
| Frame                  | False           | whether to put a frame around the plot                                             |
| FrameLabel             | None            | frame labels                                                                       |
| FrameStyle             | {}              | style specifications for the frame                                                 |
| FrameTicks             | Automatic       | frame ticks                                                                        |
| FrameTicksStyle        | {}              | style specifications for frame ticks                                               |
| GraphHighlight         | {}              | vertices and edges to highlight                                                    |
| GraphHighlightStyle    | Automatic       | style for highlight                                                                |
| GraphLayout            | Automatic       | how to lay out vertices and edges                                                  |
| GridLines              | None            | grid lines to draw                                                                 |
| GridLinesStyle         | {}              | style specifications for grid lines                                                |
| ImageMargins           | 0.              | the margins to leave around the graphic                                            |
| ImagePadding           | All             | what extra padding to allow for labels etc.                                        |
| ImageSize              | Automatic       | the absolute size at which to render the graphic                                   |
| LabelStyle             | {}              | style specifications for labels                                                    |
| Method                 | Automatic       | method to use                                                                      |
| PerformanceGoal        | Automatic       | aspects of performance to try to optimize                                          |
| PlotLabel              | None            | an overall label for the plot                                                      |
| PlotRange              | All             | range of values to include                                                         |
| PlotRangeClipping      | False           | whether to clip at the plot range                                                  |
| PlotRangePadding       | Automatic       | how much to pad the range of values                                                |
| PlotRegion             | Automatic       | the final display region to be filled                                              |
| PlotStyle              | Automatic       | graphics directives to determine styles                                            |
| PlotTheme              | Automatic       | overall theme for the graph                                                        |
| PreserveImageOptions   | Automatic       | whether to preserve image options when displaying new versions of the same graphic |
| Prolog                 | {}              | primitives rendered before the main plot                                           |
| RotateLabel            | True            | whether to rotate y labels on the frame                                            |
| Ticks                  | Automatic       | axes ticks                                                                         |
| TicksStyle             | {}              | style specifications for axes ticks                                                |
| VertexCoordinates      | Automatic       | coordinates for vertices                                                           |
| VertexLabels           | None            | labels and label placements for vertices                                           |
| VertexLabelStyle       | Automatic       | style to use for vertex labels                                                     |
| VertexShape            | Automatic       | graphic shape for vertices                                                         |
| VertexShapeFunction    | Automatic       | generate graphic shapes for vertices                                               |
| VertexSize             | Automatic       | size of vertices                                                                   |
| VertexStyle            | Automatic       | styles for vertices                                                                |

---

## Examples (120)

### Basic Examples (3)

Plot a graph:

```wl
In[1]:= GraphPlot[PetersenGraph[]]

Out[1]= [image]
```

---

Plot a graph specified by edge rules:

```wl
In[1]:= GraphPlot[{1 -> 2, 3 -> 1, 3 -> 2, 4 -> 1, 4 -> 2}]

Out[1]= [image]
```

---

Plot a graph specified by its adjacency matrix:

```wl
In[1]:= GraphPlot[{{0, 1, 1}, {1, 0, 1}, {1, 1, 0}}]

Out[1]= [image]
```

### Scope (11)

#### Graph Specification (6)

Specify a graph using a graph:

```wl
In[1]:= GraphPlot[Graph[{1\[UndirectedEdge]2, 2\[UndirectedEdge]3, 3\[UndirectedEdge]4, 4\[UndirectedEdge]1, 2\[UndirectedEdge]4}]]

Out[1]= [image]
```

---

Specify a graph using a rule list:

```wl
In[1]:= GraphPlot[{1 -> 2, 2 -> 3, 3 -> 4, 4 -> 1, 2 -> 4}]

Out[1]= [image]
```

---

Specify a graph using a dense adjacency matrix:

```wl
In[1]:= GraphPlot[{{0, 1, 0, 0}, {0, 0, 1, 1}, {0, 0, 0, 1}, {1, 0, 0, 0}}]

Out[1]= [image]
```

---

Specify a graph using a sparse adjacency matrix:

```wl
In[1]:= GraphPlot[SparseArray[{{1, 2}, {2, 3}, {3, 4}, {4, 1}, {2, 4}} -> 1, {4, 4}]]

Out[1]= [image]
```

---

Use ``GraphData`` for collections of graphs:

```wl
In[1]:= Table[GraphPlot[GraphData[g, "EdgeRules"]], {g, {{"GeneralizedPetersen", {9, 2}}, "ClebschGraph", "TesseractGraph"}}]

Out[1]= {[image], [image], [image]}
```

---

Use ``ExampleData`` for collections of sparse matrices:

```wl
In[1]:= GraphPlot[ExampleData[{"Matrix", "Bai/dwa512"}, "Matrix"]]

Out[1]= [image]
```

#### Graph Styling (5)

Give labels for some edges:

```wl
In[1]:= GraphPlot[{1 -> 2, Labeled[2 -> 3, "23"], 3 -> 1, 2 -> 4, 2 -> 5}]

Out[1]= [image]
```

---

Give vertex labels:

```wl
In[1]:= GraphPlot[{5 -> 4, 6 -> 2, 6 -> 3, 6 -> 5, 4 -> 5, 7 -> 1, 7 -> 7, 7 -> 3, 7 -> 4, 7 -> 6}, VertexLabels -> "Name"]

Out[1]= [image]
```

---

Show edges as arrows:

```wl
In[1]:= GraphPlot[{1 -> 6, 2 -> 6, 3 -> 6, 4 -> 6, 5 -> 6}, DirectedEdges -> True]

Out[1]= [image]
```

---

Plot a disconnected graph using different packing methods:

```wl
In[1]:= Table[Framed@GraphPlot[Table[i -> Mod[i ^ 2, 102], {i, 0, 102}], GraphLayout -> {"PackingLayout" -> pm}], {pm, {Automatic, "ClosestPacking"}}]

Out[1]= {[image], [image]}
```

---

For very large graphs, it is often better not to draw vertices at all:

```wl
In[1]:= GraphPlot[Table[i -> Mod[i ^ 2, 500], {i, 500}], VertexShapeFunction -> None]

Out[1]= [image]
```

### Options (71)

#### DataRange (1)

Specify the range of vertex coordinates:

```wl
In[1]:= GraphPlot[{1 -> 2, 2 -> 3, 3 -> 4, 4 -> 1, 2 -> 4}, DataRange -> {{0, 1}, {0, 1}}]

Out[1]= [image]
```

#### DirectedEdges (1)

Show the direction of edges:

```wl
In[1]:= GraphPlot[{1 -> 2, 2 -> 3, 3 -> 4, 4 -> 1, 2 -> 4}, DirectedEdges -> True]

Out[1]= [image]
```

#### GraphLayout (66)

##### "BalloonEmbedding" (6)

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

```wl
In[1]:= GraphPlot[Table[Floor[j / 12]\[UndirectedEdge]j, {j, 1, 30}], GraphLayout -> "BalloonEmbedding"]

Out[1]= [image]
```

---

``"BalloonEmbedding"`` works best for tree graphs:

```wl
In[1]:= GraphPlot[RandomInteger[{1, #}] \[UndirectedEdge] # + 1 & /@ Range[30], GraphLayout -> "BalloonEmbedding"]

Out[1]= [image]
```

---

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

```wl
In[1]:= GraphPlot[KaryTree[48, 5], GraphLayout -> {"BalloonEmbedding", "EvenAngle" -> #}]& /@ {True, False}

Out[1]= {[image], [image]}
```

---

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

```wl
In[1]:= GraphPlot[KaryTree[48, 5], GraphLayout -> {"BalloonEmbedding", "OptimalOrder" -> #}]& /@ {True, False}

Out[1]= {[image], [image]}
```

---

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

```wl
In[1]:= GraphPlot[KaryTree[48, 5], GraphLayout -> {"BalloonEmbedding", "RootVertex" -> #}]& /@ {1, 2}

Out[1]= {[image], [image]}
```

---

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

```wl
In[1]:= GraphPlot[KaryTree[48, 5], GraphLayout -> {"BalloonEmbedding", "SectorAngles" -> {1 -> Pi / 2}}]

Out[1]= [image]
```

##### "BipartiteEmbedding" (1)

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

```wl
In[1]:= GraphPlot[Table[i\[UndirectedEdge]Mod[i + 1, 5], {i, 8}], GraphLayout -> "BipartiteEmbedding"]

Out[1]= [image]
```

##### "CircularEmbedding" (2)

Place vertices on a circle:

```wl
In[1]:= GraphPlot[Table[i\[UndirectedEdge]Mod[i + 1, 3], {i, 8}], GraphLayout -> "CircularEmbedding"]

Out[1]= [image]
```

---

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

```wl
In[1]:= GraphPlot[CompleteGraph[7], GraphLayout -> {"CircularEmbedding", "Offset" -> #}]& /@ {Automatic, {30 Degree, 30 Degree}, {50 Degree, 80 Degree}}

Out[1]= {[image], [image], [image]}
```

##### "CircularMultipartiteEmbedding" (2)

Place vertices on polygon lines based on a vertex partition:

```wl
In[1]:= GraphPlot[Flatten[Table[i\[UndirectedEdge]j, {i, 4}, {j, 5, 8}]], GraphLayout -> {"CircularMultipartiteEmbedding", "VertexPartition" -> {2, 3, 3}}]

Out[1]= [image]
```

---

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

```wl
In[1]:= GraphPlot[CompleteGraph[{3, 3, 2}], GraphLayout -> {"CircularMultipartiteEmbedding", "VertexPartition" -> {3, 3, 2}}]

Out[1]= [image]
```

##### "DiscreteSpiralEmbedding" (3)

Place vertices on a discrete spiral:

```wl
In[1]:= GraphPlot[Table[i\[UndirectedEdge]i + 1, {i, 11}], GraphLayout -> "DiscreteSpiralEmbedding"]

Out[1]= [image]
```

---

``"DiscreteSpiralEmbedding"`` works best for path graphs:

```wl
In[1]:= GraphPlot[PathGraph[Range[30]], GraphLayout -> "DiscreteSpiralEmbedding"]

Out[1]= [image]
```

---

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

```wl
In[1]:=
edges = RandomSample[EdgeList[PathGraph[Range[20]]], 19];
{GraphPlot[edges, GraphLayout -> {"DiscreteSpiralEmbedding", "OptimalOrder" -> True}], 
	GraphPlot[edges, GraphLayout -> {"DiscreteSpiralEmbedding", "OptimalOrder" -> False}]}

Out[1]= {[image], [image]}
```

##### "GridEmbedding" (2)

Place vertices on a grid:

```wl
In[1]:= GraphPlot[Table[i\[UndirectedEdge]Mod[i + 3, 8], {i, 15}], GraphLayout -> {"GridEmbedding", "Dimension" -> {4, 4}}]

Out[1]= [image]
```

---

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

```wl
In[1]:= GraphPlot[GridGraph[{12, 12}], GraphLayout -> {"GridEmbedding", "Dimension" -> {12, 12}}]

Out[1]= [image]
```

##### "HighDimensionalEmbedding" (2)

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

```wl
In[1]:= GraphPlot[{1\[UndirectedEdge]2, 1\[UndirectedEdge]3, 1\[UndirectedEdge]5, 1\[UndirectedEdge]9, 2\[UndirectedEdge]4, 2\[UndirectedEdge]6, 2\[UndirectedEdge]10, 3\[UndirectedEdge]4, 3\[UndirectedEdge]7, 3\[UndirectedEdge]11, 4\[UndirectedEdge]8, 4\[UndirectedEdge]12, 5\[UndirectedEdge]6, 5\[UndirectedEdge]7, 5\[UndirectedEdge]13, 6\[UndirectedEdge]8, 6\[UndirectedEdge]14, 7\[UndirectedEdge]8, 7\[UndirectedEdge]15, 8\[UndirectedEdge]16, 9\[UndirectedEdge]10, 9\[UndirectedEdge]11, 9\[UndirectedEdge]13, 10\[UndirectedEdge]12, 10\[UndirectedEdge]14, 11\[UndirectedEdge]12, 11\[UndirectedEdge]15, 12\[UndirectedEdge]16, 13\[UndirectedEdge]14, 13\[UndirectedEdge]15, 14\[UndirectedEdge]16, 15\[UndirectedEdge]16}, GraphLayout -> "HighDimensionalEmbedding"]

Out[1]= [image]
```

---

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

```wl
In[1]:= edge = {1\[UndirectedEdge]3, 1\[UndirectedEdge]5, 1\[UndirectedEdge]7, 2\[UndirectedEdge]3, 2\[UndirectedEdge]6, 2\[UndirectedEdge]7, 2\[UndirectedEdge]8, 3\[UndirectedEdge]4, 3\[UndirectedEdge]8, 4\[UndirectedEdge]6, 5\[UndirectedEdge]8, 7\[UndirectedEdge]8};

In[2]:= GraphPlot[edge, GraphLayout -> {"HighDimensionalEmbedding", "RandomSeed" -> #}]& /@ {1, 50}

Out[2]= {[image], [image]}
```

##### "LayeredEmbedding" (6)

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

```wl
In[1]:= GraphPlot[Table[i\[UndirectedEdge]Mod[i + 1, 5], {i, 12}], GraphLayout -> "LayeredEmbedding"]

Out[1]= [image]
```

---

``"LayeredEmbedding"`` works best for tree graphs:

```wl
In[1]:= GraphPlot[RandomInteger[{1, #}] \[UndirectedEdge] # + 1 & /@ Range[20], GraphLayout -> "LayeredEmbedding"]

Out[1]= [image]
```

---

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

```wl
In[1]:= GraphPlot[KaryTree[10, 3], GraphLayout -> {"LayeredEmbedding", LayerSizeFunction -> (2&)}]

Out[1]= [image]
```

---

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

```wl
In[1]:= GraphPlot[KaryTree[10, 3], GraphLayout -> {"LayeredEmbedding", "RootVertex" -> #}]& /@ {1, 4}

Out[1]= {[image], [image]}
```

---

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

```wl
In[1]:= GraphPlot[KaryTree[10, 3], GraphLayout -> {"LayeredEmbedding", "LeafDistance" -> #}]& /@ {1, 2}

Out[1]= {[image], [image]}
```

---

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

```wl
In[1]:= Table[GraphPlot[KaryTree[6, 3], GraphLayout -> {"LayeredEmbedding", "Orientation" -> o}], {o, {Top, Bottom, Left, Right}}]

Out[1]= {[image], [image], [image], [image]}
```

##### "LayeredDigraphEmbedding" (3)

Place vertices in a series of layers:

```wl
In[1]:= GraphPlot[{1\[DirectedEdge]2, 1\[DirectedEdge]3, 2\[DirectedEdge]3, 1\[DirectedEdge]4, 2\[DirectedEdge]4, 1\[DirectedEdge]5}, GraphLayout -> "LayeredDigraphEmbedding"]

Out[1]= [image]
```

---

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

```wl
In[1]:= GraphPlot[{1\[DirectedEdge]2, 1\[DirectedEdge]3, 2\[DirectedEdge]3, 1\[DirectedEdge]4, 2\[DirectedEdge]4, 1\[DirectedEdge]5}, GraphLayout -> {"LayeredDigraphEmbedding", "RootVertex" -> #}]& /@ {1, 3}

Out[1]= {[image], [image]}
```

---

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

```wl
In[1]:= Table[GraphPlot[{1\[DirectedEdge]2, 1\[DirectedEdge]3, 2\[DirectedEdge]3, 1\[DirectedEdge]4, 2\[DirectedEdge]4, 1\[DirectedEdge]5}, GraphLayout -> {"LayeredDigraphEmbedding", "Orientation" -> o}], {o, {Top, Bottom, Left, Right}}]

Out[1]= {[image], [image], [image], [image]}
```

##### "LinearEmbedding" (2)

Place vertices on a line:

```wl
In[1]:= GraphPlot[{1\[UndirectedEdge]2, 2\[UndirectedEdge]3, 3\[UndirectedEdge]4}, GraphLayout -> "LinearEmbedding"]

Out[1]= [image]
```

---

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

```wl
In[1]:= Table[GraphPlot[CompleteGraph[4], GraphLayout -> {"LinearEmbedding", Method -> m}], {m, {"Spectral", "SpectralOrdering", "TwoNormApproximation", "TwoNormApproximationOrdering"}}]

Out[1]= {[image], [image], [image], [image]}
```

##### "MultipartiteEmbedding" (2)

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

```wl
In[1]:= GraphPlot[Flatten[Table[i\[UndirectedEdge]j, {i, 3}, {j, 4, 8}]], GraphLayout -> {"MultipartiteEmbedding", "VertexPartition" -> {2, 1, 3, 2}}]

Out[1]= [image]
```

---

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

```wl
In[1]:= GraphPlot[CompleteGraph[{3, 2, 4}], GraphLayout -> {"MultipartiteEmbedding", "VertexPartition" -> {3, 2, 4}}]

Out[1]= [image]
```

##### "PlanarEmbedding" (1)

Place vertices on a plane without an edge crossing:

```wl
In[1]:= GraphPlot[{1\[UndirectedEdge]2, 1\[UndirectedEdge]3, 1\[UndirectedEdge]4, 2\[UndirectedEdge]3, 2\[UndirectedEdge]4, 3\[UndirectedEdge]4}, GraphLayout -> "PlanarEmbedding"]

Out[1]= [image]
```

##### "RadialEmbedding" (2)

Place vertices in concentric circles:

```wl
In[1]:= GraphPlot[Table[Floor[j / 7]\[UndirectedEdge]j, {j, 1, 30}], GraphLayout -> "RadialEmbedding"]

Out[1]= [image]
```

---

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

```wl
In[1]:= GraphPlot[KaryTree[60, 5], GraphLayout -> {"RadialEmbedding", "RootVertex" -> #}]& /@ {1, 2}

Out[1]= {[image], [image]}
```

##### "RandomEmbedding" (1)

Place vertices randomly:

```wl
In[1]:= GraphPlot[Table[i\[UndirectedEdge]Mod[i + 1, 10], {i, 30}], GraphLayout -> "RandomEmbedding"]

Out[1]= [image]
```

##### "SpectralEmbedding" (2)

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

```wl
In[1]:= GraphPlot[{1\[UndirectedEdge]2, 1\[UndirectedEdge]3, 1\[UndirectedEdge]5, 1\[UndirectedEdge]9, 2\[UndirectedEdge]4, 2\[UndirectedEdge]6, 2\[UndirectedEdge]10, 3\[UndirectedEdge]4, 3\[UndirectedEdge]7, 3\[UndirectedEdge]11, 4\[UndirectedEdge]8, 4\[UndirectedEdge]12, 5\[UndirectedEdge]6, 5\[UndirectedEdge]7, 5\[UndirectedEdge]13, 6\[UndirectedEdge]8, 6\[UndirectedEdge]14, 7\[UndirectedEdge]8, 7\[UndirectedEdge]15, 8\[UndirectedEdge]16, 9\[UndirectedEdge]10, 9\[UndirectedEdge]11, 9\[UndirectedEdge]13, 10\[UndirectedEdge]12, 10\[UndirectedEdge]14, 11\[UndirectedEdge]12, 11\[UndirectedEdge]15, 12\[UndirectedEdge]16, 13\[UndirectedEdge]14, 13\[UndirectedEdge]15, 14\[UndirectedEdge]16, 15\[UndirectedEdge]16}, GraphLayout -> "SpectralEmbedding"]

Out[1]= [image]
```

---

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

```wl
In[1]:= Table[GraphPlot[GridGraph[{10, 10}], GraphLayout -> {"SpectralEmbedding", "RelaxationFactor" -> i}], {i, 0, 1, .3}]

Out[1]= {[image], [image], [image], [image]}
```

##### "SpiralEmbedding" (2)

Place vertices on a spiral:

```wl
In[1]:= GraphPlot[Table[i\[UndirectedEdge]Mod[i + 1, 20, 1], {i, 20}], GraphLayout -> "SpiralEmbedding"]

Out[1]= [image]
```

---

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

```wl
In[1]:=
edges = RandomSample[EdgeList[CycleGraph[20]], 20];
GraphPlot[edges, GraphLayout -> {"SpiralEmbedding", "OptimalOrder" -> #}]& /@ {True, False}

Out[1]= {[image], [image]}
```

##### "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:

```wl
In[1]:= GraphPlot[{1\[UndirectedEdge]2, 1\[UndirectedEdge]3, 1\[UndirectedEdge]5, 1\[UndirectedEdge]9, 2\[UndirectedEdge]4, 2\[UndirectedEdge]6, 2\[UndirectedEdge]10, 3\[UndirectedEdge]4, 3\[UndirectedEdge]7, 3\[UndirectedEdge]11, 4\[UndirectedEdge]8, 4\[UndirectedEdge]12, 5\[UndirectedEdge]6, 5\[UndirectedEdge]7, 5\[UndirectedEdge]13, 6\[UndirectedEdge]8, 6\[UndirectedEdge]14, 7\[UndirectedEdge]8, 7\[UndirectedEdge]15, 8\[UndirectedEdge]16, 9\[UndirectedEdge]10, 9\[UndirectedEdge]11, 9\[UndirectedEdge]13, 10\[UndirectedEdge]12, 10\[UndirectedEdge]14, 11\[UndirectedEdge]12, 11\[UndirectedEdge]15, 12\[UndirectedEdge]16, 13\[UndirectedEdge]14, 13\[UndirectedEdge]15, 14\[UndirectedEdge]16, 15\[UndirectedEdge]16}, GraphLayout -> "SpringElectricalEmbedding"]

Out[1]= [image]
```

---

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

```wl
In[1]:=
edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 10];
weight = RandomInteger[{1, 5}, 11];

In[2]:= GraphPlot[edge, EdgeWeight -> weight, GraphLayout -> {"SpringElectricalEmbedding", "EdgeWeighted" -> #}]& /@ {True, False}

Out[2]= {[image], [image]}
```

---

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

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 20];

In[2]:= GraphPlot[edge, {GraphLayout -> {"SpringElectricalEmbedding", "EnergyControl" -> #, "StepControl" -> "Monotonic"}}]& /@ {Automatic, "Monotonic", "NonMonotonic"}

Out[2]= {[image], [image], [image]}
```

---

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

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 20];

In[2]:= GraphPlot[edge, GraphLayout -> {"SpringElectricalEmbedding", "InferentialDistance" -> #}]& /@ {Automatic, .1, .5}

Out[2]= {[image], [image], [image]}
```

---

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

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 20];

In[2]:= GraphPlot[edge, GraphLayout -> {"SpringElectricalEmbedding", "MaxIteration" -> #}]& /@ {Automatic, 1, 2}

Out[2]= {[image], [image], [image]}
```

---

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

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 20];

In[2]:= GraphPlot[edge, GraphLayout -> {"SpringElectricalEmbedding", "Multilevel" -> #}]& /@ {Automatic, None, "MaximalIndependentVertexSet", "MaximalIndependentVertexSetRugeStuben", "MaximalIndependentVertexSetInjection", "MaximalIndependentVertexSetRugeStubenInjection", "MaximalIndependentEdgeSetHeavyEdge", "MaximalIndependentEdgeSet", "MaximalIndependentEdgeSetSmallestVertexWeight", "Hybrid"}

Out[2]= {[image], [image], [image], [image], [image], [image], [image], [image], [image], [image]}
```

---

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:

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 20];

In[2]:= GraphPlot[edge, GraphLayout -> {"SpringElectricalEmbedding", "Octree" -> #}]& /@ {True, False}

Out[2]= {[image], [image]}
```

---

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

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 20];

In[2]:= GraphPlot[edge, GraphLayout -> {"SpringElectricalEmbedding", "RandomSeed" -> #}]& /@ {1, 5}

Out[2]= {[image], [image]}
```

---

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

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 20];

In[2]:= GraphPlot[edge, GraphLayout -> {"SpringElectricalEmbedding", "RepulsiveForcePower" -> #}]& /@ {-1, -2.5}

Out[2]= {[image], [image]}
```

---

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

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 20];

In[2]:= GraphPlot[edge, GraphLayout -> {"SpringElectricalEmbedding", "StepControl" -> #}]& /@ {Automatic, "Monotonic", "NonMonotonic", "StrictlyMonotonic"}

Out[2]= {[image], [image], [image], [image]}
```

---

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

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 20];

In[2]:= GraphPlot[edge, GraphLayout -> {"SpringElectricalEmbedding", "StepLength" -> #}]& /@ {1, 4.5}

Out[2]= {[image], [image]}
```

---

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

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 20];

In[2]:= GraphPlot[edge, GraphLayout -> {"SpringElectricalEmbedding", "Tolerance" -> #}]& /@ {Automatic, .5}

Out[2]= {[image], [image]}
```

##### "SpringEmbedding" (10)

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

```wl
In[1]:= GraphPlot[{1\[UndirectedEdge]14, 1\[UndirectedEdge]15, 1\[UndirectedEdge]16, 2\[UndirectedEdge]5, 2\[UndirectedEdge]6, 2\[UndirectedEdge]13, 3\[UndirectedEdge]7, 3\[UndirectedEdge]14, 3\[UndirectedEdge]19, 4\[UndirectedEdge]8, 4\[UndirectedEdge]15, 4\[UndirectedEdge]20, 5\[UndirectedEdge]11, 5\[UndirectedEdge]19, 6\[UndirectedEdge]12, 6\[UndirectedEdge]20, 7\[UndirectedEdge]11, 7\[UndirectedEdge]16, 8\[UndirectedEdge]12, 8\[UndirectedEdge]16, 9\[UndirectedEdge]10, 9\[UndirectedEdge]14, 9\[UndirectedEdge]17, 10\[UndirectedEdge]15, 10\[UndirectedEdge]18, 11\[UndirectedEdge]12, 13\[UndirectedEdge]17, 13\[UndirectedEdge]18, 17\[UndirectedEdge]19, 18\[UndirectedEdge]20}, GraphLayout -> "SpringEmbedding"]

Out[1]= [image]
```

---

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

```wl
In[1]:=
edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 10];
weight = RandomInteger[{1, 5}, 11];

In[2]:= GraphPlot[edge, EdgeWeight -> weight, GraphLayout -> {"SpringEmbedding", "EdgeWeighted" -> #}]& /@ {True, False}

Out[2]= {[image], [image]}
```

---

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

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 30];

In[2]:= GraphPlot[edge, {GraphLayout -> {"SpringEmbedding", "EnergyControl" -> #}}]& /@ {Automatic, "Monotonic", "NonMonotonic"}

Out[2]= {[image], [image], [image]}
```

---

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

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 30];

In[2]:= GraphPlot[edge, GraphLayout -> {"SpringEmbedding", "InferentialDistance" -> #}]& /@ {Automatic, .5, 2}

Out[2]= {[image], [image], [image]}
```

---

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

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 30];

In[2]:= GraphPlot[edge, GraphLayout -> {"SpringEmbedding", "MaxIteration" -> #}]& /@ {Automatic, 1, 2}

Out[2]= {[image], [image], [image]}
```

---

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

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 30];

In[2]:= GraphPlot[edge, GraphLayout -> {"SpringEmbedding", "Multilevel" -> #}]& /@ {Automatic, None, "MaximalIndependentVertexSet", "MaximalIndependentVertexSetRugeStuben", "MaximalIndependentVertexSetInjection", "MaximalIndependentVertexSetRugeStubenInjection", "MaximalIndependentEdgeSetHeavyEdge", "MaximalIndependentEdgeSet", "MaximalIndependentEdgeSetSmallestVertexWeight", "Hybrid"}

Out[2]= {[image], [image], [image], [image], [image], [image], [image], [image], [image], [image]}
```

---

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

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 30];

In[2]:= GraphPlot[edge, GraphLayout -> {"SpringEmbedding", "RandomSeed" -> #}]& /@ {1, 5}

Out[2]= {[image], [image]}
```

---

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

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 30];

In[2]:= GraphPlot[edge, GraphLayout -> {"SpringEmbedding", "StepControl" -> #}]& /@ {Automatic, "Monotonic", "NonMonotonic", "StrictlyMonotonic"}

Out[2]= {[image], [image], [image], [image]}
```

---

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

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 30];

In[2]:= GraphPlot[edge, GraphLayout -> {"SpringEmbedding", "StepLength" -> #}]& /@ {1, 4.5}

Out[2]= {[image], [image]}
```

---

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

```wl
In[1]:= edge = RandomInteger[#]\[UndirectedEdge]# + 1& /@ Range[0, 30];

In[2]:= GraphPlot[edge, GraphLayout -> {"SpringEmbedding", "Tolerance" -> #}]& /@ {Automatic, .5}

Out[2]= {[image], [image]}
```

##### "StarEmbedding" (3)

Place vertices on a star shape:

```wl
In[1]:= GraphPlot[Table[1\[UndirectedEdge]i, {i, 2, 6}], GraphLayout -> "StarEmbedding"]

Out[1]= [image]
```

---

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

```wl
In[1]:= GraphPlot[StarGraph[15], GraphLayout -> {"StarEmbedding", "Offset" -> #}]& /@ {Automatic, {30 Degree, 30 Degree}, {50 Degree, 80 Degree}}

Out[1]= {[image], [image], [image]}
```

---

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

```wl
In[1]:= GraphPlot[StarGraph[15], GraphLayout -> {"StarEmbedding", "Center" -> #}]& /@ {Automatic, 10}

Out[1]= {[image], [image]}
```

##### "TutteEmbedding" (2)

---

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

```wl
In[1]:= GraphPlot[{1\[UndirectedEdge]2, 1\[UndirectedEdge]3, 1\[UndirectedEdge]4, 2\[UndirectedEdge]3, 2\[UndirectedEdge]4, 3\[UndirectedEdge]4}, GraphLayout -> "TutteEmbedding"]

Out[1]= [image]
```

---

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

```wl
In[1]:= GraphPlot[GraphData[{"JohnsonSkeleton", 77}, "EdgeList"], GraphLayout -> "TutteEmbedding"]

Out[1]= [image]
```

#### PlotStyle (3)

Specify an overall style for the graph:

```wl
In[1]:= Table[GraphPlot[{1 -> 2, 2 -> 3, 3 -> 4, 1 -> 4, 1 -> 3}, PlotStyle -> ps], {ps, {Red, Dashed, Directive[Red, Dashed]}}]

Out[1]= {[image], [image], [image]}
```

---

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

```wl
In[1]:= GraphPlot[{1 -> 2, 2 -> 3, 3 -> 4, 1 -> 4, 1 -> 3}, PlotStyle -> Directive[PointSize[Large], Red], VertexShapeFunction -> Function[{p}, {Green, Point[p]}]]

Out[1]= [image]
```

---

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

```wl
In[1]:= GraphPlot[{1 -> 2, 2 -> 3, 3 -> 4, 1 -> 4, 1 -> 3}, PlotStyle -> Directive[Dashed, Red], EdgeShapeFunction -> Function[{p}, {Green, Line[p]}]]

Out[1]= [image]
```

### Applications (27)

#### Basic Applications (3)

Label vertices and edges:

```wl
In[1]:= GraphPlot[{1\[UndirectedEdge]2, 2\[UndirectedEdge]3, Labeled[3\[UndirectedEdge]1, "hello"]}, VertexLabels -> {2 -> "Name"}]

Out[1]= [image]
```

---

Plot a graph with ``"BalloonEmbedding"`` :

```wl
In[1]:= GraphPlot[Table[Floor[j / 12]\[UndirectedEdge]j, {j, 1, 30}], GraphLayout -> "BalloonEmbedding"]

Out[1]= [image]
```

---

Visualize large graphs:

```wl
In[1]:= GraphPlot[ExampleData[{"Matrix", "Bai/cryg2500"}, "Matrix"]]

Out[1]= [image]
```

#### Graph Theory (5)

Plot a complete graph on 10 nodes:

```wl
In[1]:= GraphPlot[ConstantArray[1, {10, 10}]]

Out[1]= [image]
```

---

Plot a random graph on 10 nodes:

```wl
In[1]:= GraphPlot[RandomInteger[1, {10, 10}]]

Out[1]= [image]
```

---

A random graph with 1% of possible edges filled in:

```wl
In[1]:= GraphPlot[RandomChoice[{0.01, 0.99} -> {1, 0}, {100, 100}]]

Out[1]= [image]
```

---

A graph describing a simple relation:

```wl
In[1]:= GraphPlot[Table[i -> Mod[2 ^ i, 21], {i, 20}], PlotTheme -> "ClassicDiagram"]

Out[1]= [image]
```

---

Draw the graph of a random permutation:

```wl
In[1]:= GraphPlot[Thread[Range[20] -> RandomSample[Range[20]]]]

Out[1]= [image]
```

#### Linguistic or Geographic Data (3)

Generate a network of "nearby" words in a dictionary:

```wl
In[1]:= words = DictionaryLookup["wol*"];

In[2]:= Flatten[Map[(Thread[# -> DeleteCases[Nearest[words, #, 3], #]])&, words]];

In[3]:= GraphPlot[%, VertexShapeFunction -> (Text[Style[#2, Black], #1, Background -> White]&)]

Out[3]= [image]
```

---

A word graph, with edges between adjacent letters in a word:

```wl
In[1]:=
w = Characters["Shakespeare"];
GraphPlot[
	Thread[Drop[w, -1] -> Drop[w, 1]], PlotTheme -> "ClassicDiagram", DirectedEdges -> True]

Out[1]= [image]
```

---

Show the adjacent countries in South America:

```wl
In[1]:= GraphPlot[Flatten[Thread[# -> CountryData[#, "BorderingCountries"]]& /@ CountryData["SouthAmerica"]], GraphLayout -> {"EdgeLayout" -> "StraightLine"}, VertexLabels -> Placed["Name", Center, Framed[#, Background -> LightYellow]&]]

Out[1]= [image]
```

#### Number Properties (11)

Numbers that have a common divisor:

```wl
In[1]:= GraphPlot[Table[If[GCD[m, n] == 1, 0, 1], {m, 20}, {n, 20}], PlotTheme -> "SmallNetwork"]

Out[1]= [image]
```

---

Numbers that have no common divisor:

```wl
In[1]:= GraphPlot[Table[If[GCD[m, n] == 1, 1, 0], {m, 20}, {n, 20}], PlotTheme -> "SmallNetwork"]

Out[1]= [image]
```

---

Link a number to another with a 1 bit inserted:

```wl
In[1]:= GraphPlot[Flatten[Table[Table[j -> FromDigits[Insert[IntegerDigits[j, 2], 1, i], 2], {i, Length[IntegerDigits[j, 2]] + 1}], {j, 0, 2 ^ 6 - 1}]], GraphLayout -> {"EdgeLayout" -> "StraightLine"}]

Out[1]= [image]
```

---

Link a number to another with a 0 bit inserted:

```wl
In[1]:= GraphPlot[Flatten[Table[Table[j -> FromDigits[Insert[IntegerDigits[j, 2], 0, i], 2], {i, Length[IntegerDigits[j, 2]] + 1}], {j, 0, 2 ^ 6 - 1}]], GraphLayout -> {"EdgeLayout" -> "StraightLine"}]

Out[1]= [image]
```

---

Link a number to another with 1 bit deleted:

```wl
In[1]:= GraphPlot[Flatten[Table[Table[j -> FromDigits[Drop[IntegerDigits[j, 2], {i}], 2], {i, Length[IntegerDigits[j, 2]]}], {j, 2 ^ 6 - 1}]], GraphLayout -> {"EdgeLayout" -> "StraightLine"}]

Out[1]= [image]
```

---

Link a number to another that is one bit different:

```wl
In[1]:= GraphPlot[Flatten[Map[Thread, Thread[Range[0, 2 ^ 6 - 1] -> Table[Thread[BitXor[Table[2 ^ i - 1, {i, Length[IntegerDigits[j, 2]]}], j]], {j, 0, 2 ^ 6 - 1}], List]]], GraphLayout -> {"EdgeLayout" -> "StraightLine"}]

Out[1]= [image]
```

---

Link a number to another that is one bit reversed:

```wl
In[1]:= GraphPlot[Table[j -> FromDigits[Reverse[IntegerDigits[j, 2]], 2], {j, 0, 2 ^ 9 - 1}]]

Out[1]= [image]
```

---

Link a number to another that is one bit rotated right:

```wl
In[1]:= GraphPlot[Table[j -> FromDigits[RotateRight[IntegerDigits[j, 2]], 2], {j, 0, 2 ^ 9 - 1}], GraphLayout -> "RadialEmbedding"]

Out[1]= [image]
```

---

Link a number to another that is one bit rotated left:

```wl
In[1]:= GraphPlot[Table[j -> FromDigits[RotateLeft[IntegerDigits[j, 2]], 2], {j, 0, 2 ^ 9 - 1}], GraphLayout -> "RadialEmbedding"]

Out[1]= [image]
```

---

Link a number to itself but with the last bit dropped:

```wl
In[1]:= GraphPlot[Table[j -> FromDigits[Drop[IntegerDigits[j, 2], -1], 2], {j, 0, 2 ^ 8 - 1}], GraphLayout -> "RadialEmbedding"]

Out[1]= [image]
```

---

Link a number to itself but with the first bit dropped:

```wl
In[1]:= GraphPlot[Table[j -> FromDigits[Drop[IntegerDigits[j, 2], 1], 2], {j, 0, 2 ^ 8 - 1}], GraphLayout -> "RadialEmbedding"]

Out[1]= [image]
```

#### Sparse Test Matrices (3)

A sparse test matrix related to a structure from NASA's Langley Research Center:

```wl
In[1]:= GraphPlot[ExampleData[{"Matrix", "Boeing/nasa1824"}, "Matrix"]]

Out[1]= [image]
```

---

A sparse test matrix related to a finite element model of a geodesic dome:

```wl
In[1]:= GraphPlot[ExampleData[{"Matrix", "HB/blckhole"}, "Matrix"], VertexShapeFunction -> None]

Out[1]= [image]
```

---

Use ``ArrayPlot`` or ``MatrixPlot`` to display sparse matrices:

```wl
In[1]:= g = ExampleData[{"Matrix", "Boeing/nasa1824"}, "Matrix"]

Out[1]=
SparseArray[Automatic, {1824, 1824}, 0., 
 {1, {CompressedData["«4003»"], 
   CompressedData["«15937»"]}, CompressedData["«154446»"]}]

In[2]:= {ArrayPlot[g, MaxPlotPoints -> 100], MatrixPlot[g]}

Out[2]= [image]
```

#### Finite State Diagrams (2)

A finite state diagram describing the C preprocessor:

```wl
In[1]:= GraphPlot[{"start" -> "none", Labeled["none" -> "none", "other"], Labeled["none" -> "slash", "/"], Labeled["slash" -> "none", "other"], Labeled["slash" -> "C++", "/"], Labeled["slash" -> "C", "*"], Labeled["C++" -> "C++", "other"], Labeled["C++" -> "none", "end-of-line"], Labeled["C" -> "C", "other"], Labeled["C" -> "star", "*"], Labeled["star" -> "star", "*"], Labeled["star" -> "C", "other"], Labeled["star" -> "none", "/"]}, DirectedEdges -> True, PlotTheme -> "DiagramBlue"]

Out[1]= [image]
```

---

A finite state diagram for string matching:

```wl
In[1]:= GraphPlot[{"start" -> "empty", Labeled["empty" -> "empty", "other"], Labeled["empty" -> "n", "n"], Labeled["n" -> "n", "n"], Labeled["n" -> "empty", "other"], Labeled["n" -> "na", "a"], Labeled["na" -> "nan", "n"], Labeled["na" -> "empty", "other"], Labeled["nan" -> "na", "a"], Labeled["nan" -> "na", "a"], Labeled["nan" -> "nano", "o"], Labeled["nan" -> "empty", "other"], Labeled["nano" -> "nano", "any"]}, PlotTheme -> "DiagramBlue", DirectedEdges -> True]

Out[1]= [image]
```

### Properties & Relations (8)

Use ``LayeredGraphPlot`` for hierarchical-style drawing of directed graphs:

```wl
In[1]:= LayeredGraphPlot[{Labeled["main" -> "fun1", "fun1[a,b]"], Labeled["main" -> "fun2", "fun2[1,2,3]"], Labeled["fun2" -> "fun3", "fun3[0.5]"], Labeled["main" -> "fun3", "fun3[0.6]"]}, PlotTheme -> "DiagramGreen"]

Out[1]= [image]
```

---

Use ``TreePlot`` for different types of tree drawing:

```wl
In[1]:= TreePlot[Flatten[Table[{i -> 2i + j - 1}, {j, 2}, {i, 7}]]]

Out[1]= [image]
```

---

Use ``GraphPlot3D`` to draw graphs in 3D:

```wl
In[1]:= GraphPlot3D[Table[i -> Mod[i ^ 2, 200], {i, 200}]]

Out[1]= [image]

In[2]:= GraphPlot3D[PolyhedronData["Dodecahedron", "Skeleton", "Rule"]]

Out[2]= [image]
```

---

Use ``GraphData`` for an extensive collection of predefined graphs and properties:

```wl
In[1]:= Short[GraphData[], 3]

Out[1]//Short= {"12P2+3K1", "2C10", "2C3", "2C3+2K1", "2C3+C4", "2C3+K1", «7842», {"ZeroTwoNonbipartite", {7, 52}}, {"ZeroTwoNonbipartite", {7, 53}}, {"ZeroTwoNonbipartite", {7, 54}}, {"ZeroTwoNonbipartite", {7, 55}}, {"ZeroTwoNonbipartite", {7, 56}}}
```

Get the connectivity and plot it:

```wl
In[2]:= GraphData["DesarguesGraph", "EdgeRules"]

Out[2]= {1 -> 2, 1 -> 6, 1 -> 20, 2 -> 3, 2 -> 17, 3 -> 4, 3 -> 12, 4 -> 5, 4 -> 15, 5 -> 6, 5 -> 10, 6 -> 7, 7 -> 8, 7 -> 16, 8 -> 9, 8 -> 19, 9 -> 10, 9 -> 14, 10 -> 11, 11 -> 12, 11 -> 20, 12 -> 13, 13 -> 14, 13 -> 18, 14 -> 15, 15 -> 16, 16 -> 17, 17 -> 18, 18 -> 19, 19 -> 20}

In[3]:= GraphPlot[%]

Out[3]= [image]
```

Use ``VertexCoordinates`` to use the embedding provided by ``GraphData``:

```wl
In[4]:= GraphPlot[GraphData["DesarguesGraph", "Edges", "Rule"], VertexCoordinates -> GraphData["DesarguesGraph", "VertexCoordinates"], PlotTheme -> "SmallNetwork"]

Out[4]= [image]
```

---

Use ``PolyhedronData`` for a large collection of polyhedra and properties:

```wl
In[1]:= PolyhedronData["Dodecahedron", "Skeleton", "Rule"]

Out[1]= {1 -> 14, 1 -> 15, 1 -> 16, 2 -> 5, 2 -> 6, 2 -> 13, 3 -> 7, 3 -> 14, 3 -> 19, 4 -> 8, 4 -> 15, 4 -> 20, 5 -> 11, 5 -> 19, 6 -> 12, 6 -> 20, 7 -> 11, 7 -> 16, 8 -> 12, 8 -> 16, 9 -> 10, 9 -> 14, 9 -> 17, 10 -> 15, 10 -> 18, 11 -> 12, 13 -> 17, 13 -> 18, 17 -> 19, 18 -> 20}

In[2]:= GraphPlot[%]

Out[2]= [image]
```

Compare to a predefined embedding:

```wl
In[3]:= PolyhedronData["Dodecahedron", "Skeleton"]

Out[3]= [image]
```

---

Use ``ExampleData`` for a large collection of sparse matrices:

```wl
In[1]:= GraphPlot[ExampleData[{"Matrix", "HB/can_292"}, "Matrix"]]

Out[1]= [image]
```

---

Use ``GeoGraphValuePlot`` to show the values on geographic networks:

```wl
In[1]:= GeoGraphValuePlot[{{Entity["City", {"Rome", "Lazio", "Italy"}], Entity["City", {"Milan", "Lombardy", "Italy"}], 2.2}, {Entity["City", {"Milan", "Lombardy", "Italy"}], Entity["City", {"Paris", "IleDeFrance", "France"}], 2.4}, {Entity["City", {"Milan", "Lombardy", "Italy"}], Entity["City", {"Frankfurt", "Hesse", "Germany"}], 5}, {Entity["City", {"Paris", "IleDeFrance", "France"}], Entity["City", {"Frankfurt", "Hesse", "Germany"}], 3.2}, {Entity["City", {"Paris", "IleDeFrance", "France"}], Entity["City", {"Madrid", "Madrid", "Spain"}], 4.3}, {Entity["City", {"Paris", "IleDeFrance", "France"}], Entity["City", {"London", "GreaterLondon", "UnitedKingdom"}], 3.3}, {Entity["City", {"Madrid", "Madrid", "Spain"}], Entity["City", {"Seville", "Seville", "Spain"}], 3.6}, {Entity["City", {"Madrid", "Madrid", "Spain"}], Entity["City", {"Barcelona", "Barcelona", "Spain"}], 1.8}}]

Out[1]= [image]
```

---

Use ``GeoGraphPlot`` to plot relationships between geographic locations on a map:

```wl
In[1]:= GeoGraphPlot[IconizedObject[«nearest US cities»]]

Out[1]= [image]
```

## See Also

* [`Graph`](https://reference.wolfram.com/language/ref/Graph.en.md)
* [`GraphPlot3D`](https://reference.wolfram.com/language/ref/GraphPlot3D.en.md)
* [`LayeredGraphPlot`](https://reference.wolfram.com/language/ref/LayeredGraphPlot.en.md)
* [`TreePlot`](https://reference.wolfram.com/language/ref/TreePlot.en.md)
* [`CommunityGraphPlot`](https://reference.wolfram.com/language/ref/CommunityGraphPlot.en.md)
* [`GraphLayout`](https://reference.wolfram.com/language/ref/GraphLayout.en.md)
* [`GraphEmbedding`](https://reference.wolfram.com/language/ref/GraphEmbedding.en.md)
* [`Graph`](https://reference.wolfram.com/language/ref/entity/Graph.en.md)
* [`Graph`](https://reference.wolfram.com/language/ref/interpreter/Graph.en.md)
* [`ComputedGraph`](https://reference.wolfram.com/language/ref/interpreter/ComputedGraph.en.md)
* [`Graphlet`](https://reference.wolfram.com/language/ref/format/Graphlet.en.md)
* [`DOT`](https://reference.wolfram.com/language/ref/format/DOT.en.md)
* [`GraphML`](https://reference.wolfram.com/language/ref/format/GraphML.en.md)

## Related Guides

* [Graph Visualization](https://reference.wolfram.com/language/guide/GraphVisualization.en.md)
* [Computational Geometry](https://reference.wolfram.com/language/guide/ComputationalGeometry.en.md)
* [Computational Systems](https://reference.wolfram.com/language/guide/ComputationalSystemsAndDiscovery.en.md)
* [Data Visualization](https://reference.wolfram.com/language/guide/DataVisualization.en.md)
* [Social Network Analysis](https://reference.wolfram.com/language/guide/SocialNetworks.en.md)
* [Scientific Data Analysis](https://reference.wolfram.com/language/guide/ScientificDataAnalysis.en.md)
* [Graph Layouts](https://reference.wolfram.com/language/guide/GraphLayouts.en.md)

## History

* [Introduced in 2007 (6.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn60.en.md) \| [Updated in 2019 (12.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn120.en.md)