cs340-09s_slides09-graphs - Graphs : Traversals Shortest...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

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

Unformatted text preview: Graphs : Traversals Shortest Path Minimum Spanning Trees Network Flow (and more graph stuff) and Complexity CS340: Data Structures and Algorithms Bouviers Presentation based on PPTs by: Rose Hoberman William White 2 Graph Reperesentations 3 Graphs A graph G = (V, E) consists of a set of vertices , V , and a set of edges, E , each of which is a pair of vertices. If the edges are ordered pairs of vertices, then the graph is directed . Undirected, unweighted, unconnected, loopless graph (length of longest simple path: 2) Directed, unweighted, acyclic, weakly connected, loopless graph (length of longest simple path: 6) Directed, unweighted, cyclic, strongly connected, loopless graph (length of longest simple cycle: 7) Undirected, unweighted, connected graph, with loops (length of longest simple path: 4) Directed, weighted, cyclic, weakly connected, loopless graph (weight of longest simple cycle: 27) 3 4 2 4 2 3 5 6 3 6 5 4 Graph Representations Adjacency Matrix: A B D H E G F C A B C D E F G H A B C D E F G H 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 A B D H E G F C A B C D E F G H A B C D E F G H 1 1 1 1 1 1 1 1 1 1 1 1 A B D H E G F C 3 4 2 4 2 3 5 6 3 6 5 A B C D E F G H A B C D E F G H 2 3 5 4 6 6 2 3 4 5 3 The Problem: Most graphs are sparse (i.e., most vertex pairs are not edges), so the memory requirement is excessive: ( V 2 ). 5 Adjacency List: A B C D E F G H A A B B E G A G B C G E G D F H A B D H E G F C A B C D E F G H B B 3 H G 6 2 4 C A 3 5 3 5 4 2 D E G G 6 E A B D H E G F C 3 4 2 4 2 3 5 6 3 6 5 A B C D E F G H B E B G C A E D F G D H A B D H E G F C Graph Terminology 7 Paths and cycles A path is a sequence of nodes v 1 , v 2 , , v N such that (v i ,v i +1 ) E for 0< i <N The length of the path is N-1. Simple path : all v i are distinct, 0< i <N A cycle is a path such that v 1 =v N An acyclic graph has no cycles 8 Cycles PIT BOS JFK DTW LAX SFO 9 More useful definitions In a directed graph: The indegree of a node v is the number of distinct edges (w,v) E. The outdegree of a node v is the number of distinct edges (v,w) E. A node with indegree 0 is a root . 10 Trees are graphs dag- a d irected a cyclic g raph. tree- an undirected connected acyclic graph forest- an acyclic undirected graph (not necessarily connected) (i.e., each connected component is a tree) 11 Example DAG Watch Socks Shoes Underwear Pants Belt Tie Shirt Jacket a DAG implies an ordering on events 12 Example DAG In a complex DAG, it can be hard to find a schedule that obeys all the constraints....
View Full Document

This note was uploaded on 08/26/2009 for the course CS 340 taught by Professor Bouvier,d during the Spring '09 term at Southern Illinois University Edwardsville.

Page1 / 76

cs340-09s_slides09-graphs - Graphs : Traversals Shortest...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online