Adjacency Matrix Generator from Graph Edges

Paste an edge list to create a labeled binary adjacency matrix for a directed or undirected graph. Include isolated vertices, choose the label order, and copy or download the result—all locally in your browser.

Enter graph edges

Each undirected edge sets both A[i,j] and A[j,i] to 1.
Separate labels with commas, semicolons, or lines. List isolated vertices here.5 listed
Use A,B for an undirected edge.4 lines

Private by design: vertex labels and edges are processed on this device. They are not uploaded, saved, or added to the page URL.

Adjacency matrix

The sample graph is shown below.

Advertisement

What is an adjacency matrix?

For vertices v₁, v₂, …, vₙ, an adjacency matrix is an n × n matrix A. In this binary generator, an entry is 1 when the row vertex is adjacent to the column vertex and 0 otherwise.

Directed graph

A[i,j] = 1 if vᵢ → vⱼ

Rows are sources and columns are destinations. The row sum is out-degree; the column sum is in-degree.

Undirected graph

A[i,j] = A[j,i]

Every ordinary edge creates two mirrored entries, so the matrix is symmetric.

Self-loop

A[i,i] = 1

A permitted loop appears on the main diagonal. For undirected graphs, a loop contributes two to degree even though its matrix entry is 1.

How to read the generated matrix

Find the row

Start with the first endpoint or source vertex. Its label identifies a row on the left side of the table.

Find the column

Move across to the second endpoint or destination. A 1 means that adjacency exists; a 0 means it does not.

Check symmetry

An undirected matrix mirrors across the main diagonal. A directed matrix need not: A → B does not imply B → A.

Use the sums

For a loop-free undirected graph, each row sum is the vertex degree. For a directed graph, use row sums for out-degree and column sums for in-degree.

Adjacency matrix example

For V = {A, B, C, D} and undirected edges E = {{A,B}, {B,C}, {C,A}, {C,D}}, use the vertex order A, B, C, D. The A–B edge places a 1 in both row A, column B and row B, column A.

VertexABCDRow sum
A01102
B10102
C11013
D00101

The matrix is symmetric and its row sums total 8, which equals 2|E| = 2 × 4.

Input rules, assumptions, and limits

Vertex labels are case-sensitive text. The optional vertex list accepts commas, semicolons, or line breaks. Edge endpoints are added automatically, but isolated vertices must be listed explicitly. Put one edge on each line with exactly two comma-separated labels. Directed mode also accepts ASCII A -> B and Unicode A → B.

This tool produces a binary adjacency matrix. Repeated edges are ignored after their first occurrence; in undirected mode, A,B and B,A are duplicates. Parallel-edge counts and edge weights are not represented. Self-loops are rejected unless Allow self-loops is enabled. Whitespace around labels is ignored, while spaces inside a label are retained.

The generator supports up to 150 vertices, 30,000 nonempty edge lines, labels of 80 characters, 15,000 characters in the vertex field, and 100,000 characters in the edge field. The vertex cap limits the rendered matrix to 22,500 cells so accidental extreme input does not freeze the page. Natural sorting uses the browser locale with numeric comparison.

Graph, vertex, edge, adjacency, degree, simple-graph, and multigraph terminology follows OpenStax, Contemporary Mathematics, Section 12.1 and its Chapter 12 key concepts.

Calculation note: directed and undirected matrix orientation, symmetry, loop behavior, duplicate handling, and representative exports checked by the Starlight Tools editorial team. Last reviewed: .

Adjacency matrix generator FAQ

How do I make an adjacency matrix from an edge list?

Choose the graph type and enter one edge per line as two labels separated by a comma. The generator creates one row and column per vertex and places 1 where the corresponding edge exists. Directed mode also accepts arrows.

What is the difference between directed and undirected adjacency matrices?

An undirected graph produces a symmetric matrix because each edge joins both ways. In a directed graph, row i, column j contains 1 only when an edge points from vertex i to vertex j.

How do I include an isolated vertex?

Enter the isolated label in the optional vertex list. Because an isolated vertex never occurs in an edge, it cannot be detected from the edge list alone. Its row and column contain only zeros.

Can an adjacency matrix contain self-loops?

Yes. Enable Allow self-loops, then enter an edge whose endpoints match, such as A,A. Its diagonal entry is 1. When the option is disabled, loop edges are rejected with a clear input message.

How are repeated edges handled?

This generator creates a binary matrix, so repeated edges are ignored after the first. In undirected mode, reversed repeats such as A,B and B,A are the same edge.

Can I export the adjacency matrix?

Yes. Copy matrix produces labeled tab-separated text for spreadsheets, Copy LaTeX produces an unlabeled bmatrix, and Download CSV creates a labeled UTF-8 CSV file.

Does the adjacency matrix generator store my graph?

No. Parsing, matrix generation, copying, and CSV creation happen locally in your browser. The tool does not transmit or save entered vertices or edges.

Explore more tools