lecture 37: graphs - cs.pomona.edu · lecture 37: graphs michael j. bannister and kim bruce pomona...

8
Lecture 37: Graphs Michael J. Bannister and Kim Bruce Pomona College, Fall 2015

Upload: others

Post on 15-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 37: Graphs - cs.pomona.edu · Lecture 37: Graphs Michael J. Bannister and Kim Bruce Pomona College, Fall 2015

Lecture 37: Graphs

Michael J. Bannister and Kim BrucePomona College, Fall 2015

Page 2: Lecture 37: Graphs - cs.pomona.edu · Lecture 37: Graphs Michael J. Bannister and Kim Bruce Pomona College, Fall 2015

Announcements

• Reading: Bailey Chapter 16• Assignment 12: Driving Directions• Lab 12: Graph Search

Page 3: Lecture 37: Graphs - cs.pomona.edu · Lecture 37: Graphs Michael J. Bannister and Kim Bruce Pomona College, Fall 2015

Examples of Graphs

• Communication networks• Transportation networks• Social networks• Biological interaction networks• Matching graphs• and many more...

Page 4: Lecture 37: Graphs - cs.pomona.edu · Lecture 37: Graphs Michael J. Bannister and Kim Bruce Pomona College, Fall 2015

Things to do with graphs

• Find shortest/“cheapest” routes• Minimize cost for connecting a network• Maximize communication throughput• Answer sociological queries• Match ads to viewers• Cure cancer• Visualize• Have fun!

Page 5: Lecture 37: Graphs - cs.pomona.edu · Lecture 37: Graphs Michael J. Bannister and Kim Bruce Pomona College, Fall 2015

Definitions

• A graph G is a pair (V,E) such that• V is a (finite) set of vertices (aka nodes)• E is a set of (ordered) pairs of vertices called edges

Page 6: Lecture 37: Graphs - cs.pomona.edu · Lecture 37: Graphs Michael J. Bannister and Kim Bruce Pomona College, Fall 2015

Directed vs. Undirected

• Undirected graphs: Edges are symmetric– A roads are two way roads

• Directed graphs: Edges are directed from theirsource to their destinations– Some roads may be one way roads

• (Example on board)

Page 7: Lecture 37: Graphs - cs.pomona.edu · Lecture 37: Graphs Michael J. Bannister and Kim Bruce Pomona College, Fall 2015

Graph Terms

• incident• adjacent• degree (in and out)• path• path length• cycle

• simple path• simple cycle• self loop• acyclic graph (tree)• simple graph• Connected• Strongly connected

(on board)

Page 8: Lecture 37: Graphs - cs.pomona.edu · Lecture 37: Graphs Michael J. Bannister and Kim Bruce Pomona College, Fall 2015

Digital Representations

• Adjacency Matrix– Store graph as a n× n matrix of bool

• Adjacency List– For each vertex store a list of (in and out)

neighbors

(details on board)