L08 - Graphs.pdf - 337 LAX ORD 802 SFO 1843 1233 DFW Graphs...

Info icon This preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Graphs ORD DFW SFO LAX 802 1843 1233 337
Image of page 1

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

View Full Document Right Arrow Icon
Graphs } A graph is a pair ( V, E ) , where } V is a set of nodes, called vertices } E is a collection of pairs of vertices, called edges } Vertices and edges have meaning when constructed from a problem } Example: } A vertex represents an airport and stores the three-letter airport code } An edge represents a flight route between two airports and stores the mileage of the route ORD PVD MIA DFW SFO LAX LGA HNL 849 802 1843 1120 1233 337 2555 © Goodrich Tamassia 2
Image of page 2
Edge Types } Directed edge } ordered pair of vertices ( u , v ) } first vertex u is the origin } second vertex v is the destination } e.g., a flight } Undirected edge } unordered pair of vertices ( u , v ) } e.g., a flight route } Directed graph } all the edges are directed } e.g., route network } Undirected graph } all the edges are undirected } e.g., flight network ORD PVD flight AA 1206 ORD PVD 849 miles © Goodrich Tamassia 3
Image of page 3

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

View Full Document Right Arrow Icon
John David Paul brown.edu cox.net cs.brown.edu att.net qwest.net math.brown.edu cslab1b cslab1a Applications } Electronic circuits } Printed circuit board } Integrated circuit } Transportation networks } Highway network } Flight network } Computer networks } Local area network } Internet } Web } Databases } Entity-relationship diagram © Goodrich Tamassia 4
Image of page 4
Terminology } End vertices (or endpoints) of an edge } U and V are the endpoints of edge a } Edges incident on a vertex } a , d , and b are incident on V } Adjacent vertices } U and V are adjacent } Degree of a vertex } X has degree 5 } Parallel edges } h and i are parallel edges } Self-loop } j is a self-loop X U V W Z Y a c b e d f g h i j © Goodrich Tamassia 5
Image of page 5

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

View Full Document Right Arrow Icon
P 1 Terminology (cont.) } Path } sequence of alternating vertices and edges } begins with a vertex } ends with a vertex } each edge is preceded and followed by its endpoints } Simple path } path such that all its vertices and edges are distinct } Examples } P 1 =( V , b , X , h , Z ) is a simple path } P 2 =( U , c , W , e , X , g , Y , f , W , d , V ) is a path that is not simple X U V W Z Y a c b e d f g h P 2 © Goodrich Tamassia 6
Image of page 6
Terminology (cont.) } Cycle } circular sequence of alternating vertices and edges } each edge is preceded and followed by its endpoints } Simple cycle } cycle such that all its vertices and edges are distinct } Examples } C 1 =( V , b , X , g , Y , f , W , c , U , a , ) is a simple cycle } C 2 =( U , c , W , e , X , g , Y , f , W , d , V , a , ) is a cycle that is not simple C 1 X U V W Z Y a c b e d f g h C 2 © Goodrich Tamassia 7
Image of page 7

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

View Full Document Right Arrow Icon
Properties Notation n number of vertices m number of edges deg( v ) degree of vertex v Property 1 Σ v deg( v ) = 2 m Proof: each edge is counted twice Property 2 In an undirected graph with no self-loops and no multiple edges m n ( n ± 1) / 2 Proof: each vertex has degree at most ( n ± 1) What is the bound for a directed graph? Example n n = 4 n m = 6 n deg( v ) = 3 © Goodrich Tamassia 8
Image of page 8
Main Methods of the Graph ADT } Vertices and edges } are positions } store elements (problem based) } Accessor methods } endVertices (e): an array of the two endvertices of e } opposite (v, e): the vertex opposite of v on e } 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 } Update methods }
Image of page 9

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern