This preview shows pages 1–2. Sign up to view the full content.
1)
Graphs
i)
Undirected – two way edges
ii)
Directed – one way edges
iii) Weighted – each edge has a cost
iv)
In hash table: keys – vertices,
entries  distances
b)
Adjacency Lists
i)
Representation
(1)
⇒
2
⇒
5
(2)
⇒
1
⇒
5
⇒
3
⇒
4
(3)
⇒
2
⇒
4
(4)
⇒
2
⇒
5
⇒
3
(5)
⇒
1
⇒
2
⇒
4
ii) Better when E << V
2
(1) Number of edges much less
then the vertices squared
c)
Adjacency Matrices – Memory
Θ
(V
2
)
i)
Representation
1 –
connection
(could also be
the distances /
weights)
0 – no
connection (could also be
Integer.MAX_VALUE)
ii)
Better when there are a lot of extra
connections
2)
Search – both uninformed
i)
Lists save memory space at the cost
of having to traverse the list to look
up if a vertex is connected or not.
Although we use a hash table, it is
typically represented as a linked
list, and has to be searched.
The
matrix on the other hand is a
quicker, instant lookup, but at the
cost of space.
A lot of times it is
best to use the list when the graph
is sparse.
A dense graph will begin
to take up almost as much space as
the matrix itself, so it is best
handled by a matrix.
ii)
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview. Sign up
to
access the rest of the document.
 Spring '07
 Ralphs
 Systems Engineering

Click to edit the document details