T originvertexobject destinationvertexobject

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: t to v vertices(): all vertices in the graph edges(): all edges in the graph 9 Edge List Structure v element origin vertex object destination vertex object reference to position in edge sequence u c b d w z w v z Vertex sequence a element reference to position in vertex sequence Edge object u Vertex object sequence of vertex objects a b c d Edge sequence sequence of edge objects © 2010 Goodrich, Tamassia Graphs 10 Adjacency List Structure a Edge list structure Incidence sequence for each vertex sequence of references to edge objects of incident edges Augmented edge objects b u u references to associated positions in incidence sequences of end vertices © 2010 Goodrich, Tamassia v v a Graphs w w b 11 Adjacency Matrix Structure v b u w Integer key (index) associated with vertex 2D­array adjacency array a Edge list structure Augmented vertex objects 0 u 1 Reference to edge object for adjacent vertices Null for non nonadjacent vertices 0 The “old fashioned” version just has 0 for no edge and 1 for edge © 2010 Goodrich, Tamassia a Graphs 1 2 0 ∅ 2 v 1 w 2 ∅ ∅ ∅ ∅ b 12 Performance n vertices, m edges Edge List Adjacency List Adjacency Matrix n+ m n+ m n2 incidentEdges(v) m deg(v) n areAdjacent (v, w) m min(deg(v), deg(w)) 1 insertVertex(o) 1 1 n2 insertEdge(v, w, o) 1 1 1 removeVertex(v) m deg(v) n2 removeEdge(e) 1 1 1 no parallel edges no self­loops Space © 2010 Goodrich, Tamassia Graphs 13...
View Full Document

This document was uploaded on 02/05/2014.

Ask a homework question - tutors are online