Download - Graph Theory
![Page 1: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/1.jpg)
Graph TheoryAlgorithms
Breadth First Search (BFS)Depth First Search (DFS)
Dijkstra’s Algorithm
![Page 2: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/2.jpg)
Famous and Productive Problem of Graph Theory
Four Color Problem: Is it true that any map drawn in the plane may have its regions colored with four colors in such a way that any two regions having a common border have different colors?
![Page 3: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/3.jpg)
Is there a way to color this map using four different colors and still ensure that bordering
states all have different colors?
![Page 4: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/4.jpg)
What Is Graph Theory?
The Study of Graphs- DEFN: Structures used
to model relationships between objects- Often used to describe
a collection of nodes (vertices) and edges
![Page 5: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/5.jpg)
Different Types of Graphs
Graphs come in two distinct formsUndirected vs. Directed Graphs
Although they are grouped under the umbrella term of graph, these graph have specific characteristics that distinguish them from each other
![Page 6: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/6.jpg)
Undirected Graph
DEFN: Set of nodes connected by edges but there is no distinction between vertices associated with each edge
EXPLANATION: In the eyes of the graph, there is no difference between the edges that connect nodes. Basically the edge that connects vertices (6,4) is the very same edge that connects vertices (5,2)
![Page 7: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/7.jpg)
Undirected Graphs
![Page 8: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/8.jpg)
Directed Graph
DEFN: Set of nodes connected by edges, where the edges have a direction associated with them
EXPLANATION: Major difference between edges. The edge that connects vertices (7,8) is DIFFERENT from the edge that connects vertices (3,10)
MAJOR INDICATION: THE ARROWS!!
![Page 9: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/9.jpg)
Directed Graphs
![Page 10: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/10.jpg)
Applications
Used to model many types of relationshipsHave use in many aspects of physical, biological, and social system- Many problems of
practical interest can be represented by graphs
![Page 11: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/11.jpg)
Computer Science Applications
Can be used to represent network of communication, data organization, flow of computation, and more
Practical ExampleThe links on a website can represented by a directed graph. The vertices are the web pages available at the website and a directed edge from page A to page B exists if and only if A contains a link to B.
![Page 12: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/12.jpg)
Other Applications
Chemistry
Sociology
Math
![Page 13: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/13.jpg)
Algorithms
What is an ALGORITHM?DEFN: Set of step by step procedure for
calculation
Input Output
Set of Directions “Algorithm”
![Page 14: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/14.jpg)
Types of Algorithms
Simplistic Algorithms Complex Algorithms
Main purpose: Based on given problem, can you create step by step instructions to produce an appropriate solution?
![Page 15: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/15.jpg)
Breadth First Search Algorithm
Algorithm used for searching a graph
Starts at the root (top of the graph) and does a layer by layer search
Moves left to right during its search
![Page 16: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/16.jpg)
BFSDoes a layer by layer search
![Page 17: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/17.jpg)
Depth First Search Algorithm
Another algorithm used for searching a graph
Starts at the root (top of the graph) Moves left to right during its search
Major Difference: Starts at the root and explores as far as possible along each branch
before backtracking
![Page 18: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/18.jpg)
DFSDoes a depth search before backtracking
![Page 19: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/19.jpg)
Dijkstra’s Algorithm
Discovered by Dutch computer scientist Edsger Dijkstra in 1956
DEFN: Graph search algorithm that solves the shortest path problem with edge path cost to
produce a shortest path tree
SIMPLY: How can we get from the start position to the end position in the least amount of “steps”
![Page 20: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/20.jpg)
Dijkstra’s Algorithm
The major thing to notice in this graph is that the
edges have specific numbers given to them
called “weights”
Weights
![Page 21: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/21.jpg)
Remember?Undirected graph implementation
of Dijkstra’s algorithmDirected graph implementation
of Dijkstra’s algorithm
The addition of the value of weights to the edges is the major difference between the normal implementation
of undirected and directed graphs and Dijkstra implementation of those graphs
![Page 22: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/22.jpg)
How To Tackle Dijkstra Problems
The idea is to get from the start position to the end position
You want to take the road that will give you the least value in the end
Start
End
![Page 23: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/23.jpg)
Example
The best way to leave how to do this is to run through an example
Dijkstra's Algorithm for Shortest Route Problems
![Page 24: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/24.jpg)
Famous and Productive Problem of Graph Theory
Four Color Problem: Is it true that any map drawn in the plane may have its regions colored with four colors in such a way that any two regions having a common border have different colors?
![Page 25: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/25.jpg)
Solution to The Four Color Problem
![Page 26: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/26.jpg)
Four Color Problem
![Page 27: Graph Theory](https://reader035.vdocuments.net/reader035/viewer/2022062323/56816226550346895dd257e7/html5/thumbnails/27.jpg)
Worksheet Time!!!!