---
title: "Adjacency and Degree"
canonical: "https://docs.magma-maths.org/v2.30-1/Combinatorics/Multigraphs/multig-adj-deg.html"
source: "https://docs.magma-maths.org/v2.30-1/Combinatorics/Multigraphs/multig-adj-deg.md"
part: "Combinatorics"
chapter: "Multigraphs"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Combinatorics", "source": "https://docs.magma-maths.org/v2.30-1/Combinatorics/index-combinatorics.md"}
  - {"title": "Multigraphs", "source": "https://docs.magma-maths.org/v2.30-1/Combinatorics/Multigraphs/index-multigraphs.md"}
prev: {"title": "Elementary Invariants and Predicates for Multigraphs", "source": "https://docs.magma-maths.org/v2.30-1/Combinatorics/Multigraphs/multig-elem.md"}
next: {"title": "Connectedness", "source": "https://docs.magma-maths.org/v2.30-1/Combinatorics/Multigraphs/multig-connectedness.md"}
intrinsics:
  - {"name": "Degree", "signature": "Degree(u): GrphVert -> RngIntElt"}
  - {"name": "Alldeg", "signature": "Alldeg(G, n): GrphMultUnd, RngIntElt -> { GrphVert}"}
  - {"name": "MaximumDegree", "signature": "MaximumDegree(G): GrphMultUnd -> RngIntElt, GrphVert"}
  - {"name": "Maxdeg", "signature": "Maxdeg(G): GrphMultUnd -> RngIntElt, GrphVert"}
  - {"name": "MinimumDegree", "signature": "MinimumDegree(G): GrphMultUnd -> RngIntElt, GrphVert"}
  - {"name": "Mindeg", "signature": "Mindeg(G): GrphMultUnd -> RngIntElt, GrphVert"}
  - {"name": "DegreeSequence", "signature": "DegreeSequence(G): GrphMultUnd -> [ { GrphVert} ]"}
  - {"name": "Neighbours", "signature": "Neighbours(u): GrphVert -> { GrphVert}"}
  - {"name": "Neighbors", "signature": "Neighbors(u): GrphVert -> { GrphVert}"}
  - {"name": "IncidentEdges", "signature": "IncidentEdges(u): GrphVert -> { GrphEdge}"}
  - {"name": "InDegree", "signature": "InDegree(u): GrphVert -> RngIntElt"}
  - {"name": "OutDegree", "signature": "OutDegree(u): GrphVert -> RngIntElt"}
  - {"name": "MaximumInDegree", "signature": "MaximumInDegree(G): GrphMultDir -> RngIntElt, GrphVert"}
  - {"name": "Maxindeg", "signature": "Maxindeg(G): GrphMultDir -> RngIntElt, GrphVert"}
  - {"name": "MinimumInDegree", "signature": "MinimumInDegree(G): GrphMultDir -> RngIntElt, GrphVert"}
  - {"name": "Minindeg", "signature": "Minindeg(G)): GrphMultDir -> RngIntElt, GrphVert"}
  - {"name": "MaximumOutDegree", "signature": "MaximumOutDegree(G): GrphMultDir -> RngIntElt, GrphVert"}
  - {"name": "Maxoutdeg", "signature": "Maxoutdeg(G): GrphMultDir -> RngIntElt, GrphVert"}
  - {"name": "MinimumOutDegree", "signature": "MinimumOutDegree(G): GrphMultDir -> RngIntElt, GrphVert"}
  - {"name": "Minoutdeg", "signature": "Minoutdeg(G): GrphMultDir -> RngIntElt, GrphVert"}
  - {"name": "Degree", "signature": "Degree(u): GrphVert -> RngIntElt"}
  - {"name": "MaximumDegree", "signature": "MaximumDegree(G): GrphMultDir -> RngIntElt, GrphVert"}
  - {"name": "Maxdeg", "signature": "Maxdeg(G): GrphMultDir -> RngIntElt, GrphVert"}
  - {"name": "MinimumDegree", "signature": "MinimumDegree(G): GrphMultDir -> RngIntElt, GrphVert"}
  - {"name": "Mindeg", "signature": "Mindeg(G): GrphMultDir -> RngIntElt, GrphVert"}
  - {"name": "Alldeg", "signature": "Alldeg(G, n): GrphMultDir, RngIntElt -> { GrphVert}"}
  - {"name": "DegreeSequence", "signature": "DegreeSequence(G): GrphMultDir -> [ { GrphVert } ]"}
  - {"name": "InNeighbours", "signature": "InNeighbours(u): GrphVert -> { GrphVert}"}
  - {"name": "InNeighbors", "signature": "InNeighbors(u): GrphVert -> { GrphVert}"}
  - {"name": "OutNeighbours", "signature": "OutNeighbours(u): GrphVert -> { GrphVert}"}
  - {"name": "OutNeighbors", "signature": "OutNeighbors(u): GrphVert -> { GrphVert}"}
  - {"name": "IncidentEdges", "signature": "IncidentEdges(u): GrphVert -> { GrphEdge}"}
---

<a id="multig-adj-deg"></a>
<a id="multigraph-sec-deg"></a>
# Adjacency and Degree

The adjacency and degree functionalities that apply to simple graphs (see [Adjacency and Degree](https://docs.magma-maths.org/v2.30-1/Combinatorics/Graphs/adjacency-degree.md#graph-sec-adj)) similarly apply to multigraphs.

<a id="multig-adj-deg-und"></a>
<a id="multigraph-subsec-deg-und"></a>
## Adjacency and Degree Functions for Multigraphs

<a id="function-degree-grphvert"></a>
### `Degree(u): GrphVert -> RngIntElt`

Given a vertex $u$ of a graph $G$, return the degree of $u$, ie the number of edges incident to $u$.

<a id="function-alldeg-grphmultund-rngintelt"></a>
### `Alldeg(G, n): GrphMultUnd, RngIntElt -> { GrphVert}`

Given a multigraph $G$, and a non-negative integer $n$, return the set of all vertices of $G$ that have degree equal to $n$.

<a id="function-maximumdegree-grphmultund"></a>
### `MaximumDegree(G): GrphMultUnd -> RngIntElt, GrphVert`

<a id="function-maxdeg-grphmultund"></a>
### `Maxdeg(G): GrphMultUnd -> RngIntElt, GrphVert`

The maximum of the degrees of the vertices of the multigraph $G$. This function returns two values: the maximum degree, and a vertex of $G$ having that degree.

<a id="function-minimumdegree-grphmultund"></a>
### `MinimumDegree(G): GrphMultUnd -> RngIntElt, GrphVert`

<a id="function-mindeg-grphmultund"></a>
### `Mindeg(G): GrphMultUnd -> RngIntElt, GrphVert`

The minimum of the degrees of the vertices of the multigraph $G$. This function returns two values: the minimum degree, and a vertex of $G$ having that degree.

<a id="function-degreesequence-grphmultund"></a>
### `DegreeSequence(G): GrphMultUnd -> [ { GrphVert} ]`

Given a multigraph $G$ such that the maximum degree of any vertex of $G$ is $r$, return a sequence $D$ of length $r+1$, such that $D[i]$, $1 \leq i \leq r+1$, is the number of vertices in $G$ having degree $i-1$.

<a id="function-neighbours-grphvert"></a>
### `Neighbours(u): GrphVert -> { GrphVert}`

<a id="function-neighbors-grphvert"></a>
### `Neighbors(u): GrphVert -> { GrphVert}`

Given a vertex $u$ of a graph $G$, return the set of vertices of $G$ that are adjacent to $u$.

<a id="function-incidentedges-grphvert-2"></a>
### `IncidentEdges(u): GrphVert -> { GrphEdge}`

Given a vertex $u$ of a graph $G$, return the set of all edges incident with the vertex $u$.

<a id="multig-adj-deg-dir"></a>
<a id="multigraph-subsec-deg-dir"></a>
## Adjacency and Degree Functions for Multidigraphs

<a id="function-indegree-grphvert"></a>
### `InDegree(u): GrphVert -> RngIntElt`

The number of edges directed into the vertex $u$ belonging to a multidigraph.

<a id="function-outdegree-grphvert"></a>
### `OutDegree(u): GrphVert -> RngIntElt`

The number of edges of the form $[u, v]$ where $u$ is a vertex belonging to a multidigraph.

<a id="function-maximumindegree-grphmultdir"></a>
### `MaximumInDegree(G): GrphMultDir -> RngIntElt, GrphVert`

<a id="function-maxindeg-grphmultdir"></a>
### `Maxindeg(G): GrphMultDir -> RngIntElt, GrphVert`

The maximum indegree of the vertices of the multidigraph $G$. This function returns two values: the maximum indegree, and the first vertex of $G$ having that degree.

<a id="function-minimumindegree-grphmultdir"></a>
### `MinimumInDegree(G): GrphMultDir -> RngIntElt, GrphVert`

<a id="function-minindeg-grphmultdir"></a>
### `Minindeg(G)): GrphMultDir -> RngIntElt, GrphVert`

The minimum indegree of the vertices of the multidigraph $G$. This function returns two values: the minimum indegree, and the first vertex of $G$ having that degree.

<a id="function-maximumoutdegree-grphmultdir"></a>
### `MaximumOutDegree(G): GrphMultDir -> RngIntElt, GrphVert`

<a id="function-maxoutdeg-grphmultdir"></a>
### `Maxoutdeg(G): GrphMultDir -> RngIntElt, GrphVert`

The maximum outdegree of the vertices of the multidigraph $G$. This function returns two values: the maximum outdegree, and the first vertex of $G$ having that degree.

<a id="function-minimumoutdegree-grphmultdir"></a>
### `MinimumOutDegree(G): GrphMultDir -> RngIntElt, GrphVert`

<a id="function-minoutdeg-grphmultdir"></a>
### `Minoutdeg(G): GrphMultDir -> RngIntElt, GrphVert`

The minimum outdegree of the vertices of the multidigraph $G$. This function returns two values: the minimum outdegree, and the first vertex of $G$ having that degree.

<a id="function-degree-grphvert-2"></a>
### `Degree(u): GrphVert -> RngIntElt`

Given a vertex $u$ belonging to the multidigraph $G$, return the total degree of $u$, i.e. the sum of the in–degree and out–degree for $u$.

<a id="function-maximumdegree-grphmultdir"></a>
### `MaximumDegree(G): GrphMultDir -> RngIntElt, GrphVert`

<a id="function-maxdeg-grphmultdir"></a>
### `Maxdeg(G): GrphMultDir -> RngIntElt, GrphVert`

The maximum total degree of the vertices of the multidigraph $G$. This function returns two values: the maximum total degree, and the first vertex of $G$ having that degree.

<a id="function-minimumdegree-grphmultdir"></a>
### `MinimumDegree(G): GrphMultDir -> RngIntElt, GrphVert`

<a id="function-mindeg-grphmultdir"></a>
### `Mindeg(G): GrphMultDir -> RngIntElt, GrphVert`

The minimum total degree of the vertices of the multidigraph $G$. This function returns two values: the minimum total degree, and the first vertex of $G$ having that degree.

<a id="function-alldeg-grphmultdir-rngintelt"></a>
### `Alldeg(G, n): GrphMultDir, RngIntElt -> { GrphVert}`

Given a multidigraph $G$, and a non–negative integer $n$, return the set of all vertices of $G$ that have total degree equal to $n$.

<a id="function-degreesequence-grphmultdir"></a>
### `DegreeSequence(G): GrphMultDir -> [ { GrphVert } ]`

Given a multidigraph $G$ such that the maximum degree of any vertex of $G$ is $r$, return a sequence $D$ of length $r + 1$, such that $D[i]$, $1 \leq i \leq r + 1$, is the number of vertices in $G$ having degree $i - 1$.

<a id="function-inneighbours-grphvert"></a>
### `InNeighbours(u): GrphVert -> { GrphVert}`

<a id="function-inneighbors-grphvert"></a>
### `InNeighbors(u): GrphVert -> { GrphVert}`

Given a vertex $u$ of a multidigraph $G$, return the set containing all vertices $v$ such that $[v, u]$ is an edge in $G$, i.e. the initial vertex of all edges that are directed into the vertex $u$.

<a id="function-outneighbours-grphvert"></a>
### `OutNeighbours(u): GrphVert -> { GrphVert}`

<a id="function-outneighbors-grphvert"></a>
### `OutNeighbors(u): GrphVert -> { GrphVert}`

Given a vertex $u$ of the multidigraph $G$, return the set of vertices $v$ of $G$ such that $[u,v]$ is an edge in $G$, i.e. the set of vertices $v$ that are terminal vertices of edges directed from $u$ to $v$.

<a id="function-incidentedges-grphvert-3"></a>
### `IncidentEdges(u): GrphVert -> { GrphEdge}`

Given a vertex $u$ of a graph $G$, return the set of all edges incident with the vertex $u$, that is, the set of all edges incident into $u$ and incident from $u$.
