*This preview shows
pages
1–15. Sign up
to
view the full content.*

This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
**Unformatted text preview: **Introduction to Graphs 15-211 Fundamental Data Structures and Algorithms Margaret Reid-Miller 16 March 2010 Reading for today: Sections 14.1 14.3 2 Announcements Quiz 4 in recitation tomorrow Homework: Theory due in lecture Thursday Programming due 11:59 pm Monday Programming is substantial dont delay! 3 Todays outline: Graphs! Common properties of graphs Representations Paths and Reachability Making Connections Containers : Data structures such as lists, BSTs, splay trees, hash tables, can be used to store data items. Relationships: Graphs provide an abstract model for the expressing connections between pairs of items and their implies relationships. 4 5 Making Connections Example 1 . A (nowadays) classical example: the World Wide Web. <href > <href > <href > <href > <href > <href > <href > Web Pages are nodes (vertices) HTML references are links (edges) 6 Structure of the Internet Europe Japan Backbone 1 Backbone 2 Backbone 3 Backbone 4, 5, N Australia Regional A Regional B NAP NAP NAP NAP SOURCE: CISCO SYSTEMS 7 Examples of Graphs Vanguard Airlines Route Map Questions What is the fastest way to get from Pittsburgh to St Louis? What is the cheapest way to get from Pittsburgh to St Louis? 8 Abstraction and Representation Experience shows that graphs are often very useful in this regard. Lots of problems can be translated into a question about graphs, and there are many efficient algorithms to tackle the latter. problem domain solution domain We need to represent problems in some computational domain, so we can use assorted algorithms to solve them. computational domain computational domain 9 Schedules and hierarchies Scheduling and resource constraints. Inheritance hierarchies. 15-113 15-121 15-211 15-212 15-213 15-312 15-411 15-410 15-251 15-451 15-462 10 Countries and borders Poland Germany Denmark Nether. Belgium Austria France Switz. Czech R. Spain Italy Luxem. How do I color a map so that no neighboring countries have the same color? 11 A computer program if (size == 0) return false; Node n = head; while (n != null) { if (n.data.equals(item)) return true; n = n.next; } return false; end size =? 0 begin n =? null n.data =? item no yes yes no yes n := n.next no 12 e.g., A word morph game Change one letter at a time to reach a goal word Intermediate steps must be words e.g.: head and foot: head - bead - beat - boat - boot - foot A problem from the New York Times: white - - house 13 Graphs as models Physical objects are often modeled by meshes, which are a particular kind of graph structure. By Jonathan Shewchuk 14 Directed graphs Definition: A directed graph (or digraph ) is a structure G = <V,E> where V is a set of vertices ( or nodes), E V V is a set of edges (or arcs)....

View
Full
Document