lecture 5 cse 331. graphs problem statement algorithm problem definition “implementation”...
DESCRIPTION
Graphs Representation of relationships between pairs of entities/elements Entities: News hosts Relationship: Mention in other’s program Entities: News hosts Relationship: Mention in other’s program Vertex/Node EdgeTRANSCRIPT
![Page 1: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/1.jpg)
Lecture 5
CSE 331
![Page 2: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/2.jpg)
GraphsProblem Statement
Algorithm
Problem Definition
“Implementation”
Analysis
A generic tool to abstract out
problems
![Page 3: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/3.jpg)
GraphsRepresentation of relationships between pairs of entities/elements
Entities: News hosts
Relationship: Mention in other’s program
Vertex/Node
Edge
![Page 4: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/4.jpg)
Graphs are omnipresentAirline Route maps
![Page 5: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/5.jpg)
What does this graph represent?
Internet
![Page 6: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/6.jpg)
And this one?Math articles on Wikipedia
![Page 7: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/7.jpg)
And this one?
![Page 8: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/8.jpg)
Basic Graph definitionsFormally define everything
http://imgs.xkcd.com/comics/geeks_and_nerds.png
![Page 9: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/9.jpg)
Paths
Sequence of vertices connected by edges
, , ,
Path length 3
,
Connected
![Page 10: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/10.jpg)
Connectivity
u and w are connected iff there is a path between them
A graph is connected iff all pairs of vertices are connected
![Page 11: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/11.jpg)
Connected Graphs
Every pair of vertices has a path between them
![Page 12: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/12.jpg)
Cycles
Sequence of k vertices connected by edges, first k-1 are distinct
, , ,
![Page 13: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/13.jpg)
TreeConnected undirected graph with no cycles
![Page 14: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/14.jpg)
Rooted Tree
![Page 15: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/15.jpg)
A rooted tree
Pick any vertex as root
Let the rest of the tree hang under “gravity”
How many rooted trees
can an n vertex tree
have?
SG’s parent=AC
AC’s child=SG
![Page 16: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/16.jpg)
Prove n vertex tree has n-1 edges
![Page 17: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/17.jpg)
Prove n vertex tree has n-1 edges
• Pick an arbitrary node to be the root• Image every edge is directed towards the root• Every non-root node has 1 outgoing edge• There are n-1 non-root nodes• There are n-1 edges
1
2 3
4 5 7 8
6
![Page 18: Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems](https://reader035.vdocuments.mx/reader035/viewer/2022070605/5a4d1ad17f8b9ab059971697/html5/thumbnails/18.jpg)
Directed graphs
Model asymmetric relationships
Precedence relationships
u needs to be done before w means (u,w) edge