ForHosting KIT · Math

Edge list to adjacency matrix converter

Turn an edge list into an adjacency matrix with the node order spelled out: the three lines A B, B C and C A give a symmetric 3 by 3 matrix with zeros on the diagonal. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Text
A B B C C A
You get
Nodes
A, B, C
Edge count
3

Turn a compact graph edge list into a clear adjacency matrix without building the table by hand. Enter one connection per line, choose whether the graph is directed and whether each edge has a weight, and receive a square matrix with an explicit node order. The converter accepts comma-separated or whitespace-separated lines, can retain isolated nodes through an optional node list, and uses stable first-seen ordering for every other vertex. It is designed for algorithm visualization, classroom demonstrations, worked exercises, and quick checks of graph data before coding.

Write the edge list and choose the graph model

Begin with one edge on each line. For an unweighted graph, write two node names such as A B or A,B; the first value is the source and the second is the target. Node names are kept as labels, so letters, numbers, and short identifiers all work, provided a name contains no spaces or commas.

Select directed mode when A to B should mark only row A, column B. Leave directed mode off when the same edge should also mark row B, column A. For a weighted graph, enable weighted mode and add a finite, non-zero number as the third value on every line, for example A B 2.5.

Mixing weighted and unweighted rows is rejected because it would make the meaning of the matrix inconsistent. Blank lines are ignored, while incomplete rows, extra values, and duplicate edges produce a specific input error instead of a silently altered graph. This strictness makes the result suitable for lessons and automated examples where every entry needs a clear explanation.

Read the node order, rows, and columns

An adjacency matrix only makes sense when its node order is known, so the result always returns the node labels beside the matrix. Unless you provide a node list, vertices appear in the order they are first encountered while reading edges from top to bottom. Matrix row i describes edges leaving node i, and column j represents the destination node j.

In an unweighted matrix, a connection is marked with 1 and no connection is marked with 0. In weighted mode, the edge weight replaces 1, while 0 still means that no edge was supplied. Undirected graphs produce a symmetric matrix because each edge is written in both mirrored cells.

Directed graphs may be asymmetric, which makes incoming and outgoing relationships immediately visible. Self-loops are supported and appear on the main diagonal. The response also reports the selected directed and weighted settings and the number of input edges, making it easier to label a visualization or verify that a classroom transcription included every intended connection.

Include isolated nodes and avoid ambiguous data

An edge list cannot reveal a vertex that has no edges. To preserve isolated vertices, supply the optional nodes array in the exact order you want displayed. The converter rejects repeated names in that array because duplicate row labels would make the matrix ambiguous.

It also rejects duplicate edge declarations rather than adding weights or letting the last line win. For an undirected graph, A B and B A count as the same edge; for a directed graph, they are separate edges and occupy different cells. Zero weights are rejected because this matrix reserves zero to mean no connection, so accepting a zero-weight edge would hide its existence.

These rules are useful when teaching graph traversal, degree calculations, shortest-path inputs, or matrix representations: students can trace each edge to one predictable cell or mirrored pair.

Prepare an algorithm lesson

Convert a small graph into the matrix students will use for traversal, reachability, or degree exercises.

Check a weighted graph

Verify that every weighted edge lands in the expected row and column before using it in a shortest-path demonstration.

Feed a graph visualization

Turn pasted edge data into a stable node order and numeric grid that a table or heatmap can render directly.

What line formats are accepted?

Use two whitespace-separated or comma-separated values per unweighted edge, or three values per weighted edge.

How are directed edges placed?

An edge from A to B is placed at row A and column B. Directed mode does not fill the mirrored cell.

How do I include an isolated node?

Add its name to the optional nodes array. The array can also establish the preferred row and column order.

Why are zero weights rejected?

The output uses zero to represent no connection, so a zero-weight edge would be indistinguishable from an absent edge.

What happens if the same edge appears twice?

It is refused with a specific message instead of being merged or counted twice. Incomplete rows, extra values and a mix of weighted and unweighted lines are refused the same way, so every cell of the matrix has a clear origin.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/dev/edges-to-adjacency-matrix

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/dev/edges-to-adjacency-matrix \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"A B\nB C\nC A"}'
{
  "text": "A B\nB C\nC A"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "dev.edges_to_adjacency_matrix",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_chars200000
max_nodes500
max_edges10000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Include isolated nodes and avoid ambiguous data

Those names form the beginning of the returned order, and any endpoint found only in the edge text is appended when first seen. For API automation, the same deterministic conversion costs $0.002 per request and does not use network access, randomness, or stored state.

What does the API conversion cost?

Each API request costs $0.002. The browser version can run locally for free.

Read the full KIT documentation →