VertexDegree[g]
gives the list of vertex degrees for all vertices in the graph g.
VertexDegree[g,v]
gives the vertex degree for the vertex v.
VertexDegree[{vw,…},…]
uses rules vw to specify the graph g.
VertexDegree
VertexDegree[g]
gives the list of vertex degrees for all vertices in the graph g.
VertexDegree[g,v]
gives the vertex degree for the vertex v.
VertexDegree[{vw,…},…]
uses rules vw to specify the graph g.
Details
- VertexDegree is also known as valence.
- The vertex degree for a vertex v is the number of edges incident to v.
- For a directed graph g, an edge is incident to a vertex whether it is an in-edge or an out-edge.
Examples
open all close allBasic Examples (3)
Find the degree for each vertex:
VertexDegree[[image]]Find the degree for a specified vertex:
VertexDegree[[image], 2]Vertex degrees of the HararyGraph:
HararyGraph[3, 5, VertexShapeFunction -> "Name"]VertexDegree[%]Scope (6)
VertexDegree works with undirected graphs:
VertexDegree[[image]]VertexDegree[[image]]VertexDegree[[image]]VertexDegree[[image], 5]Use rules to specify the graph:
VertexDegree[{1 -> 2, 2 -> 3, 3 -> 1, 3 -> 4}]VertexDegree works with large graphs:
GridGraph[{10, 10, 10, 10}];VertexDegree[%]//Timing//ShortApplications (4)
Highlight the vertex by its vertex degree for CycleGraph:
HighlightVertexDegree[g_, vd_] := HighlightGraph[g, Table[Style[VertexList[g][[i]], ColorData["TemperatureMap"][vd[[i]] / Max[vd]]], {i, VertexCount[g]}]];g = CycleGraph[8, VertexSize -> Large];vd = VertexDegree[g];HighlightVertexDegree[g, vd]g = StarGraph[10, VertexSize -> Large];vd = VertexDegree[g];HighlightVertexDegree[g, vd]g = GridGraph[{10, 10}, VertexSize -> Large];vd = VertexDegree[g];HighlightVertexDegree[g, vd]g = CompleteKaryTree[3, 3, VertexSize -> Large];vd = VertexDegree[g];HighlightVertexDegree[g, vd]g = TreeGraph[{12, 13, 14, 25, Table[ii + 1, {i, 5, 10}]}//Flatten, VertexSize -> Large];vd = VertexDegree[g];HighlightVertexDegree[g, vd]g = PathGraph[Range[20], VertexSize -> Large];vd = VertexDegree[g];HighlightVertexDegree[g, vd]g = RandomGraph[BarabasiAlbertGraphDistribution[50, 5], VertexSize -> {"Scaled", 0.03}, BaseStyle -> EdgeForm[None]];vd = VertexDegree[g];HighlightVertexDegree[g, vd]people = {"Elisabeth", "James", "Anna", "John", "Dorothy", "Linda", "Michael", "Larry", "Carol", "Nancy", "David", "Nora", "Julia", "Ben", "Oscar", "Felicia", "Arlene", "Rudy"};
relations = Join@@Table[UndirectedEdge@@@Subsets[family, {2}], {family, {{"Elisabeth", "Anna"}, {"James", "Anna", "Linda", "Larry", "Nancy"}, {"John", "Dorothy", "David"}, {"Linda", "Michael", "Nora", "Julia"}, {"Larry", "Carol", "Ben", "Oscar"}, {"Nancy", "David", "Arlene"}, {"Oscar", "Felicia"}, {"Arlene", "Rudy"}}}];g = Graph[people, relations, VertexSize -> Large, VertexLabels -> "Name", ImagePadding -> 30];Find the people with more influence:
vd = VertexDegree[g];HighlightGraph[g, Table[Style[VertexList[g][[i]], ColorData["TemperatureMap"][vd[[i]] / Max[vd]]], {i, VertexCount[g]}]]The degree distribution for a Bernoulli random graph follows a BinomialDistribution:
Histogram[VertexDegree[RandomGraph[BernoulliGraphDistribution[100, 0.3]]], Automatic, "PDF"]Generate vertex degrees from 1000 instances of random graphs:
Block[{n = 10, p = 0.3},
data = Join@@(VertexDegree /@ RandomGraph[BernoulliGraphDistribution[n, p], 10^3]);
Show[Histogram[data, {0, n - 1, 1}, "PDF"], DiscretePlot[PDF[BinomialDistribution[n - 1, p], k], {k, 0, n - 1}, PlotStyle -> PointSize[Large]]]]Find the probability that a Bernoulli random graph has max degree greater than 50:
Probability[d > 50, dBinomialDistribution[99, p]]Plot[%, {p, 0, 1}]The vertex degree distribution for BarabasiAlbertGraphDistribution follows a power-law:
g = RandomGraph[BarabasiAlbertGraphDistribution[10^4, 4]];Histogram[VertexDegree[g], {"Log", 10}, "LogProbability"]Properties & Relations (15)
The degree of a vertex of an undirected graph is the number of edges incident to the vertex:
Graph[{12, 23, 31}, VertexLabels -> "Name", ImagePadding -> 10]VertexDegree[%]Graph[{12, 23, 31, 33}, VertexLabels -> "Name", ImagePadding -> 10]VertexDegree[%]For an undirected graph, the vertex in-degree and out-degree are equal to the vertex degree:
WheelGraph[6]VertexDegree[%] == VertexInDegree[%] == VertexOutDegree[%]For a directed graph, the sum of the vertex in-degree and out-degree is the vertex degree:
g = Graph[{12, 23, 31, 24}];Put the vertex degree, in-degree, and out-degree before, above, and below the vertex, respectively:
Graph[EdgeList[g], VertexLabels -> Table[i -> Placed[{VertexDegree[g][[i]], VertexInDegree[g][[i]], VertexOutDegree[g][[i]]}, {Before, Above, Below}], {i, VertexCount[g]}], VertexSize -> Small, ImagePadding -> 10]VertexDegree[g] == VertexInDegree[g] + VertexOutDegree[g]The sum of the degrees of all vertices of a graph is twice the number of edges:
g = PetersenGraph[5, 2]Total[VertexDegree[g]] == 2EdgeCount[g]Every graph has an even number of vertices with odd degree:
g = WheelGraph[5]VertexDegree[g]Count[%, _ ? OddQ]Connected simple graphs have minimum vertex degree of at least
:
g = Graph[{12, 23, 31, 45}]ConnectedGraphQ[g]Min[VertexDegree[g]] ≥ (VertexCount[g] - 1) / 2A graph with minimum vertex degree at least 2 contains a cycle:
g = WheelGraph[6]Min[VertexDegree[g]]AcyclicGraphQ[g]The vertex degrees of an undirected graph can be obtained from its adjacency matrix:
g = [image];(a = AdjacencyMatrix[g])//MatrixFormVertexDegree[g]Total[a] + Diagonal[a]The vertex degrees of a directed graph can be obtained from its adjacency matrix:
g = [image];(a = AdjacencyMatrix[g])//MatrixFormVertexDegree[g]Total[a] + Total[a]The vertex degrees for an undirected graph can be obtained from the incidence matrix:
g = [image];VertexDegree[g](i = IncidenceMatrix[g])//MatrixFormTotal[i]The vertex degrees for a directed graph can be obtained from the incidence matrix:
g = [image];(i = IncidenceMatrix[g])//MatrixFormVertexDegree[g]Total[Abs[i]]Each vertex of a
-regular graph has the same vertex degree
:
CompleteGraph[5]VertexDegree[%]All vertices of a simple graph have maximum degree less than the number of vertices:
g = WheelGraph[6]SimpleGraphQ[g]Max[VertexDegree[g]] < VertexCount[g]A simple graph without isolated vertices has at least one pair of vertices with equal degrees:
g = GridGraph[{2, 3}]SimpleGraphQ[g]VertexDegree[g]A connected undirected graph is Eulerian iff every vertex has an even degree:
g = GraphData[{"Antiprism", 4}]VertexDegree[g]EulerianGraphQ[g]Related Guides
Text
Wolfram Research (2010), VertexDegree, Wolfram Language function, https://reference.wolfram.com/language/ref/VertexDegree.html (updated 2015).
CMS
Wolfram Language. 2010. "VertexDegree." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/VertexDegree.html.
APA
Wolfram Language. (2010). VertexDegree. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/VertexDegree.html
BibTeX
@misc{reference.wolfram_2026_vertexdegree, author="Wolfram Research", title="{VertexDegree}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/VertexDegree.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_vertexdegree, organization={Wolfram Research}, title={VertexDegree}, year={2015}, url={https://reference.wolfram.com/language/ref/VertexDegree.html}, note=[Accessed: 13-June-2026]}