# Order vertices by degree in CircularEmbedding for graphs

I would like to draw a graph in circular layout but I would like to position the vertices in descending order on the circle. Can this be done in an easy way?

Sort the vertices first. Here is an example graph:

SeedRandom[1]
g = RandomGraph[{20,40}]

We can use DegreeCentrality to get all of the degrees:

DegreeCentrality[g]

{5, 4, 5, 4, 6, 2, 4, 3, 1, 4, 4, 3, 5, 4, 5, 2, 4, 3, 5, 7}

So, the following should do what you want:

Graph[
VertexList[g][[Ordering[DegreeCentrality[g]]]],
EdgeList[g],
GraphLayout->"CircularEmbedding"
]

• Any reason you chose DegreeCentrality over VertexDegree? Commented Jul 23, 2018 at 5:21

Suppose you already have some graph properties (such as edge or vertex weights) or some graph styling. The IGReorderVertices convenience function from IGraph/M makes it easy to preserve these properties during reordering.

Here's a styled graph:

g = RandomGraph[BarabasiAlbertGraphDistribution[20, 3], VertexSize -> Large, EdgeStyle -> Gray] //
IGVertexMap[ColorData["SolarColors"], VertexStyle -> Rescale@*VertexDegree]

And here it is with circular layout:

IGReorderVertices[
VertexList[g][[ Ordering@VertexDegree[g] ]],
Graph[g, GraphLayout -> "CircularEmbedding"]
]

### GraphPropertyChart

GraphComputationGraphPropertyChart is an alternative way to visualize vertex degree centralities using a circular layout.

Using Carl Wolls' example:

SeedRandom[1]
g = RandomGraph[{20, 40}];
dc = DegreeCentrality[g];
ordering = Ordering[dc];

GraphComputationGraphPropertyChart[g, Automatic -> dc[[ordering]],
ChartStyle -> "SolarColors"] /. False -> True

Or, remove the annuli and disks from the callout lines:

GraphComputationGraphPropertyChart[g, Automatic -> dc[[ordering]],
ChartElementFunction -> None,