New in Wolfram
Mathematica
8: Graph & Network Analysis
◄
previous
|
next
►
Application Areas
Color Cycle Decompositions
Color cycle decompositions in complete graphs on a prime number of vertices.
In[1]:=
X
ColoringCycles[n_] := Block[{i, e}, e = Table[ Mod[#, n, 1] \[UndirectedEdge] Mod[# + i, n, 1] & /@ Range[n], {i, (n - 1)/2}]; HighlightGraph[ CompleteGraph[n, PlotLabel -> Style[n, 11, FontFamily -> "Verdana"]], Table[Style[e[[i]], ColorData[1][i]], {i, Length[e]}], ImageSize -> {150, 150}]];
In[2]:=
X
graphs = ColoringCycles[#] & /@ {3, 5, 7, 9, 11, 13};
In[3]:=
X
Grid[Partition[graphs, 3], Frame -> All, FrameStyle -> LightGray]
Out[3]=