({{, (RefLink[GraphPlot, paclet:ref/GraphPlot])[g]
generates a plot of the graph g.}, {, (RefLink[GraphPlot, paclet:ref/GraphPlot])[{(Subscript[e, 1]),(Subscript[e, 2]),…}]
generates a plot of the graph with edges (Subscript[e, i]).}, {, (RefLink[GraphPlot, paclet:ref/GraphPlot])[{…,w[(Subscript[e, i])],…}]
plots (Subscript[e, i]) with features defined by the symbolic wrapper w.}, {, (RefLink[GraphPlot, paclet:ref/GraphPlot])[{(Subscript[v, i1])->(Subscript[v, j1]),…}]
uses rules (Subscript[v, ik])->(Subscript[v, jk]) to specify the graph g.}, {, (RefLink[GraphPlot, paclet:ref/GraphPlot])[m]
uses the adjacency matrix m to specify the graph g.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[GraphPlot, paclet:ref/GraphPlot]) attempts to place vertices to give a well laid-out version of the graph.

(RefLink[GraphPlot, paclet:ref/GraphPlot]) supports the same vertices and edges as (RefLink[Graph, paclet:ref/Graph]).

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

(RefLink[GraphPlot, paclet:ref/GraphPlot]) has the same options as (RefLink[Graphics, paclet:ref/Graphics]), with the following additions and changes:

With the setting (RefLink[VertexCoordinates, paclet:ref/VertexCoordinates])->(RefLink[Automatic, paclet:ref/Automatic]), the embedding of vertices and routing of edges is computed automatically, based on the setting for (RefLink[GraphLayout, paclet:ref/GraphLayout]).

Possible special embeddings for (RefLink[GraphLayout, paclet:ref/GraphLayout]) include:

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

Possible optimizing embeddings all minimize a quantity and include:

Possible settings for (RefLink[PlotTheme, paclet:ref/PlotTheme]) include common base themes:

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

OpenersPrimaryExamplesSection(Spacer1)Examples  (118)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Plot a graph:

GraphPlot[PetersenGraph[]]

Plot a graph specified by edge rules:

GraphPlot[{1->2,3->1,3->2,4->1,4->2}]

Plot a graph specified by its adjacency matrix:

GraphPlot[{{0,1,1},{1,0,1},{1,1,0}}]

OpenersExampleSection1(Spacer1)Scope  (11)

OpenersExampleSubsection0(Spacer1)Graph Specification  (6)

Specify a graph using a graph:

GraphPlot[Graph[{1\[UndirectedEdge]2,2\[UndirectedEdge]3,3\[UndirectedEdge]4,4\[UndirectedEdge]1,2\[UndirectedEdge]4}]]

Specify a graph using a rule list:

GraphPlot[{1->2,2->3,3->4,4->1,2->4}]

Specify a graph using a dense adjacency matrix:

GraphPlot[{{0,1,0,0},{0,0,1,1},{0,0,0,1},{1,0,0,0}}]

Specify a graph using a sparse adjacency matrix:

GraphPlot[SparseArray[{{1,2},{2,3},{3,4},{4,1},{2,4}}->1,{4,4}]]

Use (RefLink[GraphData, paclet:ref/GraphData]) for collections of graphs:

Table[GraphPlot[GraphData[g,"EdgeRules"]],{g,{{"GeneralizedPetersen",{9,2}},"ClebschGraph","TesseractGraph"}}]

Use (RefLink[ExampleData, paclet:ref/ExampleData]) for collections of sparse matrices:

GraphPlot[ExampleData[{"Matrix","Bai/dwa512"},"Matrix"]]

OpenersExampleSubsection1(Spacer1)Graph Styling  (5)

Give labels for some edges:

GraphPlot[{1->2,Labeled[2->3,"23"],3->1,2->4,2->5}]

Give vertex labels:

GraphPlot[{5->4,6->2,6->3,6->5,4->5,7->1,7->7,7->3,7->4,7->6},VertexLabels->"Name"]

Show edges as arrows:

GraphPlot[{1->6,2->6,3->6,4->6,5->6},DirectedEdges->True]

Plot a disconnected graph using different packing methods:

Table[Framed@GraphPlot[Table[i->Mod[i^2,102],{i,0,102}],GraphLayout->{"PackingLayout"->pm}],{pm,{Automatic,"ClosestPacking"}}]

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

GraphPlot[Table[i->Mod[i^2,500],{i,500}],VertexShapeFunction->None]

OpenersExampleSection2(Spacer1)Options  (71)

OpenersExampleSubsection2(Spacer1)DataRange  (1)

Specify the range of vertex coordinates:

GraphPlot[{1->2,2->3,3->4,4->1,2->4}, DataRange->{{0,1},{0,1}}]

OpenersExampleSubsection3(Spacer1)DirectedEdges  (1)

Show the direction of edges:

GraphPlot[{1->2,2->3,3->4,4->1,2->4},DirectedEdges-> True]

OpenersExampleSubsection4(Spacer1)GraphLayout  (66)

OpenersExampleSubsubsection0(Spacer1)"BalloonEmbedding"  (6)

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

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

"BalloonEmbedding" works best for tree graphs:

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

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

GraphPlot[KaryTree[48,5],GraphLayout->{"BalloonEmbedding", "EvenAngle"->#}]&/@{True,False}

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

GraphPlot[KaryTree[48,5],GraphLayout->{"BalloonEmbedding", "OptimalOrder"->#}]&/@{True,False}

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

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

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

GraphPlot[KaryTree[48,5],GraphLayout->{"BalloonEmbedding", "SectorAngles"->{1->Pi/2}}]

OpenersExampleSubsubsection1(Spacer1)"BipartiteEmbedding"  (1)

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

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

OpenersExampleSubsubsection2(Spacer1)"CircularEmbedding"  (2)

Place vertices on a circle:

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

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

GraphPlot[CompleteGraph[7],GraphLayout->{"CircularEmbedding", "Offset"->#}]&/@{Automatic,{30 Degree, 30 Degree},{50 Degree, 80 Degree}}

OpenersExampleSubsubsection3(Spacer1)"CircularMultipartiteEmbedding"  (2)

Place vertices on polygon lines based on a vertex partition:

GraphPlot[Flatten[Table[i\[UndirectedEdge]j,{i,4},{j,5,8}]],GraphLayout->{"CircularMultipartiteEmbedding", "VertexPartition"->{2,3,3}}]

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

GraphPlot[CompleteGraph[{3,3,2}],GraphLayout->{"CircularMultipartiteEmbedding", "VertexPartition"->{3,3,2}}]

OpenersExampleSubsubsection4(Spacer1)"DiscreteSpiralEmbedding"  (3)

Place vertices on a discrete spiral:

GraphPlot[Table[i\[UndirectedEdge]i+1,{i,11}],GraphLayout-> "DiscreteSpiralEmbedding"]

"DiscreteSpiralEmbedding" works best for path graphs:

GraphPlot[PathGraph[Range[30]],GraphLayout->"DiscreteSpiralEmbedding"]

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

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

OpenersExampleSubsubsection5(Spacer1)"GridEmbedding"  (2)

Place vertices on a grid:

GraphPlot[Table[i\[UndirectedEdge]Mod[i+3,8],{i,15}],GraphLayout->{"GridEmbedding","Dimension"->{4,4}}]

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

GraphPlot[GridGraph[{12,12}],GraphLayout->{"GridEmbedding","Dimension"->{12,12}}]

OpenersExampleSubsubsection6(Spacer1)"HighDimensionalEmbedding"  (2)

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

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"]

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

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};

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

OpenersExampleSubsubsection7(Spacer1)"LayeredEmbedding"  (6)

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

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

"LayeredEmbedding" works best for tree graphs:

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

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

GraphPlot[KaryTree[10,3],GraphLayout->{"LayeredEmbedding", LayerSizeFunction->(2&)}]

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

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

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

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

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

Table[GraphPlot[KaryTree[6,3],GraphLayout->{"LayeredEmbedding", "Orientation"->o}],{o,{Top,Bottom,Left,Right}}]

OpenersExampleSubsubsection8(Spacer1)"LayeredDigraphEmbedding"  (3)

Place vertices in a series of layers:

GraphPlot[{1\[DirectedEdge]2,1\[DirectedEdge]3,2\[DirectedEdge]3,1\[DirectedEdge]4,2\[DirectedEdge]4,1\[DirectedEdge]5}, GraphLayout->"LayeredDigraphEmbedding"]

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

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

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

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}}]

OpenersExampleSubsubsection9(Spacer1)"LinearEmbedding"  (2)

Place vertices on a line:

GraphPlot[{1\[UndirectedEdge]2,2\[UndirectedEdge]3,3\[UndirectedEdge]4},GraphLayout->"LinearEmbedding"]

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

Table[GraphPlot[CompleteGraph[4],GraphLayout->{"LinearEmbedding", Method->m}],{m,{"Spectral","SpectralOrdering","TwoNormApproximation","TwoNormApproximationOrdering"}}]

OpenersExampleSubsubsection10(Spacer1)"MultipartiteEmbedding"  (2)

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

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

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

GraphPlot[CompleteGraph[{3,2,4}],GraphLayout->{"MultipartiteEmbedding", "VertexPartition"->{3,2,4}}]

OpenersExampleSubsubsection11(Spacer1)"PlanarEmbedding"  (1)

Place vertices on a plane without an edge crossing:

GraphPlot[{1\[UndirectedEdge]2,1\[UndirectedEdge]3,1\[UndirectedEdge]4,2\[UndirectedEdge]3,2\[UndirectedEdge]4,3\[UndirectedEdge]4},GraphLayout->"PlanarEmbedding"]

OpenersExampleSubsubsection12(Spacer1)"RadialEmbedding"  (2)

Place vertices in concentric circles:

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

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

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

OpenersExampleSubsubsection13(Spacer1)"RandomEmbedding"  (1)

Place vertices randomly:

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

OpenersExampleSubsubsection14(Spacer1)"SpectralEmbedding"  (2)

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

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"]

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

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

OpenersExampleSubsubsection15(Spacer1)"SpiralEmbedding"  (2)

Place vertices on a spiral:

GraphPlot[Table[i\[UndirectedEdge]Mod[i+1,20,1],{i,20}],GraphLayout->"SpiralEmbedding"]

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

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

OpenersExampleSubsubsection16(Spacer1)"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:

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"]

With the setting "EdgeWeighted"->(RefLink[True, paclet:ref/True]), edge weights are used:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

OpenersExampleSubsubsection17(Spacer1)"SpringEmbedding"  (10)

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

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"]

With the setting "EdgeWeighted"->(RefLink[True, paclet:ref/True]), edge weights are used:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

OpenersExampleSubsubsection18(Spacer1)"StarEmbedding"  (3)

Place vertices on a star shape:

GraphPlot[Table[1\[UndirectedEdge]i,{i,2,6}],GraphLayout->"StarEmbedding"]

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

GraphPlot[StarGraph[15],GraphLayout->{"StarEmbedding", "Offset"->#}]&/@{Automatic,{30 Degree, 30 Degree},{50 Degree, 80 Degree}}

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

GraphPlot[StarGraph[15],GraphLayout->{"StarEmbedding", "Center"->#}]&/@{Automatic,10}

OpenersExampleSubsubsection19(Spacer1)"TutteEmbedding"  (2)

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

GraphPlot[{1\[UndirectedEdge]2,1\[UndirectedEdge]3,1\[UndirectedEdge]4,2\[UndirectedEdge]3,2\[UndirectedEdge]4,3\[UndirectedEdge]4},GraphLayout->"TutteEmbedding"]

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

GraphPlot[GraphData[{"JohnsonSkeleton",77},"EdgeList"],GraphLayout->"TutteEmbedding"]

OpenersExampleSubsection5(Spacer1)PlotStyle  (3)

Specify an overall style for the graph:

Table[GraphPlot[{1->2,2->3,3->4,1->4,1->3},PlotStyle->ps],{ps,{Red,Dashed,Directive[Red,Dashed]}}]

(RefLink[PlotStyle, paclet:ref/PlotStyle]) can be combined with (RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]), which has higher priority:

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

(RefLink[PlotStyle, paclet:ref/PlotStyle]) can be combined with (RefLink[EdgeShapeFunction, paclet:ref/EdgeShapeFunction]), which has higher priority:

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

OpenersExampleSection3(Spacer1)Applications  (27)

OpenersExampleSubsection6(Spacer1)Basic Applications  (3)

Label vertices and edges:

GraphPlot[{1\[UndirectedEdge]2,2\[UndirectedEdge]3,Labeled[3\[UndirectedEdge]1,"hello"]},VertexLabels->{2->"Name"}]

Plot a graph with "BalloonEmbedding":

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

Visualize large graphs:

GraphPlot[ExampleData[{"Matrix","Bai/cryg2500"},"Matrix"]]

OpenersExampleSubsection7(Spacer1)Graph Theory  (5)

Plot a complete graph on 10 nodes:

GraphPlot[ConstantArray[1,{10,10}]]

Plot a random graph on 10 nodes:

GraphPlot[RandomInteger[1,{10,10}]]

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

GraphPlot[RandomChoice[{0.01,0.99}->{1,0},{100,100}]]

A graph describing a simple relation:

GraphPlot[Table[i->Mod[2^i,21],{i,20}],PlotTheme->"ClassicDiagram"]

Draw the graph of a random permutation:

GraphPlot[Thread[Range[20]->RandomSample[Range[20]]]]

OpenersExampleSubsection8(Spacer1)Linguistic or Geographic Data  (3)

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

words=DictionaryLookup["wol*"];

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

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

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

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

Show the adjacent countries in South America:

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

OpenersExampleSubsection9(Spacer1)Number Properties  (11)

Numbers that have a common divisor:

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

Numbers that have no common divisor:

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

Link a number to another with a 1 bit inserted:

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"}]

Link a number to another with a 0 bit inserted:

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"}]

Link a number to another with 1 bit deleted:

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

Link a number to another that is one bit different:

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"}]

Link a number to another that is one bit reversed:

GraphPlot[Table[j->FromDigits[Reverse[IntegerDigits[j,2]],2],{j,0,2^9-1}]]

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

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

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

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

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

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

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

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

OpenersExampleSubsection10(Spacer1)Sparse Test Matrices  (3)

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

GraphPlot[ExampleData[{"Matrix","Boeing/nasa1824"},"Matrix"]]

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

GraphPlot[ExampleData[{"Matrix","HB/blckhole"},"Matrix"], VertexShapeFunction->None]

Use (RefLink[ArrayPlot, paclet:ref/ArrayPlot]) or (RefLink[MatrixPlot, paclet:ref/MatrixPlot]) to display sparse matrices:

g=ExampleData[{"Matrix","Boeing/nasa1824"},"Matrix"]

{ArrayPlot[g,MaxPlotPoints->100],MatrixPlot[g]}

OpenersExampleSubsection11(Spacer1)Finite State Diagrams  (2)

A finite state diagram describing the C preprocessor:

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"]

A finite state diagram for string matching:

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]

OpenersExampleSection4(Spacer1)Properties & Relations  (6)

Use (RefLink[LayeredGraphPlot, paclet:ref/LayeredGraphPlot]) for hierarchical-style drawing of directed graphs:

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"]

Use (RefLink[TreePlot, paclet:ref/TreePlot]) for different types of tree drawing:

TreePlot[Flatten[Table[{i-> 2i+j-1},{j,2},{i,7}]]]

Use (RefLink[GraphPlot3D, paclet:ref/GraphPlot3D]) to draw graphs in 3D:

GraphPlot3D[Table[i->Mod[i^2,200],{i,200}]]

GraphPlot3D[PolyhedronData["Dodecahedron","Skeleton","Rule"]]

Use (RefLink[GraphData, paclet:ref/GraphData]) for an extensive collection of predefined graphs and properties:

Short[GraphData[],3]

Get the connectivity and plot it:

GraphData["DesarguesGraph","EdgeRules"]

GraphPlot[%]

Use (RefLink[VertexCoordinates, paclet:ref/VertexCoordinates]) to use the embedding provided by (RefLink[GraphData, paclet:ref/GraphData]):

GraphPlot[GraphData["DesarguesGraph","Edges","Rule"],VertexCoordinates->GraphData["DesarguesGraph","VertexCoordinateRules"],PlotTheme->"SmallNetwork"]

Use (RefLink[PolyhedronData, paclet:ref/PolyhedronData]) for a large collection of polyhedra and properties:

PolyhedronData["Dodecahedron","Skeleton","Rule"]

GraphPlot[%]

Compare to a predefined embedding:

PolyhedronData["Dodecahedron","Skeleton"]

Use (RefLink[ExampleData, paclet:ref/ExampleData]) for a large collection of sparse matrices:

GraphPlot[ExampleData[{"Matrix","HB/can_292"},"Matrix"]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Graph, paclet:ref/Graph])  ▪  (RefLink[GraphPlot3D, paclet:ref/GraphPlot3D])  ▪  (RefLink[LayeredGraphPlot, paclet:ref/LayeredGraphPlot])  ▪  (RefLink[TreePlot, paclet:ref/TreePlot])  ▪  (RefLink[CommunityGraphPlot, paclet:ref/CommunityGraphPlot])  ▪  (RefLink[GraphEmbedding, paclet:ref/GraphEmbedding])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Graph Visualization, paclet:guide/GraphVisualization])}, {▪(RefLinkPlain[Computational Geometry, paclet:guide/ComputationalGeometry])}, {▪(RefLinkPlain[Data Visualization, paclet:guide/DataVisualization])}, {▪(RefLinkPlain[Computational Systems, paclet:guide/ComputationalSystemsAndDiscovery])}, {▪(RefLinkPlain[Social Network Analysis, paclet:guide/SocialNetworks])}, {▪(RefLinkPlain[Scientific Data Analysis, paclet:guide/ScientificDataAnalysis])}})}})