Graph Adjacency List Generator

Paste your edges, choose whether the graph is directed/undirected and weighted/unweighted, and we’ll build the adjacency list for you. We also show a JSON version and an adjacency matrix so you can compare different graph representations.

1. Graph input

Accepted edge formats (one per line): A B, A,B, A B 5 (weighted), 1 2, node_1 node_2 1.25. We auto-detect separators.

No graph generated yet.

Adjacency list vs adjacency matrix

For a graph \( G = (V, E) \):

  • Adjacency list: store, for every vertex \(v\), the list of neighbors it connects to. Space is \(O(|V| + |E|)\).
  • Adjacency matrix: store a full \( |V|\times|V| \) table. Space is \(O(|V|^2)\), but lookups are \(O(1)\).

When to use which

  • Use an adjacency list for sparse graphs, typical interview problems, and traversals like BFS/DFS.
  • Use an adjacency matrix when you need instant edge existence checks or when the graph is dense.

Weighted edges

If you tick “weighted”, neighbors will be shown as node(weight), e.g. C(2), so you can directly feed it to Dijkstra or Prim implementations.