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

OpenersNotesSection(Spacer1)Details and Options

(RefLink[LayeredGraphPlot, paclet:ref/LayeredGraphPlot]) attempts to place vertices in a series of "layers".

(RefLink[LayeredGraphPlot, paclet:ref/LayeredGraphPlot]) 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[LayeredGraphPlot, paclet:ref/LayeredGraphPlot]) by default puts "dominant" vertices at the top, and puts vertices lower in the "hierarchy" progressively further down.

(RefLink[LayeredGraphPlot, paclet:ref/LayeredGraphPlot])[g,pos] places the dominant vertices at position pos. Possible positions are: (RefLink[Top, paclet:ref/Top]), (RefLink[Bottom, paclet:ref/Bottom]), (RefLink[Left, paclet:ref/Left]), (RefLink[Right, paclet:ref/Right]).

By default, (RefLink[LayeredGraphPlot, paclet:ref/LayeredGraphPlot]) places each dominant vertex at the top.

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

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  (29)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Plot a graph:

LayeredGraphPlot[PetersenGraph[]]

Plot a graph specified by edge rules:

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

Plot a graph specified by its adjacency matrix:

LayeredGraphPlot[{{0,1,1,1,1},{0,0,1,1,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}}]

Drawing a graph with different orientation from the default:

LayeredGraphPlot[{1->2,1->3,2->3,1->4,2->4,1->5},Left]

OpenersExampleSection1(Spacer1)Scope  (9)

OpenersExampleSubsection0(Spacer1)Graph Specification  (4)

Specify a graph using a graph:

LayeredGraphPlot[Graph[{0\[DirectedEdge]3,0\[DirectedEdge]5,0\[DirectedEdge]8,0\[DirectedEdge]10,3\[DirectedEdge]8}]]

Specify a graph using a rule list:

LayeredGraphPlot[{0->3,0->5,0->8,0->10,3->8}]

Specify a graph using a dense adjacency matrix:

LayeredGraphPlot[{{0,1,1,1,1},{0,0,0,1,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}}]

Specify a graph using a sparse adjacency matrix:

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

OpenersExampleSubsection1(Spacer1)Graph Styling  (5)

Give labels for some edges:

LayeredGraphPlot[{1->2,1->7,1->11,2->5,Labeled[1->5,"1->5"]}]

Give vertex labels:

LayeredGraphPlot[{1->2,1->7,1->11,2->5,1->5,5->5,1->5},VertexLabels->Automatic]

Show edges as lines:

LayeredGraphPlot[{1->2,1->7,1->11,2->5,1->5},DirectedEdges->False]

Plot a disconnected graph using different packing methods:

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

Draw with different orientations:

Row@Table[LayeredGraphPlot[{1->3,1->4,1->5,3->5,3->6},pos,PlotLabel->pos],{pos,{Left,Top,Right,Bottom}}]

OpenersExampleSection2(Spacer1)Options  (6)

OpenersExampleSubsection2(Spacer1)DataRange  (1)

Specify the range of vertex coordinates:

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

OpenersExampleSubsection3(Spacer1)DirectedEdges  (2)

By default edges are shown as arrows:

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

Do not show the direction of edges:

LayeredGraphPlot[{1->2,1->3,2->3,1->4,2->4},DirectedEdges-> False]

OpenersExampleSubsection4(Spacer1)PlotStyle  (3)

Specify an overall style for the graph:

Table[LayeredGraphPlot[{1->4,1->9,4->5,0->5,3->5,3->8,3->9},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:

LayeredGraphPlot[{1->4,1->9,4->5,0->5,3->5,3->8,3->9},PlotStyle->Directive[PointSize[Large],Red],VertexShapeFunction->Function[{p,l},{Green,Point[p]}]]

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

LayeredGraphPlot[{1->4,1->9,4->5,0->5,3->5,3->8,3->9},PlotStyle->Directive[Dashed,Red],EdgeShapeFunction->Function[{p,vl},{Green,Line[p]}]]

OpenersExampleSection3(Spacer1)Applications  (5)

A food chain:

LayeredGraphPlot[{"John"->"plants","lion"->"John","tiger"->"John","tiger"->"deer","lion"->"deer","deer"->"plants","mosquito"->"lion","frog"->"mosquito","mosquito"->"tiger","John"->"cow","cow"->"plants","mosquito"->"deer","mosquito"->"John","snake"->"frog","vulture"->"snake"},Left, PlotTheme->"DiagramGreen"]

A chart showing the relationships between shapes:

LayeredGraphPlot[{"Square"->"Rectangle","Rectangle"->"Parallelogram","Parallelogram"->"Four-Sided Polygon","Trapezoid"->"Four-Sided Polygon","Rectangle"->"Trapezoid","Four-Sided Polygon"->"Polygon","Polygon"->"Shape","Circle"->"Ellipsoid","Ellipsoid"->"Shape","Triangle"->"Polygon","Equilateral Triangle"->"Isosceles Triangle","Isosceles Triangle"->"Triangle"},PlotTheme->"DiagramBlue", VertexSize->{.4,.15}, AspectRatio->1.5]

A flow chart for a computer program:

LayeredGraphPlot[{"Total"->"TotalDispatch","TotalList"->"CheckThreading","TotalList"->"TotalDispatch","TotalSparse"->"TotalDispatch","TotalSparse"->"TotalDispatch","TotalDispatch"->"TotalDispatch","TotalDispatch"->"TotalList","TotalDispatch"->"TotalPacked","TotalDispatch"->"TotalSparse"},PlotTheme->"DiagramBlue", VertexSize->{.4,.15}]

A visual representation of a straight-line program, used for common subexpression elimination:

f[x_]:=Module[{e1,e2,e3,e4},e1=x+1;e2=Exp[x e1]+1; e3=e1+Sin[x e2]; x+e3+e1]

LayeredGraphPlot[{x->f,e3->f,e1->f,e1->e3,x->e3,e2->e3,x->e2,e1->e2,x->e1},PlotTheme->"ClassicDiagram"]

The relationships between early versions of the Unix operating system:

g={"5th Edition"->"6th Edition","5th Edition"->"PWB 1.0","6th Edition"->"1 BSD","6th Edition"->"Interdata","6th Edition"->"LSX","6th Edition"->"Mini Unix","6th Edition"->"Wollongong","PWB 1.0"->"PWB 1.2","PWB 1.0"->"USG 1.0","1 BSD"->"2 BSD","Interdata"->"PWB 2.0","Interdata"->"Unix/TS 3.0","Interdata"->"7th Edition","PWB 1.2"->"PWB 2.0","USG 1.0"->"USG 2.0","USG 1.0"->"CB Unix 1","7th Edition"->"2 BSD","7th Edition"->"32V","7th Edition"->"Xenix","7th Edition"->"Ultrix-11","7th Edition"->"UniPlus+","7th Edition"->"V7M","PWB 2.0"->"Unix/TS 3.0","USG 2.0"->"USG 3.0","CB Unix 1"->"CB Unix 2","32V"->"3 BSD","Unix/TS 1.0"->"Unix/TS 3.0","USG 3.0"->"Unix/TS 3.0","CB Unix 2"->"CB Unix 3","3 BSD"->"4 BSD","V7M"->"Ultrix-11","Unix/TS 3.0"->"TS 4.0","CB Unix 3"->"Unix/TS++","CB Unix 3"->"PDP-11 Sys V","4 BSD"->"4.1 BSD","Unix/TS++"->"TS 4.0","4.1 BSD"->"8th Edition","4.1 BSD"->"4.2 BSD","4.1 BSD"->"2.8 BSD","2 BSD"->"2.8 BSD","TS 4.0"->"System V.0","4.2 BSD"->"4.3 BSD","4.2 BSD"->"Ultrix-32","2.8 BSD"->"2.9 BSD","2.8 BSD"->"Ultrix-11","System V.0"->"System V.2","8th Edition"->"9th Edition","System V.2"->"System V.3"};

LayeredGraphPlot[g, PlotTheme->"ClassicDiagram", VertexSize->{.5,.1}]

OpenersExampleSection4(Spacer1)Properties & Relations  (3)

(RefLink[TreePlot, paclet:ref/TreePlot]) provides a layered layout ignoring the direction of edges:

{TreePlot[{1->4,1->6,1->8,2->6,3->8,4->5,7->8,1->7},DirectedEdges->True,VertexLabels->"Name"],LayeredGraphPlot[{1->4,1->6,1->8,2->6,3->8,4->5,7->8,1->7},DirectedEdges->True,VertexLabels->"Name"]}

Use (RefLink[GraphPlot, paclet:ref/GraphPlot]) or (RefLink[GraphPlot3D, paclet:ref/GraphPlot3D]) for general undirected graph drawing:

g={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};

{GraphPlot[g],GraphPlot3D[g]}

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

g=ExampleData[{"Matrix","Bai/bfwa62"},"Matrix"]

{ArrayPlot[g],MatrixPlot[g]}

OpenersExampleSection5(Spacer1)Possible Issues  (1)

When vertex coordinates are specified, all edges are shown as straight lines:

LayeredGraphPlot[{1->2,2->3,3->4,1->4},VertexLabels->"Name",VertexCoordinates->{{0,2},{0,1},{0,0},{2,-1}}]

If explicit vertex coordinates are not specified, curved edges will be used:

LayeredGraphPlot[{1->2,2->3,3->4,1->4},VertexLabels->"Name"]

OpenersExampleSection6(Spacer1)Neat Examples  (1)

Plot isotope decay networks:

DaughterNuclides[s_List]:=DeleteCases[Union[Apply[Join,Map[IsotopeData[#,"DaughterNuclides"]&,DeleteCases[s,_Missing]]]],_Missing]

ReachableNuclides[s_List]:=FixedPoint[Union[Join[#,DaughterNuclides[#]]]&,s]

DecayNetwork[iso_List]:=
Apply[Join,Map[Thread[#->DaughterNuclides[{#}]]&,ReachableNuclides[iso]]]

DecayNetworkPlot[s_]:=LayeredGraphPlot[Map[IsotopeData[#,"Symbol"]&,DecayNetwork[{s}],{2}],PerformanceGoal->"Quality",VertexShapeFunction->(Text[Framed[Style[#2,8, Black],Background->LightYellow],#1]&)]

Uranium-235:

DecayNetworkPlot["Uranium235"]

Polonium-189:

DecayNetworkPlot["Polonium189"]

Plutonium-239:

DecayNetworkPlot["Plutonium239"]

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

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Graph Visualization, paclet:guide/GraphVisualization])}, {▪(RefLinkPlain[Data Visualization, paclet:guide/DataVisualization])}, {▪(RefLinkPlain[Social Network Analysis, paclet:guide/SocialNetworks])}})}})