Store a graph as a V × V grid of 0s and 1s: M[u][v] = 1 when there is an edge from u to v. Any single edge can be checked or changed in one step, at the cost of V² cells of memory however few edges there are.
- Typical operation
- O(1)
- Space
- O(V²)
Store a graph as a V × V grid of 0s and 1s: M[u][v] = 1 when there is an edge from u to v. Any single edge can be checked or changed in one step, at the cost of V² cells of memory however few edges there are.