Adjacency Matrix in LaTeX (A_{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.
\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 Teori Graf →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.
Editor LaTeX AI Terbaik, Alternatif Overleaf
Octree membantu penyelidik dari 15+ universiti menulis kertas penyelidikan dengan lebih cepat menggunakan AI
- Jana diagram TikZ yang cantik menggunakan AI
- Muat naik imej dan tukar ke LaTeX dengan lancar
- Dapatkan bantuan segera untuk menulis dan memformat kertas penyelidikan