lecture 37: graphs - cs.pomona.edu · lecture 37: graphs michael j. bannister and kim bruce pomona...
TRANSCRIPT
Lecture 37: Graphs
Michael J. Bannister and Kim BrucePomona College, Fall 2015
Announcements
• Reading: Bailey Chapter 16• Assignment 12: Driving Directions• Lab 12: Graph Search
Examples of Graphs
• Communication networks• Transportation networks• Social networks• Biological interaction networks• Matching graphs• and many more...
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!
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
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)
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)
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)