# Plotting a graph with its vertices on a circle

If have the following code.

AdjacencyGraph[Table[Boole[CoprimeQ[i - j, 8]], {j, 0, 7}, {i, 0, 7}]]


This generates a graph with 8 vertices. If the vertices are labeled 0, 1, ..., 7, where two vertices are adjacent whenever their difference is relatively prime to 8 (so 3 and 6 are adjacent since 6 - 3 = 3 is relatively prime to 8). I would like to have the graph drawn so that the vertices are in specific positions. Specifically, I would like to have the vertices 0, 1, ..., 7 evenly spaced around a circle in this order. In other words, this the graph should look like a regular octagon with additional edges inside. Is there a way to modify my code so that the vertices get drawn in this way?

You can use the option GraphLayout -> "CircularEmbedding":

k = 7;
Table[Boole[CoprimeQ[i - j, k + 1]], {j, 0, k}, {i, 0, k}],
GraphLayout -> "CircularEmbedding",
VertexLabels -> Placed["Name", Center], VertexSize -> Medium]


You can also use RelationGraph to get the same result:

RelationGraph[CoprimeQ[# - #2, k + 1] &, Range[0, k],
GraphLayout -> "CircularEmbedding",
VertexLabels -> Placed["Name", Center], VertexSize -> Medium]


same picture

• Is it true? k = 7; AdjacencyGraph[Range[0, k], Table[Boole[CoprimeQ[i - j, k + 1]], {j, 0, k}, {i, 0, k}], GraphLayout -> "CircularEmbedding", VertexLabels -> Placed["Name", Center], VertexSize -> Medium] Feb 12 '19 at 7:39
• @minhthien_2016, yes.
– kglr
Feb 12 '19 at 7:41