End of Term Review 2.4

End of Term Review 2.4 - Graphs Definitions &...

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: Graphs Definitions & Properties Implementations Depth-First Search Topological Sort Breadth-First Search Weighted Graphs Single-Source Shortest Path on DAGs General Single-Source Shortest Path (Dijkstra’s Algorithm) CSE 2011 Prof. J. Elder - 66 - Last Updated: 4/1/10 2:37 PM Properties Property 1 Notation v deg(v) |V| number of edges deg(v) Proof: each edge is counted twice number of vertices |E| = 2|E| degree of vertex v Property 2 In an undirected graph with no self-loops and no multiple edges |E| |V| (|V| Example |V| = 4 |E| = 6 deg(v) = 3 1)/2 Proof: each vertex has degree at most (|V| 1) Q: What is the bound for a digraph? A: E V (V CSE 2011 Prof. J. Elder 1) - 67 - Last Updated: 4/1/10 2:37 PM Main Methods of the (Undirected) Graph ADT Vertices and edges Update methods are positions insertVertex(o): insert a vertex storing element o store elements insertEdge(v, w, o): insert an edge (v,w) storing element o Accessor methods endVertices(e): an array of the two endvertices of e removeVertex(v): remove vertex v (and its incident edges) opposite(v, e): the vertex opposite to v on e removeEdge(e): remove edge e Iterator methods areAdjacent(v, w): true iff v and w are adjacent replace(v, x): replace element at vertex v with x replace(e, x): replace element at edge e with x CSE 2011 Prof. J. Elder - 68 - incidentEdges(v): edges incident to v vertices(): all vertices in the graph edges(): all edges in the graph Last Updated: 4/1/10 2:37 PM Running Time of Graph Algorithms Running time often a function of both |V| and |E|. For convenience, we sometimes drop the | . | in asymptotic notation, e.g. O(V+E). CSE 2011 Prof. J. Elder - 69 - Last Updated: 4/1/10 2:37 PM Implementing a Graph (Simplified) Adjacency List CSE 2011 Prof. J. Elder - 70 - Adjacency Matrix Last Updated: 4/1/10 2:37 PM ...
View Full Document

This note was uploaded on 02/14/2012 for the course CSE 2011Z taught by Professor Elder during the Fall '11 term at York University.

Ask a homework question - tutors are online