Graphs
Aligned to the AQA 7517 specification
- Level
- Intermediate
- Reading time
- 5 min
- Published
- 13 June 2026
- Updated
- 1 July 2026
On this page
Key takeaways
- A graph is a set of vertices (nodes) connected by edges (arcs); it is undirected if edges are bidirectional, directed (a digraph) if edges are one-way, and weighted if edges carry a numeric value.
- An adjacency matrix is a 2D array where matrix[i][j] records whether an edge exists from vertex i to vertex j; for an undirected graph it is symmetric.
- An adjacency list stores, for each vertex, the list of vertices it connects to and optionally the edge weights.
- An adjacency matrix uses O(V²) space and checks an edge in O(1), while an adjacency list uses O(V + E) space, so matrices suit dense graphs and lists suit sparse graphs.
- A tree is a special case of a graph: connected, undirected, and with no cycles, so all graph representations apply to trees.
Studying this for an exam?
Generate a personalised learning path for this subject. Free to get started.
Key terms
- Graph
- A data structure made up of a set of vertices (nodes) connected by edges (arcs).
- Vertex (node)
- An entity in a graph.
- Edge (arc)
- A connection between two vertices in a graph.
- Directed graph (digraph)
- A graph whose edges have a direction, so A to B does not imply B to A.
- Undirected graph
- A graph whose edges have no direction, so if A connects to B then B connects to A.
- Weighted graph
- A graph whose edges carry a numeric value such as cost, distance, or time.
- Adjacency matrix
- A 2D array where entry [i][j] indicates whether (and with what weight) an edge exists from vertex i to vertex j; uses O(V²) space.
- Adjacency list
- A representation storing a list of neighbours for each vertex, optionally with edge weights; uses O(V + E) space.
- Dense graph
- A graph with close to V² edges, best represented by an adjacency matrix.
- Sparse graph
- A graph with far fewer than V² edges, best represented by an adjacency list.
Frequently asked questions
An adjacency matrix is a 2D array marking every possible vertex pair, using O(V²) space and checking an edge in O(1). An adjacency list stores only each vertex's actual neighbours, using O(V + E) space. Matrices suit dense graphs; lists suit sparse graphs.
Use an adjacency list when the graph is sparse (few edges, as in most real applications), when memory efficiency matters, or when operations mainly iterate over neighbours, as in BFS and DFS. Most real-world networks like road maps and social networks are sparse.
In an undirected graph an edge between A and B goes both ways, so if matrix[A][B] = 4 then matrix[B][A] must also be 4. Missing the symmetric entry loses marks in matrix construction questions.
Generate revision on any topic you study
Type any topic you're studying and Aicademy generates a complete lesson, quiz, and flashcard set, personalised to your level.
Lessons on anything
Structured, level-matched lessons on any topic you study
Practice quizzes
Find out what you actually know before the exam does
Flashcard sets
Lock in key concepts with instant revision cards
Ask Aica
Stuck on something? Get a clear explanation, any time
Stacks and Queues
Binary Search Trees
Related lessons
8 min
7 min
5 min