New in Wolfram
Mathematica
8: Graph & Network Analysis
◄
previous
|
next
►
Application Areas
Visualize Eulerian Cycles
Find Eulerian cycles.
In[1]:=
X
Manipulate[ HighlightGraph[ g1, {eulercycle[[1, 1]], MapIndexed[Labeled[#1, Placed[First[#2], {1/2, {1/2, 0}}]] &, eulercycle[[1 ;; n]]]}, GraphHighlightStyle -> "Thick", ImageSize -> {400, 300}], {n, 0, EdgeCount[g1], 1}, Initialization :> (g1 = \!\(\* GraphicsBox[ NamespaceBox["NetworkGraphics", DynamicModuleBox[{Typeset`graph = HoldComplete[ Graph[{"v1", "v4", "v8", "v2", "v3", "v5", "v6", "v7"}, { Null, {{1, 2}, {1, 3}, {4, 2}, {4, 3}, {5, 6}, {5, 7}, {2, 8}, {2, 3}, {6, 7}, {6, 8}, {6, 3}, {7, 8}, {7, 3}, {8, 3}}}]], Typeset`boxes = GraphicsGroupBox[{{ Directive[ Hue[0.6, 0.2, 0.8], EdgeForm[ Directive[ GrayLevel[0], Opacity[0.7]]]], TagBox[ DiskBox[{0., 1.5001983323633388`}, 0.03198204512128562], "DynamicName", BoxID -> "VertexID$1"], TagBox[ DiskBox[{0.3518614300275378, 0.851519673626847}, 0.03198204512128562], "DynamicName", BoxID -> "VertexID$2"], TagBox[ DiskBox[{1.059147719400799, 0.735134353379667}, 0.03198204512128562], "DynamicName", BoxID -> "VertexID$3"], TagBox[ DiskBox[{0.12413277051821736`, 0.}, 0.03198204512128562], "DynamicName", BoxID -> "VertexID$4"], TagBox[ DiskBox[{3.246573951865002, 0.7332978216024789}, 0.03198204512128562], "DynamicName", BoxID -> "VertexID$5"], TagBox[ DiskBox[{2.2199039245077112`, 0.5182380464864496}, 0.03198204512128562], "DynamicName", BoxID -> "VertexID$6"], TagBox[ DiskBox[{2.30515567145384, 1.1294117203451886`}, 0.03198204512128562], "DynamicName", BoxID -> "VertexID$7"], TagBox[ DiskBox[{1.4934874091486072`, 1.1771162617999784`}, 0.03198204512128562], "DynamicName", BoxID -> "VertexID$8"]}, { Directive[ Opacity[0.7], Hue[0.6, 0.7, 0.5]], LineBox[{{ DynamicLocation["VertexID$1", Automatic, Center], DynamicLocation["VertexID$2", Automatic, Center]}, { DynamicLocation["VertexID$1", Automatic, Center], DynamicLocation["VertexID$3", Automatic, Center]}, { DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$4", Automatic, Center]}, { DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$8", Automatic, Center]}, { DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$3", Automatic, Center]}, { DynamicLocation["VertexID$3", Automatic, Center], DynamicLocation["VertexID$4", Automatic, Center]}, { DynamicLocation["VertexID$3", Automatic, Center], DynamicLocation["VertexID$6", Automatic, Center]}, { DynamicLocation["VertexID$3", Automatic, Center], DynamicLocation["VertexID$7", Automatic, Center]}, { DynamicLocation["VertexID$3", Automatic, Center], DynamicLocation["VertexID$8", Automatic, Center]}, { DynamicLocation["VertexID$5", Automatic, Center], DynamicLocation["VertexID$6", Automatic, Center]}, { DynamicLocation["VertexID$5", Automatic, Center], DynamicLocation["VertexID$7", Automatic, Center]}, { DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$7", Automatic, Center]}, { DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$8", Automatic, Center]}, { DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$8", Automatic, Center]}}]}}]}, DynamicBox[GraphComputation`NetworkGraphicsBox[ 1, Typeset`graph, Typeset`boxes], { CachedValue :> Typeset`boxes, SingleEvaluation -> True, SynchronousUpdating -> False, TrackedSymbols :> {}}, ImageSizeCache->{{0.7800000000000007, 88.22000000000003}, {-24.291199999999996`, 18.077475933525605`}}]]], DefaultBaseStyle->{ "NetworkGraphics", FrontEnd`GraphicsHighlightColor -> Hue[0.8, 1., 0.6]}, FrameTicks->None]\); eulercycle = FindEulerianCycle[g1, 1][[1]])]
Out[1]=
Play Animation
»
Stop Animation
»