This resource function is obsolete. Use the built-in symbol LayeredGraphPlot3D instead.

Function Repository Resource:

LayeredGraphPlot3D

Source Notebook

Generate a layered 3D plot of a graph

Contributed by: Stephen Wolfram and Jan Mangaldan

ResourceFunction["LayeredGraphPlot3D"][g]

generates a layered 3D plot of the graph g.

Details and Options

ResourceFunction["LayeredGraphPlot3D"] takes the same options as Graph3D.

Examples

Basic Examples (1) 

Place vertices in a series of 3D layers:

In[1]:=
ResourceFunction["LayeredGraphPlot3D"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5}, {{{1, 2}, {1, 3}, {2, 3}, {1, 4}, {2, 4}, {1, 5}}, Null}]]}, 
TagBox[GraphicsGroupBox[GraphicsComplexBox[CompressedData["
1:eJxTTMoPSmViYGCwBmIQjQYcINQHe1QalzoY+LAfu3o43wFdfvm8jd3X7f/D
+UkTjT6UZP+D8/VuNOneaPoL5/MUL3JmbPsD5/9KBGn4jeAv8QchhHqbu7Pk
xX7C+YbqViIJJ77D+Wlg8A3OXwzW/gXOf2zRB0Sf4XxlJRD4BOcncm9L4N6G
8I/9y8l2Lye/g/P37AaB13C+Jci4xy/gfJDuBO5ncL4xGDyG88HBk/8Azj/H
3z2lcfltOF8856BYzsFrcL5kxS5Te51LcP6K9DePvp4/DedPsQM58DCc/+Dl
tT8bPHbC+f+0znTysa6wV7vFse921k57vZ38SitN/ttbegSkeoucsa/9vcpz
t90/+50nCj19+K7bvzp2scxM7q+9/qT3kVM3P7AvlW5ZKXX5t3279I+KhK5n
9nI/Dz5Mj/1ln9RwqbGd+639i/huebm9P+wTE+ytWqU/2V/wf5Bk++mbfXBe
3YoStm/2108cWH30zxd7jqxl3JPcftn/OaXza9udT/Z9R+dYKFb9tvf62GCz
Ve+TvRN7RH5j5x/75T4TV4dlfbRX0r+xflPJX3uBu7Hus/s/2OvYyv7aYv3P
ntv1rDyb7Xv7FEN1v457/+yFrMK5ZPTe2p/g/rZaJ/a/vdHMSL+KT6/sI850
Ci/a/t8+L+nKa6muF/ZixY9aXrz9b39k6vFHzF+fwtMvWvw4oMWPAyx+GKF8
tPhxQIsfB7T4cUCLHwe0+HGAxQ8AOkckNA==
"], {
{Hue[0.6, 0.7, 0.5], Opacity[0.7], Arrowheads[Medium], ArrowBox[{1, 2}, 0.030239520958083826`], ArrowBox[BezierCurveBox[{1, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 3}], 0.030239520958083826`], ArrowBox[BezierCurveBox[{1, 34, 35, 36, 37, 38, 39, 40, 41,
             42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 4}], 0.030239520958083826`], ArrowBox[{1, 5}, 0.030239520958083826`], ArrowBox[{2, 3}, 0.030239520958083826`], ArrowBox[{2, 4}, 0.030239520958083826`]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], DiskBox[1, 0.030239520958083826], DiskBox[2, 0.030239520958083826], DiskBox[3, 0.030239520958083826], DiskBox[4, 0.030239520958083826], DiskBox[5, 0.030239520958083826]}}]],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
ExpressionUUID -> "6036f2a0-267e-4657-8928-d302e4669ece",
DefaultBaseStyle->{"NetworkGraphics", FrontEnd`GraphicsHighlightColor -> Hue[0.8, 1., 0.6]},
FormatType->TraditionalForm,
FrameTicks->None]\)]
Out[1]=

Scope (2) 

Layered visualization of a graph with loops and multiedges:

In[2]:=
ResourceFunction["LayeredGraphPlot3D"][
 Graph[{1 -> 2, 1 -> 7, 1 -> 11, 2 -> 5, 1 -> 5, 5 -> 5, 1 -> 5}], 1]
Out[2]=

Visualize a directed acyclic graph:

In[3]:=
ResourceFunction["LayeredGraphPlot3D"][\!\(\*
GraphicsBox[
NamespaceBox["NetworkGraphics",
DynamicModuleBox[{Typeset`graph = HoldComplete[
Graph[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21}, {{{1, 2}, {1, 3}, {2, 4}, {3, 5}, {5, 6}, {2, 7}, {1, 8}, {2, 9}, {1, 10}, {8, 11}, {9, 12}, {7, 13}, {1, 14}, {8, 15}, {8, 16}, {16, 17}, {7, 18}, {9, 19}, {7, 20}, {
         17, 21}}, Null}]]}, 
TagBox[GraphicsGroupBox[GraphicsComplexBox[CompressedData["
1:eJxTTMoPSmViYGAQBWIQ3c274yZTBbtDYnLwb+FyRodXby9+T5rwzl5I9O+P
uUa/7K1sNH7duMLqAOMzQAFE/Ue4PDo/Acx/aJ+IQn+0h5jPBzcPwv8Hl4fQ
gnB5CM0FNx8mDjMf5h4Y/+z5vVXflgqjmc/ngG4+Oh/dvah8RjT5j2jygg4w
dwAAYkCWww==
"], {
{Hue[0.6, 0.7, 0.5], Opacity[0.7], Arrowheads[0.021652196047244082`], ArrowBox[{{1, 2}, {1, 3}, {1, 8}, {1, 10}, {1, 14}, {2, 4}, {2, 7}, {2, 9}, {3, 5}, {5, 6}, {7, 13}, {7, 18}, {7, 20}, {8, 11}, {8, 15}, {8, 16}, {9, 12}, {9, 19}, {16, 17}, {17, 21}}, 0.04254286753157144]}, 
{Hue[0.6, 0.2, 0.8], EdgeForm[{GrayLevel[0], Opacity[0.7]}], DiskBox[1, 0.04254286753157144], DiskBox[2, 0.04254286753157144], DiskBox[3, 0.04254286753157144], DiskBox[4, 0.04254286753157144], DiskBox[5, 0.04254286753157144], DiskBox[6, 0.04254286753157144], DiskBox[7, 0.04254286753157144], DiskBox[8, 0.04254286753157144], DiskBox[9, 0.04254286753157144], DiskBox[10, 0.04254286753157144], DiskBox[11, 0.04254286753157144], DiskBox[12, 0.04254286753157144], DiskBox[13, 0.04254286753157144], DiskBox[14, 0.04254286753157144], DiskBox[15, 0.04254286753157144], DiskBox[16, 0.04254286753157144], DiskBox[17, 0.04254286753157144], DiskBox[18, 0.04254286753157144], DiskBox[19, 0.04254286753157144], DiskBox[20, 0.04254286753157144], DiskBox[21, 0.04254286753157144]}}]],
MouseAppearanceTag["NetworkGraphics"]],
AllowKernelInitialization->False]],
ExpressionUUID -> "490fd128-85b7-4327-b6e6-d4ea3f2e92c8",
DefaultBaseStyle->{"NetworkGraphics", FrontEnd`GraphicsHighlightColor -> Hue[0.8, 1., 0.6]},
FormatType->TraditionalForm,
FrameTicks->None]\)]
Out[3]=

Version History

  • 2.0.0 – 16 March 2020
  • 1.0.0 – 09 March 2020

License Information