Since 2010 · Powering 2M+ tool runs every month
Since 2010
Add to Chrome

My Toolbox

Automatic Mode

No saved tools yet.

Go Premium
Related tools
Jacobian Matrix CalculatorGraph Degree Sequence ValidatorGraph Coloring CalculatorTopological Sort CalculatorSVG to React/JSX Converter
Home Page > Math > Advanced Math Operations

Adjacency Matrix Calculator

Convert between adjacency matrix, edge list, and adjacency list. Auto-detects directed/undirected graphs, computes degree sequence, density, connected components, and matrix powers — with an interactive SVG graph visualization.

Free to useNo sign-up requiredInstant Results
Adjacency Matrix CalculatorTry it now — free ▼
Accepts A-B, A->B, A B, A,B, or matrix rows like 0 1 1 0. Use letters, digits, or underscores for vertex labels.
Comma- or space-separated labels, one per matrix row. Defaults to A, B, C… if omitted.

Embed Adjacency Matrix Calculator Widget

About Adjacency Matrix Calculator

The Adjacency Matrix Calculator is a graph-theory utility that converts between the three canonical graph representations — adjacency matrix, edge list, and adjacency list — and enriches the result with structural analysis: degree sequence, graph density, connected components, and matrix powers. It auto-detects whether your input describes a directed or undirected graph and renders a live SVG visualization alongside every result.

What Is an Adjacency Matrix?

Given a graph G = (V, E) with n vertices, its adjacency matrix is the n × n square matrix A whose entry A[i][j] is 1 if there is an edge from vertex i to vertex j, and 0 otherwise.

A[i][j] = 1 if (vi, vj) ∈ E , else 0

For an undirected graph, the adjacency matrix is always symmetric: every edge {u, v} contributes both A[u][v] = 1 and A[v][u] = 1. For a directed graph (digraph), the matrix may be asymmetric, reflecting the direction of each arc.

Three Representations — Pick What Fits Your Problem

Representation Space Edge lookup List neighbors Best for
Adjacency matrix Θ(n²) O(1) Θ(n) Dense graphs; matrix algebra (powers, eigenvalues)
Adjacency list Θ(n + m) O(deg v) Θ(deg v) Sparse graphs; BFS/DFS and shortest-path algorithms
Edge list Θ(m) Θ(m) Θ(m) Input/output, Kruskal's MST, edge-centric algorithms

Key Metrics Computed

Degree Sequence

For undirected graphs, the degree of a vertex is the number of edges incident to it (with self-loops counting twice). For directed graphs, each vertex has an in-degree (incoming arcs) and out-degree (outgoing arcs). The sorted list of degrees is a classical graph invariant used in isomorphism testing and the Erdős–Gallai realisability theorem.

Handshaking Lemma: Σ deg(v) = 2m (undirected) Σ in-deg(v) = Σ out-deg(v) = m (directed)

Graph Density

Density measures how "full" a graph is relative to the maximum number of edges possible on n vertices.

Undirected: D = 2m / (n(n−1)) Directed: D = m / (n(n−1))

A density of 0 means no edges, 1 means the graph is complete, and values below 0.1 typically indicate a sparse graph where an adjacency list is more space-efficient than a matrix.

Connected Components

A connected component is a maximal subset of vertices such that every pair is joined by a path. For directed graphs, this calculator reports weakly connected components (ignoring arrow directions) — the same subsets you'd get by treating each arc as an undirected edge.

Matrix Powers (A², A³ ... )

A fundamental theorem of algebraic graph theory states that the (i, j) entry of Ak equals the number of walks of exactly length k from vertex i to vertex j. Consequently:

Input Formats Accepted

1. Edge list

One edge per line or comma-separated. Any of these separators work: A-B, A B, A,B, A->B, A--B. Use -> if you want to force a directed interpretation.

A-B, B-C, C-A, C-D (undirected 4-cycle with a tail) A->B, B->C, C->D, D->A (directed cycle of length 4)

2. Adjacency list

One line per vertex, in the form vertex: neighbor1, neighbor2, .... Order doesn't matter; missing vertices are added automatically from the neighbor lists.

A: B, C, D B: A, C C: A, B, D D: A, C

3. Adjacency matrix

One row per line with space- or comma-separated 0/1 values. The matrix must be square. Optionally provide custom labels in the Matrix labels field (otherwise A, B, C… are used).

0 1 1 0 1 0 1 1 1 1 0 1 0 1 1 0

How to Use This Calculator

  1. Pick an input format using the tabbed selector: edge list, adjacency list, or adjacency matrix.
  2. Paste or type your graph in the text area. For matrix input, add optional labels in the Matrix labels field.
  3. Select graph type — leave on Auto-detect and the calculator will infer directedness from arrows (->) or matrix symmetry. Force it to Directed or Undirected if you want to override.
  4. Click Convert & Analyze Graph. The result page shows the adjacency matrix, an interactive SVG rendering, the other two text representations, degree statistics, connected components, and walk-count matrices A² and A³ when the graph is small enough.
  5. Hover a matrix row or a graph node to light up the matching row/column and incident edges — an instant visual proof that each format encodes the same information.

Worked Example

Consider an undirected graph on vertices {A, B, C, D} with edges AB, BC, CA, CD. The adjacency matrix is:

A B C D A [ 0 1 1 0 ] B [ 1 0 1 0 ] C [ 1 1 0 1 ] D [ 0 0 1 0 ]

Key facts the calculator derives:

Common Applications

Frequently Asked Questions

What is an adjacency matrix?

An adjacency matrix is an n × n square matrix used to represent a finite graph. Each cell A[i][j] is 1 if there is an edge from vertex i to vertex j, and 0 otherwise. For undirected graphs the matrix is symmetric, so A[i][j] = A[j][i]. The matrix makes it easy to check whether two vertices are connected in constant time, and matrix powers encode the number of walks between vertices.

How do I tell if a graph is directed from its adjacency matrix?

If the adjacency matrix is symmetric, meaning A[i][j] equals A[j][i] for every pair of indices, the graph is undirected. If there is at least one pair where A[i][j] differs from A[j][i], the graph is directed. This calculator performs that symmetry check automatically when you pick the Auto-detect option.

What does the k-th power of an adjacency matrix represent?

The entry (i, j) of A^k counts the number of walks of exactly length k from vertex i to vertex j. For example, A²[i][j] is the number of 2-step paths, which equals the number of common neighbors between i and j in undirected graphs. This property is used in algorithms for triangle counting, reachability, and PageRank-style computations.

What is graph density?

Graph density is the ratio of the number of edges present to the maximum possible number of edges. For an undirected simple graph with n vertices, density = 2m / (n(n-1)). For a directed graph, density = m / (n(n-1)). A density near 0 means a sparse graph; a density of 1 means a complete graph.

How is an adjacency matrix different from an adjacency list?

An adjacency matrix stores connectivity for every pair of vertices using n² bits, making neighbor lookup O(1) but memory usage O(n²). An adjacency list stores only the actual neighbors of each vertex, giving O(n + m) memory, which is far smaller for sparse graphs, but neighbor lookup requires a linear scan. Matrices are better for dense graphs and matrix-algebra operations; lists are better for sparse graphs and traversal algorithms like BFS/DFS.

Can this tool handle weighted graphs?

The current calculator focuses on unweighted adjacency matrices with 0/1 entries. If you paste a matrix with non-zero numeric weights, every non-zero cell is treated as a 1 for structural analysis. For weighted graph computations such as shortest-path, consider a dedicated weighted-graph tool.

Further Reading

Reference this content, page, or tool as:

"Adjacency Matrix Calculator" at https://MiniWebtool.com/adjacency-matrix-calculator/ from MiniWebtool, https://MiniWebtool.com/

by miniwebtool team. Updated: Apr 20, 2026

You can also try our AI Math Solver GPT to solve your math problems through natural language question and answer.

Advanced Math Operations:

Top & Updated:

Matrix Power CalculatorMatrix Diagonalization CalculatorMatrix Multiplication CalculatorView all →
Home Page > Math > Advanced Math Operations > Adjacency Matrix Calculator