Adjacency Matrix in LaTeX (A_{ij})

AijA_{ij}
LaTeX command
A_{ij}
Package
No package needed: built into LaTeX
Mode
Math mode only

Where it is used

Entry in row i, column j of the adjacency matrix: 1 if vertices i and j are adjacent, 0 otherwise.

For a simple undirected graph the adjacency matrix is symmetric with zeros on the diagonal; in weighted graphs, A_{ij} holds the edge weight. A classic fact: (A^k)_{ij} counts walks of length k from i to j, so \operatorname{tr}(A^3)/6 is the number of triangles. Degrees are row sums, \deg(i) = \sum_j A_{ij}, and the Laplacian is L = D - A. Write A_{ij} with braces; A_ij would subscript only the i. For indices with commas, A_{i,j} is clearer when indices are expressions like A_{i+1,j}.

Minimal compilable example

Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.

(Ak)ij=#{walks of length k from i to j}(A^k)_{ij} = \#\{\text{walks of length } k \text{ from } i \text{ to } j\}
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Adjacency Matrix: $A_{ij}$

\[ (A^k)_{ij} = \#\{\text{walks of length } k \text{ from } i \text{ to } j\} \]
\end{document}

Related symbols

All Graph Theory →

Frequently asked questions

How do I write Adjacency Matrix in LaTeX?
Type A_{ij} in math mode, for example $(A^k)_{ij} = \#\{\text{walks of length } k \text{ from } i \text{ to } j\}$. It works in plain LaTeX without loading any package.
Which package do I need for A_{ij}?
None. A_{ij} is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
Can I use A_{ij} in text mode, or only in math mode?
Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $A_{ij}$ in running text.
Math poweredSumulat ng LaTeX gamit ang AI

Pinakamahusay na AI LaTeX Editor, Alternatibo sa Overleaf

Tinutulungan ng Octree ang mga researcher mula sa 15+ na unibersidad na sumulat ng research papers nang mas mabilis gamit ang AI

  • Gumawa ng magagandang TikZ diagrams gamit ang AI
  • Mag-upload ng larawan at i-convert ito sa LaTeX nang walang problema
  • Makakuha ng instant na tulong sa pagsulat at pag-format ng research papers