Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories...

17
Graph Theory ITEC 320 Lecture 21

Transcript of Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories...

Page 1: Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.

Graph Theory

ITEC 320Lecture 21

Page 2: Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.

Graph Theory

Review

• Higher level usage of pointers– Factories– Flyweight– Disk pool

• Rationale• Benefits / Downsides

Page 3: Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.

Graph Theory

Outline

• Rationale • Definition• Methods of implementation• Algorithms

Page 4: Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.

Graph Theory

Cell phones

• How do they work (communication side)

Page 5: Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.

Graph Theory

Cell Networks

Page 6: Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.

Graph Theory

Other scenarios

• Computer networks• Google maps• Facebook friends• Gaming

Page 7: Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.

Graph Theory

Rationale

• How do you model a cell phone network on a computer?

• Why would you want to simulate a cell phone network?

Page 8: Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.

Graph Theory

Graphs

• Composed of vertices and edges• Vertices– Represent an object in a graph

• Edges– A connection between two vertices

Page 9: Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.

Graph Theory

Variations

• Weighted graph– Toll road– Hotel cost– Identifiers

• Possible usage scenarios?

Page 10: Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.

Graph Theory

Methods of implementation

• Arrays• Pointers• Benefits of each approach• Downsides of each approach

Page 11: Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.

Graph Theory

Code

• Should we use a package?• What about generics?

Page 12: Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.

Graph Theory

Searching

• How do you find information in a graph?

Destination

Start

Page 13: Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.

Graph Theory

Breadth first

• For each node I am connected to– Is this the node I’m looking for?

• If I didn’t find it– For each node I am connected to• Call breadth first search on it

Page 14: Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.

Graph Theory

Depth first

• If I am the node searched for, stop and return

• For each node I am connected to– Call depth first search on that node

Page 15: Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.

Graph Theory

Issues

• What are some of the issues that might happen with searching?

• How do you implement each way?– Stacks / Recursion / Packages / ?

Page 16: Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.

Graph Theory

More

• How do you pick the best path?– Lowest cost– Highest cost– Cover all points with least overlap

Page 17: Graph Theory ITEC 320 Lecture 21. Graph Theory Review Higher level usage of pointers –Factories –Flyweight –Disk pool Rationale Benefits / Downsides.

Graph Theory

Summary

• Rationale for graph theory• Approach• Finding algorithms