Graph Representations

← Back to Graph Structures

The three main ways to represent a graph in memory, each with different space and time tradeoffs for common operations.

Key Properties

Tradeoffs

  • Adjacency list — O(V+E) space, efficient for sparse graphs.
  • Adjacency matrix — O(V²) space, O(1) edge lookup, better for dense graphs.
  • Edge list — simplest, O(E) space, slow lookups.

data-structures graphs representations