« View all new features in
Mathematica
9
◄
previous
|
next
►
New in
Mathematica
9
›
Enhanced Graphs and Networks
New and Enhanced Graph Layouts
Adding to an already rich set of graph layouts,
Mathematica
9 brings new capabilities to visualize graphs with structures such as planar graphs, multipartite graphs, and trees.
In[1]:=
X
graphs = { KaryTree[40, 5], Graph[{1 \[UndirectedEdge] 4, 1 \[UndirectedEdge] 5, 2 \[UndirectedEdge] 4, 2 \[UndirectedEdge] 6, 3 \[UndirectedEdge] 4, 3 \[UndirectedEdge] 7, 4 \[UndirectedEdge] 8, 5 \[UndirectedEdge] 8, 6 \[UndirectedEdge] 8, 7 \[UndirectedEdge] 8}], CompleteGraph[{3, 3, 2}], PathGraph[Range[25]], GridGraph[{5, 5}], Graph[{1 \[DirectedEdge] 3, 1 \[DirectedEdge] 6, 2 \[DirectedEdge] 6, 3 \[DirectedEdge] 8, 4 \[DirectedEdge] 2, 4 \[DirectedEdge] 3, 5 \[DirectedEdge] 1, 5 \[DirectedEdge] 2, 5 \[DirectedEdge] 7, 6 \[DirectedEdge] 3, 7 \[DirectedEdge] 6, 8 \[DirectedEdge] 5, 8 \[DirectedEdge] 7}], KnightTourGraph[10, 10], Graph[{1 \[UndirectedEdge] 2, 1 \[UndirectedEdge] 3, 1 \[UndirectedEdge] 5, 2 \[UndirectedEdge] 4, 2 \[UndirectedEdge] 6, 3 \[UndirectedEdge] 4, 3 \[UndirectedEdge] 7, 4 \[UndirectedEdge] 8, 5 \[UndirectedEdge] 6, 5 \[UndirectedEdge] 7, 6 \[UndirectedEdge] 8, 7 \[UndirectedEdge] 8}], Graph[Range[11], {1 \[UndirectedEdge] 5, 1 \[UndirectedEdge] 6, 2 \[UndirectedEdge] 5, 2 \[UndirectedEdge] 6, 3 \[UndirectedEdge] 7, 4 \[UndirectedEdge] 7, 4 \[UndirectedEdge] 6, 5 \[UndirectedEdge] 9, 11 \[UndirectedEdge] 7, 6 \[UndirectedEdge] 8, 6 \[UndirectedEdge] 10, 7 \[UndirectedEdge] 10, 6 \[UndirectedEdge] 11}], StarGraph[12], CompleteGraph[8], Graph[Table[ j -> FromDigits[Drop[IntegerDigits[j, 2], -1], 2], {j, 1, 200}]] }; layouts = {"BalloonEmbedding", "BipartiteEmbedding", {"CircularMultipartiteEmbedding", "VertexPartition" -> {3, 3, 2}}, "DiscreteSpiralEmbedding", {"GridEmbedding", "Dimension" -> {5, 5}}, "LayeredDigraphEmbedding", "SpectralEmbedding", "PlanarEmbedding", {"MultipartiteEmbedding", "VertexPartition" -> {4, 3, 4}}, "StarEmbedding", "LinearEmbedding", "RadialEmbedding"}; background = {Hue[.15, .3, .9], Hue[.7, .1, .7], Hue[.15, .2, .9], Hue[.2, .2, .7], Hue[.15, .2, .9], Hue[.5, .8, .7], Hue[.15, .5, .7], Hue[.5, .3, .7], Hue[.2, .3, .8], Hue[.15, .2, .8], Hue[.13, .2, .95], Hue[.2, .3, .5]}; label[{name_, __}] := Style[name, Directive[11, FontFamily -> "Helvetica"]]; label[name_] := Style[name, Directive[11, FontFamily -> "Helvetica"]]; Grid[Partition[ Item[Labeled[ SetProperty[#1, { GraphLayout -> #2, ImagePadding -> 15, ImageSize -> {155, 155}, EdgeStyle -> Directive[Thickness[.01], Brown], VertexStyle -> Lighter[ColorData[44, 8], .5], VertexSize -> .3}], label[#2], Top, FrameMargins -> {{0, 0}, {-10, -18}}], Background -> #3] & @@@ Transpose[{graphs, layouts, background}], 3, 3, 1, {}], Spacings -> {.5, 1}, Frame -> All, FrameStyle -> Directive[GrayLevel[.8]]]
Out[1]=