[prev] 36 [next]
Storage cost: O(V2)

If the graph is sparse, most storage is wasted.

Cost of operations:

  • initialisation: O(V2)   (initialise V×V matrix)
  • insert edge: O(1)   (set two cells in matrix)
  • delete edge: O(1)   (unset two cells in matrix)