Nodes: , , . Edges: (-) and (-). Here is what the matrix looks like:
1 2 3
1 [ 0 1 0 ]
2 [ 1 0 1 ]
3 [ 0 1 0 ]
Notice the matrix is symmetric. Position M[1][2] equals position M[2][1] because if node connects to node , then node connects to node . This symmetry only holds for undirected graphs. For directed graphs, the matrix is not symmetric.
The diagonal is all zeros because no node connects to itself. If self-loops existed, you would see ones on the diagonal. You can read any cell to immediately answer "Is there an edge between and ?" That lookup takes time, which is the main advantage of this representation.