| 1 | Start with 5 nodes, 4 edges | Sparse | Adjacency List empty | [] [] [] [] [] |
| 2 | Add edge 0->1 | Sparse | List[0]: 1 -> NULL | [0:1] [] [] [] [] |
| 3 | Add edge 0->4 | Sparse | List[0]: 4 -> 1 -> NULL | [0:4->1] [] [] [] [] |
| 4 | Add edge 1->2 | Sparse | List[1]: 2 -> NULL | [0:4->1] [1:2] [] [] [] |
| 5 | Add edge 3->4 | Sparse | List[3]: 4 -> NULL | [0:4->1] [1:2] [] [3:4] [] |
| 6 | Check if edge 0->3 exists | Sparse | Traverse List[0] | No edge found |
| 7 | Start with 5 nodes, dense graph | Dense | Matrix all zeros | [[0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0]] |
| 8 | Add edge 0->1 | Dense | Matrix[0][1] = 1 | [[0,1,0,0,0], [0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0]] |
| 9 | Add edge 0->4 | Dense | Matrix[0][4] = 1 | [[0,1,0,0,1], [0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0]] |
| 10 | Add edge 1->2 | Dense | Matrix[1][2] = 1 | [[0,1,0,0,1], [0,0,1,0,0], [0,0,0,0,0], [0,0,0,0,0], [0,0,0,0,0]] |
| 11 | Add edge 3->4 | Dense | Matrix[3][4] = 1 | [[0,1,0,0,1], [0,0,1,0,0], [0,0,0,0,0], [0,0,0,0,1], [0,0,0,0,0]] |
| 12 | Check if edge 0->3 exists | Dense | Check Matrix[0][3] | Value = 0, no edge |
| 13 | End | - | - | Representation chosen based on graph density |