Overview
An adjacency matrix gives constant-time edge lookup but uses O(V^2) space, making it better for dense graphs.
Represents graph edges with a matrix indexed by source and destination nodes.
Compact metadata for implementation and discovery.
An adjacency matrix gives constant-time edge lookup but uses O(V^2) space, making it better for dense graphs.
Quick facts
Runtime and memory behavior at a glance.
Best
O(1)
Average
O(1)
Worst
O(1)
Space
O(V^2)
edge_exists = matrix[u][v]Checks whether an edge is present between two indexed nodes.
Show the structure layout and how operations move through or update it.
Graph Adjacency Matrix should be used with the assumptions and tradeoffs of graph Representation in mind.
What each reference supports for this entry.
Reference for Graph Adjacency Matrix matrix graph storage and edge-query tradeoffs.
Good next jumps from the relationship graph, ranked for useful discovery.
Data Structures · Foundation
Adjacency matrices favor direct edge-existence checks at higher memory cost.
Compare with thisAdjacency matrices trade memory for constant-time edge tests compared with adjacency lists.