---
title: "Elementary Invariants of a Graph"
canonical: "https://docs.magma-maths.org/v2.30-1/Combinatorics/Graphs/invariant.html"
source: "https://docs.magma-maths.org/v2.30-1/Combinatorics/Graphs/invariant.md"
part: "Combinatorics"
chapter: "Graphs"
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": "Graphs", "source": "https://docs.magma-maths.org/v2.30-1/Combinatorics/Graphs/index-graphs.md"}
prev: {"title": "Construction from Groups, Codes, and Designs", "source": "https://docs.magma-maths.org/v2.30-1/Combinatorics/Graphs/group-code-design.md"}
next: {"title": "Elementary Graph Predicates", "source": "https://docs.magma-maths.org/v2.30-1/Combinatorics/Graphs/Boolean.md"}
intrinsics:
  - {"name": "Order", "signature": "Order(G): Grph -> RngIntElt"}
  - {"name": "NumberOfVertices", "signature": "NumberOfVertices(G): Grph -> RngIntElt"}
  - {"name": "Size", "signature": "Size(G): Grph -> RngIntElt"}
  - {"name": "NumberOfEdges", "signature": "NumberOfEdges(G): Grph -> RngIntElt"}
  - {"name": "CharacteristicPolynomial", "signature": "CharacteristicPolynomial(G): GrphUnd -> RngUPolElt"}
  - {"name": "Spectrum", "signature": "Spectrum(G): GrphUnd -> SetEnum"}
---

<a id="invariant"></a>
<a id="graph-sec-inv"></a>
# Elementary Invariants of a Graph

<a id="function-order-grph"></a>
## `Order(G): Grph -> RngIntElt`

<a id="function-numberofvertices-grph"></a>
## `NumberOfVertices(G): Grph -> RngIntElt`

The number of vertices of the graph $G$.

<a id="function-size-grph"></a>
## `Size(G): Grph -> RngIntElt`

<a id="function-numberofedges-grph"></a>
## `NumberOfEdges(G): Grph -> RngIntElt`

The number of edges of the graph $G$.

<a id="function-characteristicpolynomial-grphund"></a>
## `CharacteristicPolynomial(G): GrphUnd -> RngUPolElt`

The characteristic polynomial (over the integers) of the graph $G$; i.e. the characteristic polynomial of the adjacency matrix of $G$.

<a id="function-spectrum-grphund"></a>
## `Spectrum(G): GrphUnd -> SetEnum`

The spectrum of the graph $G$; i.e. the roots of the characteristic polynomial of $G$. The roots are returned as a set of tuples, each containing a root and its multiplicity.
