Edge List to Adjacency List Converter
Convert graph edge lists to adjacency list representation. Supports directed/undirected graphs, multiple input formats, and duplicate edge merging.
Result will appear here…
About
Graph representation matters. An edge list is compact for storage but inefficient for traversal - scanning all edges to find neighbors of a single vertex costs O(E) per query. An adjacency list reduces that to O(1) lookup plus O(deg(v)) iteration. This converter parses edge pairs, deduplicates repeated connections, and outputs a zero-indexed adjacency array. It handles both directed and undirected interpretations. Feed it raw edge data in any common format and get a structure ready for BFS, DFS, Dijkstra, or any standard graph algorithm.
The tool accepts flexible input: JSON bracket notation like [0, 1], space-separated pairs, comma-separated pairs, or arrow syntax 0 β 1. Vertices are assumed integer-indexed starting at 0. If your graph has isolated vertices beyond the maximum index found in edges, specify the vertex count manually. Note: this tool does not handle weighted edges or hypergraphs. For multigraph input, parallel edges are collapsed into single adjacency entries.
Formulas
Given an edge list E = {(u1, v1), (u2, v2), β¦, (um, vm)} over vertex set V = {0, 1, β¦, n β 1}, the adjacency list Adj is constructed as follows:
Adj[v] = {w | (v, w) β E}
For an undirected graph, every edge (u, v) implies both w β Adj[u] and u β Adj[v]. For a directed graph, only the forward direction is recorded. The degree of vertex v equals the length of its adjacency list:
Total construction time is O(V + E) using hash sets for deduplication. The total space consumed is O(V + 2E) for undirected and O(V + E) for directed graphs.
Where: V = set of vertices, E = set of edges, n = number of vertices, m = number of edges, Adj[v] = neighbor set of vertex v, deg(v) = degree of vertex v.
Reference Data
| Representation | Space Complexity | Add Edge | Query Neighbors | Check Edge Exists | Best For |
|---|---|---|---|---|---|
| Edge List | O(E) | O(1) | O(E) | O(E) | Storage, Kruskalβs MST |
| Adjacency List | O(V + E) | O(1) | O(deg(v)) | O(deg(v)) | BFS, DFS, most algorithms |
| Adjacency Matrix | O(V2) | O(1) | O(V) | O(1) | Dense graphs, Floyd-Warshall |
| Incidence Matrix | O(V β E) | O(V) | O(E) | O(E) | Theoretical analysis |
| Compressed Sparse Row | O(V + E) | O(V + E) | O(deg(v)) | O(log deg(v)) | Static graphs, GPU/SIMD |
| Hash Map of Sets | O(V + E) | O(1) avg | O(deg(v)) | O(1) avg | Dynamic graphs, non-integer keys |
| Edge List (sorted) | O(E) | O(E) | O(log E) | O(log E) | Binary search queries |
| Adjacency Multilist | O(V + E) | O(1) | O(deg(v)) | O(deg(v)) | Undirected traversal |
| Forward Star | O(V + E) | O(V + E) | O(deg(v)) | O(log deg(v)) | Network flow |
| Doubly Connected Edge List | O(V + E) | O(1) | O(deg(v)) | O(deg(v)) | Planar subdivisions, computational geometry |
| Object-Pointer (Node class) | O(V + E) | O(1) | O(deg(v)) | O(deg(v)) | OOP implementations, trees |