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.
Private by design: vertex labels and edges are processed on this device. They are not uploaded, saved, or added to the page URL.
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.
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.
A[i,j] = A[j,i]
Every ordinary edge creates two mirrored entries, so the matrix is symmetric.
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.
Start with the first endpoint or source vertex. Its label identifies a row on the left side of the table.
Move across to the second endpoint or destination. A 1 means that adjacency exists; a 0 means it does not.
An undirected matrix mirrors across the main diagonal. A directed matrix need not: A → B does not imply B → A.
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.
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.
| Vertex | A | B | C | D | Row sum |
|---|---|---|---|---|---|
| A | 0 | 1 | 1 | 0 | 2 |
| B | 1 | 0 | 1 | 0 | 2 |
| C | 1 | 1 | 0 | 1 | 3 |
| D | 0 | 0 | 1 | 0 | 1 |
The matrix is symmetric and its row sums total 8, which equals 2|E| = 2 × 4.
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: .
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.
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.
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.
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.
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.
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.
No. Parsing, matrix generation, copying, and CSV creation happen locally in your browser. The tool does not transmit or save entered vertices or edges.