<s>
In	O
graph	O
theory	O
and	O
computer	B-General_Concept
science	I-General_Concept
,	O
an	O
adjacency	B-Data_Structure
list	I-Data_Structure
is	O
a	O
collection	O
of	O
unordered	O
lists	O
used	O
to	O
represent	O
a	O
finite	O
graph	O
.	O
</s>
<s>
Each	O
unordered	O
list	O
within	O
an	O
adjacency	B-Data_Structure
list	I-Data_Structure
describes	O
the	O
set	O
of	O
neighbors	O
of	O
a	O
particular	O
vertex	O
in	O
the	O
graph	O
.	O
</s>
<s>
This	O
is	O
one	O
of	O
several	O
commonly	O
used	O
representations	O
of	O
graphs	B-Application
for	O
use	O
in	O
computer	O
programs	O
.	O
</s>
<s>
An	O
adjacency	B-Data_Structure
list	I-Data_Structure
representation	O
for	O
a	O
graph	O
associates	O
each	O
vertex	O
in	O
the	O
graph	O
with	O
the	O
collection	O
of	O
its	O
neighbouring	O
vertices	O
or	O
edges	O
.	O
</s>
<s>
An	O
implementation	O
suggested	O
by	O
Guido	O
van	O
Rossum	O
uses	O
a	O
hash	B-Algorithm
table	I-Algorithm
to	O
associate	O
each	O
vertex	O
in	O
a	O
graph	O
with	O
an	O
array	B-Data_Structure
of	O
adjacent	O
vertices	O
.	O
</s>
<s>
Their	O
representation	O
uses	O
an	O
array	B-Data_Structure
indexed	O
by	O
vertex	O
number	O
,	O
in	O
which	O
the	O
array	B-Data_Structure
cell	O
for	O
each	O
vertex	O
points	O
to	O
a	O
singly	O
linked	O
list	O
of	O
the	O
neighboring	O
vertices	O
of	O
that	O
vertex	O
.	O
</s>
<s>
In	O
this	O
representation	O
,	O
the	O
nodes	O
of	O
the	O
singly	O
linked	O
list	O
may	O
be	O
interpreted	O
as	O
edge	O
objects	O
;	O
however	O
,	O
they	O
do	O
not	O
store	O
the	O
full	O
information	O
about	O
each	O
edge	O
(	O
they	O
only	O
store	O
one	O
of	O
the	O
two	O
endpoints	O
of	O
the	O
edge	O
)	O
and	O
in	O
undirected	O
graphs	B-Application
there	O
will	O
be	O
two	O
different	O
linked	O
list	O
nodes	O
for	O
each	O
edge	O
(	O
one	O
within	O
the	O
lists	O
for	O
each	O
of	O
the	O
two	O
endpoints	O
of	O
the	O
edge	O
)	O
.	O
</s>
<s>
The	O
object	B-Language
oriented	I-Language
incidence	B-Data_Structure
list	I-Data_Structure
structure	O
suggested	O
by	O
Goodrich	O
and	O
Tamassia	O
has	O
special	O
classes	O
of	O
vertex	O
objects	O
and	O
edge	O
objects	O
.	O
</s>
<s>
This	O
version	O
of	O
the	O
adjacency	B-Data_Structure
list	I-Data_Structure
uses	O
more	O
memory	O
than	O
the	O
version	O
in	O
which	O
adjacent	O
vertices	O
are	O
listed	O
directly	O
,	O
but	O
the	O
existence	O
of	O
explicit	O
edge	O
objects	O
allows	O
it	O
extra	O
flexibility	O
in	O
storing	O
additional	O
information	O
about	O
edges	O
.	O
</s>
<s>
The	O
main	O
operation	O
performed	O
by	O
the	O
adjacency	B-Data_Structure
list	I-Data_Structure
data	O
structure	O
is	O
to	O
report	O
a	O
list	O
of	O
the	O
neighbors	O
of	O
a	O
given	O
vertex	O
.	O
</s>
<s>
It	O
is	O
also	O
possible	O
,	O
but	O
not	O
as	O
efficient	O
,	O
to	O
use	O
adjacency	B-Data_Structure
lists	I-Data_Structure
to	O
test	O
whether	O
an	O
edge	O
exists	O
or	O
does	O
not	O
exist	O
between	O
two	O
specified	O
vertices	O
.	O
</s>
<s>
In	O
an	O
adjacency	B-Data_Structure
list	I-Data_Structure
in	O
which	O
the	O
neighbors	O
of	O
each	O
vertex	O
are	O
unsorted	O
,	O
testing	O
for	O
the	O
existence	O
of	O
an	O
edge	O
may	O
be	O
performed	O
in	O
time	O
proportional	O
to	O
the	O
minimum	O
degree	O
of	O
the	O
two	O
given	O
vertices	O
,	O
by	O
using	O
a	O
sequential	B-Algorithm
search	I-Algorithm
through	O
the	O
neighbors	O
of	O
this	O
vertex	O
.	O
</s>
<s>
If	O
the	O
neighbors	O
are	O
represented	O
as	O
a	O
sorted	O
array	B-Data_Structure
,	O
binary	O
search	O
may	O
be	O
used	O
instead	O
,	O
taking	O
time	O
proportional	O
to	O
the	O
logarithm	O
of	O
the	O
degree	O
.	O
</s>
<s>
The	O
main	O
alternative	O
to	O
the	O
adjacency	B-Data_Structure
list	I-Data_Structure
is	O
the	O
adjacency	B-Algorithm
matrix	I-Algorithm
,	O
a	O
matrix	B-Architecture
whose	O
rows	O
and	O
columns	O
are	O
indexed	O
by	O
vertices	O
and	O
whose	O
cells	O
contain	O
a	O
Boolean	O
value	O
that	O
indicates	O
whether	O
an	O
edge	O
is	O
present	O
between	O
the	O
vertices	O
corresponding	O
to	O
the	O
row	O
and	O
column	O
of	O
the	O
cell	O
.	O
</s>
<s>
For	O
a	O
sparse	O
graph	O
(	O
one	O
in	O
which	O
most	O
pairs	O
of	O
vertices	O
are	O
not	O
connected	O
by	O
edges	O
)	O
an	O
adjacency	B-Data_Structure
list	I-Data_Structure
is	O
significantly	O
more	O
space-efficient	O
than	O
an	O
adjacency	B-Algorithm
matrix	I-Algorithm
(	O
stored	O
as	O
a	O
two-dimensional	O
array	B-Data_Structure
)	O
:	O
the	O
space	O
usage	O
of	O
the	O
adjacency	B-Data_Structure
list	I-Data_Structure
is	O
proportional	O
to	O
the	O
number	O
of	O
edges	O
and	O
vertices	O
in	O
the	O
graph	O
,	O
while	O
for	O
an	O
adjacency	B-Algorithm
matrix	I-Algorithm
stored	O
in	O
this	O
way	O
the	O
space	O
is	O
proportional	O
to	O
the	O
square	O
of	O
the	O
number	O
of	O
vertices	O
.	O
</s>
<s>
However	O
,	O
it	O
is	O
possible	O
to	O
store	O
adjacency	O
matrices	O
more	O
space-efficiently	O
,	O
matching	O
the	O
linear	O
space	O
usage	O
of	O
an	O
adjacency	B-Data_Structure
list	I-Data_Structure
,	O
by	O
using	O
a	O
hash	B-Algorithm
table	I-Algorithm
indexed	O
by	O
pairs	O
of	O
vertices	O
rather	O
than	O
an	O
array	B-Data_Structure
.	O
</s>
<s>
The	O
other	O
significant	O
difference	O
between	O
adjacency	B-Data_Structure
lists	I-Data_Structure
and	O
adjacency	O
matrices	O
is	O
in	O
the	O
efficiency	O
of	O
the	O
operations	O
they	O
perform	O
.	O
</s>
<s>
In	O
an	O
adjacency	B-Data_Structure
list	I-Data_Structure
,	O
the	O
neighbors	O
of	O
each	O
vertex	O
may	O
be	O
listed	O
efficiently	O
,	O
in	O
time	O
proportional	O
to	O
the	O
degree	O
of	O
the	O
vertex	O
.	O
</s>
<s>
In	O
an	O
adjacency	B-Algorithm
matrix	I-Algorithm
,	O
this	O
operation	O
takes	O
time	O
proportional	O
to	O
the	O
number	O
of	O
vertices	O
in	O
the	O
graph	O
,	O
which	O
may	O
be	O
significantly	O
higher	O
than	O
the	O
degree	O
.	O
</s>
<s>
On	O
the	O
other	O
hand	O
,	O
the	O
adjacency	B-Algorithm
matrix	I-Algorithm
allows	O
testing	O
whether	O
two	O
vertices	O
are	O
adjacent	O
to	O
each	O
other	O
in	O
constant	O
time	O
;	O
the	O
adjacency	B-Data_Structure
list	I-Data_Structure
is	O
slower	O
to	O
support	O
this	O
operation	O
.	O
</s>
<s>
For	O
use	O
as	O
a	O
data	O
structure	O
,	O
the	O
main	O
alternative	O
to	O
the	O
adjacency	B-Data_Structure
list	I-Data_Structure
is	O
the	O
adjacency	B-Algorithm
matrix	I-Algorithm
.	O
</s>
<s>
Because	O
each	O
entry	O
in	O
the	O
adjacency	B-Algorithm
matrix	I-Algorithm
requires	O
only	O
one	O
bit	O
,	O
it	O
can	O
be	O
represented	O
in	O
a	O
very	O
compact	O
way	O
,	O
occupying	O
only	O
bytes	O
of	O
contiguous	O
space	O
,	O
where	O
is	O
the	O
number	O
of	O
vertices	O
of	O
the	O
graph	O
.	O
</s>
<s>
Besides	O
avoiding	O
wasted	O
space	O
,	O
this	O
compactness	O
encourages	O
locality	B-General_Concept
of	I-General_Concept
reference	I-General_Concept
.	O
</s>
<s>
However	O
,	O
for	O
a	O
sparse	O
graph	O
,	O
adjacency	B-Data_Structure
lists	I-Data_Structure
require	O
less	O
space	O
,	O
because	O
they	O
do	O
not	O
waste	O
any	O
space	O
to	O
represent	O
edges	O
that	O
are	O
not	O
present	O
.	O
</s>
<s>
Using	O
a	O
naïve	O
array	B-Data_Structure
implementation	O
on	O
a	O
32-bit	O
computer	O
,	O
an	O
adjacency	B-Data_Structure
list	I-Data_Structure
for	O
an	O
undirected	O
graph	O
requires	O
about	O
bytes	O
of	O
space	O
,	O
where	O
is	O
the	O
number	O
of	O
edges	O
of	O
the	O
graph	O
.	O
</s>
<s>
Then	O
,	O
when	O
,	O
that	O
is	O
the	O
adjacency	B-Data_Structure
list	I-Data_Structure
representation	O
occupies	O
more	O
space	O
than	O
the	O
adjacency	B-Algorithm
matrix	I-Algorithm
representation	O
when	O
.	O
</s>
<s>
Thus	O
a	O
graph	O
must	O
be	O
sparse	O
enough	O
to	O
justify	O
an	O
adjacency	B-Data_Structure
list	I-Data_Structure
representation	O
.	O
</s>
<s>
Finding	O
all	O
vertices	O
adjacent	O
to	O
a	O
given	O
vertex	O
in	O
an	O
adjacency	B-Data_Structure
list	I-Data_Structure
is	O
as	O
simple	O
as	O
reading	O
the	O
list	O
.	O
</s>
<s>
With	O
an	O
adjacency	B-Algorithm
matrix	I-Algorithm
,	O
an	O
entire	O
row	O
must	O
instead	O
be	O
scanned	O
,	O
which	O
takes	O
time	O
.	O
</s>
<s>
Whether	O
there	O
is	O
an	O
edge	O
between	O
two	O
given	O
vertices	O
can	O
be	O
determined	O
at	O
once	O
with	O
an	O
adjacency	B-Algorithm
matrix	I-Algorithm
,	O
while	O
requiring	O
time	O
proportional	O
to	O
the	O
minimum	O
degree	O
of	O
the	O
two	O
vertices	O
with	O
the	O
adjacency	B-Data_Structure
list	I-Data_Structure
.	O
</s>
