next up previous
Next: Traversing Graphs Up: CSE 2320: Algorithms and Previous: Representation

2. Adjacency matrix

Matrix A $\mid$V$\mid$ x $\mid$V$\mid$, where

\begin{displaymath}A[i,j] \;=\; \left\{ \begin{array}{ll} 1 & {\rm if} \;(i,j) \in E \\
0 & {\rm otherwise} \end{array} \right.\end{displaymath}

Memory \(\Theta(V^2)\), Lookup O(1)



\psfig{figure=figures/f16-5.ps}

Both allow added satellite data easily



\psfig{figure=figures/f16-6.ps}

Adjacency list better for sparse graphs

Graph algorithms



Copyright © 1998 The University of Texas at Arlington