4
$\begingroup$

A circular embedding is a graph embedding in which all graph vertices lie on a common circle, usually arranged so they are equally spaced around the circumference.

If I only specify that some of the vertices are on a circle while the others are placed inside the circle (or arranged randomly), how should I handle it? For example,

    TrapezohedralGraph[n_] :=
     Module[{c}, c = CycleGraph[n]; VertexAdd[c, {n + 1, n + 2}]; 
      EdgeAdd[c, 
       Flatten[{Table[n + 1 <-> i, {i, 1, n, 2}], 
         Table[n + 2 <-> i, {i, 2, n, 2}]}]]]
TrapezohedralGraph[20]

enter image description here

But I love the following embedding from the web Trapezohedral Graph:

enter image description here

$\endgroup$

1 Answer 1

6
$\begingroup$

Use the option VertexCoordinates to place the first n vertices on the unit circle and the last two vertices on a smaller circle.

Use the second argument in trapezohedralGraph to specify the horizontal coordinate of last two vertices.

trapezohedralGraph = Graph[TrapezohedralGraph[#], 
  VertexCoordinates -> Join[ CirclePoints[#], CirclePoints[#2, 2]], ##3] &;

trapezohedralGraph[20, .3, VertexStyle -> Red]

enter image description here

Alternatively, define trapezohedronGraph as GraphUnion of CycleGraph and two StarGraphs (one with odd vertices and the second with even vertices):

ClearAll[trapezohedronGraph]

trapezohedronGraph = GraphUnion[
  CycleGraph @ #,
  Map[Splice@Thread[Most@# <-> Last @ #] &] @ {#, # + 1} & @ Range[1, # + 2, 2],
  VertexCoordinates -> Join[ CirclePoints[#], CirclePoints[#2, 2]], ##3] &;

Multicolumn[
 trapezohedronGraph[#, .3, VertexStyle -> Red, PlotLabel -> #] & /@ 
  Range[4, 22, 2], 5, Appearance -> "Horizontal"]

enter image description here

Add the option

EdgeShapeFunction ->
   (GraphComputation`GraphElementData[
   {"CurvedArc", 
    "Curvature" -> ((1/3) Sign[#[[1, 1]]] Order @@ #[[{1, -1}, 2]])}][##] &)

to get

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.