Skip to content

VertexDegree ​

How many edge-ends meet a vertex — direction-blind (a self-loop counts twice).

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageVertexDegree✓
VertexDegree(g)the degree of every vertex of gg, as a list in VertexList order.
VertexDegree(g, v)the degree of vv alone.
Typed signatures
TypePackageApplies
(value, any?) -> valuecombinatoricsalways

Domain: Collections

Details
  • Total degree, in and out combined — a directed edge counts once at each endpoint, same as an undirected one. Sums to 2∣E∣2|E| (the handshake lemma), which the tests check against an independently-computed sum on random graphs.

Examples

3 more kept as data, checked against the oracles
Basic #

A 5-vertex path — the two ends have degree 1, the rest degree 2

live ↗
InVertexDegree(PathGraph(5))\mathrm{VertexDegree}(\mathrm{PathGraph}(5))Out[1,2,2,2,1]\bigl\lbrack1, 2, 2, 2, 1\bigr\rbrack

The centre of a 6-vertex star has degree 5

live ↗
InVertexDegree(StarGraph(6),1)\mathrm{VertexDegree}(\mathrm{StarGraph}(6), 1)Out55
About
Examples5
Checked againstWolfram Language 4 agree
CrosswalkWolfram Language

See also: AdjacencyMatrix, Graph