Adjacency Matrix
Space: O(V²).
Check whether an edge exists: O(1).
Iterating all neighbors: O(V).
Excellent for dense graphs.
Can waste substantial memory for sparse graphs.
Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.