gives a list of vertex degrees for the vertices in the underlying simple graph of g.
DegreeCentrality[g,"In"]
gives a list of vertex in-degrees.
DegreeCentrality[g,"Out"]
gives a list of vertex out-degrees.
DegreeCentrality[{vw,…},…]
uses rules vw to specify the graph g.
DegreeCentrality
gives a list of vertex degrees for the vertices in the underlying simple graph of g.
DegreeCentrality[g,"In"]
gives a list of vertex in-degrees.
DegreeCentrality[g,"Out"]
gives a list of vertex out-degrees.
DegreeCentrality[{vw,…},…]
uses rules vw to specify the graph g.
Details
- DegreeCentrality will give high centralities to vertices that have high vertex degrees.
- The vertex degree for a vertex
is the number of edges incident to
. - For a directed graph, the in-degree is the number of incoming edges and the out-degree is the number of outgoing edges.
- For an undirected graph, in-degree and out-degree coincide.
- DegreeCentrality works with undirected graphs, directed graphs, multigraphs, and mixed graphs.
Examples
open all close allBasic Examples (2)
g = ExampleData[{"NetworkGraph", "Friendship"}];DegreeCentrality[g]HighlightGraph[g, VertexList[g], VertexSize -> Thread[VertexList[g] -> Rescale[%]]]Rank vertices. Highest-ranked vertices have the most connections to other vertices:
g = ExampleData[{"NetworkGraph", "Friendship"}];Part[VertexList[g], Ordering[DegreeCentrality[g], All, Greater]]Scope (7)
DegreeCentrality works with undirected graphs:
DegreeCentrality[[image]]DegreeCentrality[[image]]DegreeCentrality[[image]]DegreeCentrality[[image]]Use rules to specify the graph:
DegreeCentrality[{1 -> 3, 2 -> 1, 3 -> 6, 4 -> 6, 1 -> 5, 5 -> 4, 6 -> 1}]Compute in-degree and out-degree:
DegreeCentrality[[image], "In"]DegreeCentrality[[image], "Out"]DegreeCentrality works with large graphs:
g = GridGraph[{10, 10, 10, 10}];DegreeCentrality[g]//Short//TimingApplications (8)
Rank vertices by their influence on other vertices in their immediate neighborhood:
g = [image];SortBy[{VertexList[g], DegreeCentrality[g]}, Last]//ReverseHighlight the degree centrality for CycleGraph:
HighlightCentrality[g_, cc_] := HighlightGraph[g, Table[Style[VertexList[g][[i]], ColorData["TemperatureMap"][cc[[i]] / Max[cc]]], {i, VertexCount[g]}]];g = CycleGraph[8, VertexSize -> Large];cc = DegreeCentrality[g];HighlightCentrality[g, cc]g = GridGraph[{10, 10}, VertexSize -> Large];cc = DegreeCentrality[g];HighlightCentrality[g, cc]g = CompleteKaryTree[3, 3, VertexSize -> Large];cc = DegreeCentrality[g];HighlightCentrality[g, cc]g = PathGraph[Range[20], VertexSize -> Large];cc = DegreeCentrality[g];HighlightCentrality[g, cc]A friendship network in a school. Find the most popular students:
g = [image];c = DegreeCentrality[g];Pick[VertexList[g], c, Max[c]]A citation network from the High Energy Physics Phenomenology section of the arXiv e-Print archive. Find the top 10 most-cited articles:
g = ExampleData[{"NetworkGraph", "HighEnergyPhysicsPhenomenology"}];c = DegreeCentrality[g, "In"];Part[VertexList[g], Ordering[c, -10]]Find the basal species or producers in a food chain:
g = ExampleData[{"NetworkGraph", "SimpleFoodWeb"}]With[{d = DegreeCentrality[g, "In"]}, Pick[VertexList[g], d, 0]]Find the top species or apex predators:
With[{d = DegreeCentrality[g, "Out"]}, Pick[VertexList[g], d, 0]]A network of email sent to the MathGroup list in November 2011. Construct a social network of users, with an edge from
to
if
has sent at least one reply to
. Find the users who are the most active at answering questions:
g = [image];d = DegreeCentrality[g, "Out"];Pick[VertexList[g], d, Max[d]]Count the users who only received replies and did not send any replies:
Length[Pick[VertexList[g], d, 0]]Find the users who asked questions most often:
d = DegreeCentrality[g, "In"];Pick[VertexList[g], d, Max[d]]Count the users who only sent replies and did not receive any replies:
Length[Pick[VertexList[g], d, 0]]The internet at the level of autonomous systems. The frequency of the degree centrality follows a power-law distribution:
g = ExampleData[{"NetworkGraph", "Internet"}];c = DegreeCentrality[g];Histogram[c, {"Log", 30}, {"Log", "SF"}]Obtain the maximum likelihood parameter estimates, assuming a Zipf distribution:
EstimatedDistribution[Tally[c][[All, -1]], ZipfDistribution[ρ]]PDF[%, k]For graphs with
vertices, the largest sum in differences in degree centrality between the most central vertex and all other vertices is
:
n = 10;
g = StarGraph[n];
c = DegreeCentrality[g];{Total[Max[c] - c], (n - 1)(n - 2)}Measure how central the most central vertex is with respect to other vertices:
centralization[g_] := With[{c = DegreeCentrality[g], n = VertexCount[g]}, N[Total[Max[c] - c] / ((n - 1)(n - 2))]]Centralization of social networks:
centralization[ExampleData[{"NetworkGraph", "ZacharyKarateClub"}]]centralization[ExampleData[{"NetworkGraph", "DolphinSocialNetwork"}]]Properties & Relations (5)
The degree of a vertex of an undirected graph is the number of edges incident to the vertex:
g = [image];DegreeCentrality[g]Table[EdgeCount[g, i_], {i, VertexList[g]}]For an undirected graph, the in-degree and out-degree centralities coincide:
g = WheelGraph[6]DegreeCentrality[g, "In"] == DegreeCentrality[g, "Out"]Use VertexDegree to obtain the degree of a specific vertex:
g = ExampleData[{"NetworkGraph", "Friendship"}];VertexDegree[g, "Anna"]DegreeCentrality is equivalent to VertexDegree for simple graphs:
g = [image];DegreeCentrality[SimpleGraph[g]] == VertexDegree[SimpleGraph[g]]For a directed graph, the sum of in- and out-degree centralities is equal to the vertex degree:
g = Graph[{12, 23, 31, 34}]DegreeCentrality[g, "In"] + DegreeCentrality[g, "Out"]VertexDegree[g]Related Guides
Text
Wolfram Research (2010), DegreeCentrality, Wolfram Language function, https://reference.wolfram.com/language/ref/DegreeCentrality.html (updated 2015).
CMS
Wolfram Language. 2010. "DegreeCentrality." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/DegreeCentrality.html.
APA
Wolfram Language. (2010). DegreeCentrality. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DegreeCentrality.html
BibTeX
@misc{reference.wolfram_2026_degreecentrality, author="Wolfram Research", title="{DegreeCentrality}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/DegreeCentrality.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_degreecentrality, organization={Wolfram Research}, title={DegreeCentrality}, year={2015}, url={https://reference.wolfram.com/language/ref/DegreeCentrality.html}, note=[Accessed: 13-June-2026]}