Graphs, Part 1. Please take a handout & Sit in row H or forward. Week 12, Class 21. CS 60, Spring 2016 B D
|
|
- Darrell Wilson
- 5 years ago
- Views:
Transcription
1 Graphs, Part 1 nope nope yep! upload.wikimedia.org/wikipedia/commons/4/45/wikimedia_ommons_monthly_uploads_graph.png upload.wikimedia.org/wikipedia/commons/9/93/giraffe_head_1a_( ).jpg Please take a handout & Sit in row H or forward S 60, Spring 2016 Week 12, lass 21
2 The Seven ridges of Königsberg an you: start at point, cross every bridge only once, and return to point? Leonard Euler No! commons.wikimedia.org/wiki/file:leonhard_euler.jpg Koenigsberg, Map by Merian-Erben 1652 commons.wikimedia.org/wiki/file:image-koenigsberg,_map_by_merian-erben_1652.jpg
3 We need a model Koenigsberg, Map by Merian-Erben 1652 commons.wikimedia.org/wiki/file:image-koenigsberg,_map_by_merian-erben_1652.jpg
4 Graphs! set of nodes/vertices (places), and a set of edges (links) nodes edge
5 This week s theme: Graphs Our goals are to: practice implementing data structures and algorithms functional (Racket) and imperative (Java) implementations learn / implement / compare multiple representations There is more than one way to represent a graph! know when to use the right data structure If we care about the relationships among pieces of data, we might want a graph.
6 This week s theme: Graphs Today why graphs? because relationships matter! graph vocabulary node edge (un)directed (un)weighted connected cycle graph as data structure: interface Racket graphs plus: use-it-or-lose-it! Thursday graph as data structure: representation (in Java) edge list adjacency list adjacency matrix ssignment graphs in Racket & Java, plus: Harry Potter!
7 Graphs represent relationships Like what? node is n edge is nodes edge
8 Graphs represent relationships Like Facebook node is a Facebook user n edge is a friendship
9 Undirected graph important vocabulary! We can traverse the edge in both directions. The relationship is mutual.
10 Undirected graph important vocabulary! We can traverse the edge in both directions. The relationship is mutual.
11 Graphs represent relationships Like Twitter node is a Twitter user n edge is a follow williamjturkel.files.wordpress.com/2011/08/fig-5-niche-twitter-followers jpg
12 irected graph important vocabulary! We can traverse the edge in one direction. The relationship is one way. edge destination edge source
13 irected graph important vocabulary! We can traverse the edge in one direction. The relationship is one way. edge source edge destination
14 Graphs represent relationships Like highways node is a city n edge is a highway from one city to another upload.wikimedia.org/wikipedia/commons/4/45/l-ie_freeway_system.jpg
15 Weighted graph important vocabulary! Information (usually cost ) associated with each edge
16 Graphs represent relationships Like flights node is a city n edge is a flight from one city to another
17 irected weighted graph important vocabulary! Information (usually cost ) associated with each edge edge source edge weight 0 edge destination
18 Undirected irected Unweighted facebook twitter Weighted highways flights weights = distance, time, cost weights = distance, time, cost
19 onnected graph important vocabulary! There is a path between each pair of nodes. In other words, each node is reachable from every other node. If this is true in a directed graph, the graph is strongly connected. connected not connected
20 We ve seen graphs before! 7& 27& 3& 6& 13& 1& 42& 2& 5& ville& (ity&1)& eesburg& (ity&2)& ee&ity& (ity&3)& eesdale& (ity&4)& Etown& (ity&5)&
21 We ve seen graphs before! a list is a a tree is a graph graph there may be more than one path to a node tree connected, directed graph exactly one path to each node linked list connected, directed graph exactly one path to each node each node has at most one child
22 ycle important vocabulary! no cycles there are a finite number of paths to a node cycle there may be an infinite number of paths to a node
23 esigning and implementing a new data structure Interface escribes: what this data structure can do Implementation: encoding escribes: how the structure is stored, using existing data structures Implementation: operations efines: how the structure provides its interface via algorithms over the encoding It should be possible to replace the implementation without modifying the interface.
24 esigning and implementing a new data structure Interface escribes: what this data structure can do Nodes construct set contents get contents Edges construct set source set destination set weight get source get destination get weight Graphs construct empty graph add / remove edge add / remove node test if empty get all edges / nodes search for edge / node is node b reachable from a?
25 Graphs in Racket
26 esigning and implementing a new data structure Interface escribes: what this data structure can do Implementation: encoding escribes: how the structure is stored, using existing data structures Implementation: operations efines: how the structure provides its interface via algorithms over the encoding It should be possible to replace the implementation without modifying the interface. Our Racket graphs will be connected, weighted, directed, and functional
27 esigning and implementing a new data structure Interface escribes: what this data structure can do Nodes construct set contents get contents Edges construct set source set destination set weight get source get destination get weight Graphs construct empty graph add / remove edge add / remove node test if empty get all edges / nodes search for edge / node is node b reachable from a?
28 Our Racket graphs: Interface this interface is not built in to Racket Edges onstructor (make-edge source destination weight) Graphs onstructor (make-empty-graph) Operations (emptygraph? graph) (edge-list graph) Operations (src edge) (dst edge) (weight edge) Modifications return a new graph (add-edge edge graph) (remove-edge edge graph)
29 Our Racket graphs: examples > (make-edge ' ' ) > (src ) ' > (dst ) ' > (weight ) > (edge-list ) '(
30 esigning and implementing a new data structure Interface escribes: what this data structure can do Nodes construct set contents get contents Edges construct set source set destination set weight get source get destination get weight Graphs construct empty graph add / remove edge add / remove node test if empty get all edges / nodes search for edge / node is node b reachable from a?
31 ;; node-list: ;; inputs: graph ;; outputs: list of nodes in graph (no duplicates) (define (node-list graph) (let* ([edges (edge-list graph)] [srcs (map src edges)] [dsts (map dst edges)]) (remove-duplicates (append srcs dsts)))) Q graph operations (emptygraph? graph) (edge-list graph) (add-edge edge graph) (remove-edge edge graph) (src edge) (dst edge) list operations (empty? list) (cons elem list) (first list) (rest list) (map function list) (append list1 list2) (member elem list) (remove-duplicates list) and more: docs.racket-lang.org/reference/pairs.html
32 ;; node-list: ;; inputs: graph ;; outputs: list of nodes in graph (no duplicates) (define (node-list graph) (let* ([edges (edge-list graph)] [srcs (map src edges)] [dsts (map dst edges)]) (remove-duplicates (append srcs dsts)))) Q graph operations (emptygraph? graph) (edge-list graph) (add-edge edge graph) (remove-edge edge graph) (src edge) (dst edge) list operations (empty? list) (cons elem list) (first list) (rest list) (map function list) (append list1 list2) (member elem list) (remove-duplicates list) and more: docs.racket-lang.org/reference/pairs.html
33 ;; contains-edge: ;; inputs: an edge and a graph ;; outputs: true if the graph contains the edge (define (contains-edge edge graph) (list? (member edge (edge-list graph)))) ;; contains-node: ;; inputs: a node and a graph ;; outputs: true if the node is in the graph (define (contains-node node graph) (list? (member node (node-list graph)))) graph operations (emptygraph? graph) (edge-list graph) (add-edge edge graph) (remove-edge edge graph) (src edge) (dst edge) list operations (empty? list) (cons elem list) (first list) (rest list) (map function list) (append list1 list2) (member elem list) (remove-duplicates list) and more: docs.racket-lang.org/reference/pairs.html
34 esigning and implementing a new data structure Interface escribes: what this data structure can do Nodes construct set contents get contents Edges construct set source set destination set weight get source get destination get weight Graphs construct empty graph add / remove edge add / remove node test if empty get all edges / nodes search for edge / node is node b reachable from a?
35 upload.wikimedia.org/wikipedia/commons/8/8c/key_break.jpg
36 etour: Use it or lose it
37 Review: use it or lose it a recursive strategy fill in the pieces ase case(s) Recursive case(s) 1. It: a piece of the problem 2. Lose it: How could we solve a smaller version without it? 3. Use it: How could we solve a smaller version with it? 4. How would we combine the solutions to solve the full problem?
38 > (uniq '(c a l i f o r n i a)) '(c l f o r n i a) > (uniq '(m u d d)) '(m u d) > (uniq '(m i s s i p p i)) '(m s p i)
39 unique: use it or lose it a recursive strategy fill in the pieces ase case(s) empty list empty list Recursive case(s) 1. It: a piece of the problem the first element 2. Smaller version: What does the input look like without it? the rest of the list 3. Lose it: How could we solve a smaller version without it? unique-ify the rest of the list 4. Use it: How could we solve a smaller version with it? pre-pend it to the lose-it solution > (uniq '(c a l i f o r n i a)) '(c l f o r n i a) > (uniq '(m u d d)) '(m u d) > (uniq '(m i s s i p p i)) '(m s p i) 5. How would we combine the solutions to solve the full problem? if it is in lose-it, then lose-it ; else use-it
40 unique: use it or lose it a recursive strategy (define (uniq L) (if (empty? L) '() (let* ([it (first L)] [lose-it (uniq (rest L))] [use-it (cons it lose-it)]) (if (member it lose-it) lose-it use-it))))
41 unique: use it or lose it a recursive strategy (define (uniq L) (if (empty? L) '() (let* ([it (first L)] [lose-it (uniq (rest L))] [use-it (cons it lose-it)]) (if (member it lose-it) lose-it use-it))))
42 The cost of uniq measured in list-element comparisons (define (uniq L) (if (empty? L) '() (let* ([it (first L)] n-1 comparisons [lose-it (uniq (rest L))] [use-it (cons it lose-it)]) (if (member it lose-it) lose-it use-it)))) T(0) = 0 T(n) = n-1 + T(n-1) T(n) = n-1 + T(n-1) = n-1 + n-2 + T(n-2) O(n 2 )
43 reachable?: use it or lose it a recursive strategy fill in the pieces ase case(s) a node is always reachable from itself no nodes are reachable in the empty graph Recursive case(s) 1. It: a piece of the problem an edge, c d 2. Smaller version: What does the input look like without it? the graph without that edge, called sub-graph 3. Lose it: How could we solve a smaller version without it? is a reachable from b in sub-graph? 4. Use it: How could we solve a smaller version with it? is c reachable from a N is b reachable from d in sub-graph? 5. How would we combine the solutions to solve the full problem? use-it OR lose-it
44 reachable?: use it or lose it (define (reachable? a b G) (cond [(equal? a b) true] [(emptygraph? G) false] [else graph operations (emptygraph? graph) (edge-list graph) (add-edge edge graph) (remove-edge edge graph) (src edge) (dst edge) list operations (empty? list) (cons elem list) (first list) (rest list) (map function list) (append list1 list2) (member elem list) (remove-duplicates list) and more: docs.racket-lang.org/reference/pairs.html
45 reachable?: use it or lose it (define (reachable? a b G) (cond [(equal? a b) true] [(emptygraph? G) false] [else (let* ([edges (edge-list G)] [it (first edges)] [subg (remove-edge it G)] [lose-it (reachable? a b subg)] [use-it (and (reachable? a (src it) subg) (reachable? (dst it) b subg))]) (or use-it lose-it))])) graph operations (emptygraph? graph) (edge-list graph) (add-edge edge graph) (remove-edge edge graph) (src edge) (dst edge) list operations (empty? list) (cons elem list) (first list) (rest list) (map function list) (append list1 list2) (member elem list) (remove-duplicates list) and more: docs.racket-lang.org/reference/pairs.html
46 The cost of reachable? measured in number of edges seen, i.e., calls to remove-edge (define (reachable? a b G) (cond [(equal? a b) true] [(emptygraph? G) false] [else (let* ([edges (edge-list G)] [it (first edges)] [subg (remove-edge it G)] [lose-it (reachable? a b subg)] [use-it (and (reachable? a (src it) subg) (reachable? (dst it) b subg))]) (or use-it lose-it))])) T(0) = 0 T(e) = * T(e-1) T(e) = 1 + 3*T(e-1) = 1 + 3*(1 + 3*T(e-2)) = 4 + 9*T(e-2) = 4 + 9*(1 + 3*T(e-3)) = *T(e-3) O(3 e )
Graphs & Digraphs Tuesday, November 06, 2007
Graphs & Digraphs Tuesday, November 06, 2007 10:34 PM 16.1 Directed Graphs (digraphs) like a tree but w/ no root node & no guarantee of paths between nodes consists of: nodes/vertices - a set of elements
More informationCSE 373 NOVEMBER 20 TH TOPOLOGICAL SORT
CSE 373 NOVEMBER 20 TH TOPOLOGICAL SORT PROJECT 3 500 Internal Error problems Hopefully all resolved (or close to) P3P1 grades are up (but muted) Leave canvas comment Emails tomorrow End of quarter GRAPHS
More informationCS 206 Introduction to Computer Science II
CS 206 Introduction to Computer Science II 04 / 06 / 2018 Instructor: Michael Eckmann Today s Topics Questions? Comments? Graphs Definition Terminology two ways to represent edges in implementation traversals
More informationGraphs And Algorithms
Graphs nd lgorithms Mandatory: hapter 3 Sections 3.1 & 3.2 Reading ssignment 2 1 Graphs bstraction of ata 3 t the end of this section, you will be able to: 1. efine directed and undirected graphs 2. Use
More information(add1 3) 4 (check-expect (add1 3) 4)
(add1 3) 4 (check-expect (add1 3) 4) (define T 7) (define (q z) (sqr z)) (cond [(> T 3) (q 4)] [else 9]) (cond [(> T 3) (q 4)] [else 9]) -->[const] ^ (cond [(> 7 3) (q 4)] [else 9]) -->[arith] ^^^^^^^
More informationWorksheet for the Final Exam - Part I. Graphs
Worksheet for the Final Exam - Part I. Graphs Date and Time: May 10 2012 Thursday 11:50AM~1:50PM Location: Eng 120 Start with the Self-Test Exercises (pp.816) in Prichard. 1. Give the adjacency matrix
More informationGRAPH THEORY. What are graphs? Why graphs? Graphs are usually used to represent different elements that are somehow related to each other.
GRPH THEORY Hadrian ng, Kyle See, March 2017 What are graphs? graph G is a pair G = (V, E) where V is a nonempty set of vertices and E is a set of edges e such that e = {a, b where a and b are vertices.
More informationGraph Theory. Network Science: Graph theory. Graph theory Terminology and notation. Graph theory Graph visualization
Network Science: Graph Theory Ozalp abaoglu ipartimento di Informatica Scienza e Ingegneria Università di ologna www.cs.unibo.it/babaoglu/ ranch of mathematics for the study of structures called graphs
More informationUnderstand graph terminology Implement graphs using
raphs Understand graph terminology Implement graphs using djacency lists and djacency matrices Perform graph searches Depth first search Breadth first search Perform shortest-path algorithms Disjkstra
More informationSome Graph Theory for Network Analysis. CS 249B: Science of Networks Week 01: Thursday, 01/31/08 Daniel Bilar Wellesley College Spring 2008
Some Graph Theory for Network Analysis CS 9B: Science of Networks Week 0: Thursday, 0//08 Daniel Bilar Wellesley College Spring 008 Goals this lecture Introduce you to some jargon what we call things in
More informationGraphs. Reading Assignment. Mandatory: Chapter 3 Sections 3.1 & 3.2. Peeking into Computer Science. Jalal Kawash 2010
Graphs Mandatory: hapter 3 Sections 3.1 & 3.2 Reading ssignment 2 Graphs bstraction of ata 3 t the end of this section, you will be able to: 1.efine directed and undirected graphs 2.Use graphs to model
More informationToday s Outline. CSE 326: Data Structures. Topic #15: Cool Graphs n Pretty Pictures. A Great Mathematician. The Bridges of Königsberg
CSE 326: Data Structures Topic #15: Cool Graphs n Pretty Pictures Ashish Sabharwal Autumn, 2003 Today s Outline Admin Project 3 in-progress checkin due tonight! Graph Algorithms Representation Applications
More informationDiscrete Mathematics for CS Spring 2008 David Wagner Note 13. An Introduction to Graphs
CS 70 Discrete Mathematics for CS Spring 2008 David Wagner Note 13 An Introduction to Graphs Formulating a simple, precise specification of a computational problem is often a prerequisite to writing a
More informationCS4800: Algorithms & Data Jonathan Ullman
CS4800: Algorithms & Data Jonathan Ullman Lecture 11: Graphs Graph Traversals: BFS Feb 16, 2018 What s Next What s Next Graph Algorithms: Graphs: Key Definitions, Properties, Representations Exploring
More informationIntroduction to Graphs. Tecniche di Programmazione A.A. 2017/2018
Introduction to Graphs Tecniche di Programmazione Summary Definition: Graph Related Definitions Applications 2 Definition: Graph Introduction to Graphs Definition: Graph A graph is a collection of points
More informationGraphs. Directed graphs. Readings: Section 28
Graphs Readings: Section 28 CS 135 Winter 2018 12: Graphs 1 Directed graphs A directed graph consists of a collection of vertices (also called nodes) together with a collection of edges. An edge is an
More informationGraphs. Readings: Section 28. CS 135 Fall : Graphs 1
Graphs Readings: Section 28 CS 135 Fall 2018 12: Graphs 1 Directed graphs A directed graph consists of a collection of vertices (also called nodes) together with a collection of edges. An edge is an ordered
More informationChapter 9: Elementary Graph Algorithms Basic Graph Concepts
hapter 9: Elementary Graph lgorithms asic Graph oncepts msc 250 Intro to lgorithms graph is a mathematical object that is used to model different situations objects and processes: Linked list Tree (partial
More informationDiscrete Mathematics and Probability Theory Fall 2009 Satish Rao,David Tse Note 8
CS 70 Discrete Mathematics and Probability Theory Fall 2009 Satish Rao,David Tse Note 8 An Introduction to Graphs Formulating a simple, precise specification of a computational problem is often a prerequisite
More informationLesson 22: Basic Graph Concepts
Lesson 22: asic Graph oncepts msc 175 iscrete Mathematics 1. Introduction graph is a mathematical object that is used to model different relations between objects and processes: Linked list Flowchart of
More informationHere(is(the(XML(Schema(that(describes(the(format:
BuildingBusinessDashboardsusingXSLT,SVG,HTML5 Today seconomyhasdramaticallychangedthewaycompaniesdobusiness,havinganonlinepresenceisnolonger sufficient,andordermanagementsystemshavetobereal:timeandaccessibleonalargevarietyofdevices:
More informationCSE 332: Data Structures & Parallelism Lecture 19: Introduction to Graphs. Ruth Anderson Autumn 2018
SE 332: ata Structures & Parallelism Lecture 19: Introduction to Graphs Ruth nderson utumn 2018 Today Graphs Intro & efinitions 11/19/2018 2 Graphs graph is a formalism for representing relationships among
More informationAnalysis of Algorithms Prof. Karen Daniels
UMass Lowell omputer Science 91.404 nalysis of lgorithms Prof. Karen aniels Spring, 2013 hapter 22: raph lgorithms & rief Introduction to Shortest Paths [Source: ormen et al. textbook except where noted]
More informationGraphs. Data Structures and Algorithms CSE 373 SU 18 BEN JONES 1
Graphs Data Structures and Algorithms CSE 373 SU 18 BEN JONES 1 Warmup Discuss with your neighbors: Come up with as many kinds of relational data as you can (data that can be represented with a graph).
More informationEulerian Tours and Fleury s Algorithm
Eulerian Tours and Fleury s Algorithm CSE21 Winter 2017, Day 12 (B00), Day 8 (A00) February 8, 2017 http://vlsicad.ucsd.edu/courses/cse21-w17 Vocabulary Path (or walk):describes a route from one vertex
More informationModule 9: Binary trees
Module 9: Binary trees Readings: HtDP, Section 14 We will cover the ideas in the text using different examples and different terminology. The readings are still important as an additional source of examples.
More information3.1 Basic Definitions and Applications
Graphs hapter hapter Graphs. Basic efinitions and Applications Graph. G = (V, ) n V = nodes. n = edges between pairs of nodes. n aptures pairwise relationship between objects: Undirected graph represents
More informationGrade 7/8 Math Circles Graph Theory - Solutions October 13/14, 2015
Faculty of Mathematics Waterloo, Ontario N2L 3G1 Centre for Education in Mathematics and Computing Grade 7/8 Math Circles Graph Theory - Solutions October 13/14, 2015 The Seven Bridges of Königsberg In
More informationGraph Theory CS/Math231 Discrete Mathematics Spring2015
1 Graphs Definition 1 A directed graph (or digraph) G is a pair (V, E), where V is a finite set and E is a binary relation on V. The set V is called the vertex set of G, and its elements are called vertices
More informationGraphs and Algorithms
Graphs and Algorithms Graphs are a mathematical concept readily adapted into computer programming. Graphs are not just data structures, that is, they are not solutions to simple data storage problems.
More informationAlgorithms: Graphs. Amotz Bar-Noy. Spring 2012 CUNY. Amotz Bar-Noy (CUNY) Graphs Spring / 95
Algorithms: Graphs Amotz Bar-Noy CUNY Spring 2012 Amotz Bar-Noy (CUNY) Graphs Spring 2012 1 / 95 Graphs Definition: A graph is a collection of edges and vertices. Each edge connects two vertices. Amotz
More informationNotes slides from before lecture. CSE 21, Winter 2017, Section A00. Lecture 9 Notes. Class URL:
Notes slides from before lecture CSE 21, Winter 2017, Section A00 Lecture 9 Notes Class URL: http://vlsicad.ucsd.edu/courses/cse21-w17/ Notes slides from before lecture Notes February 8 (1) HW4 is due
More informationCS115 INTRODUCTION TO COMPUTER SCIENCE 1. Additional Notes Module 5
CS115 INTRODUCTION TO COMPUTER SCIENCE 1 Additional Notes Module 5 Example my-length (Slide 17) 2 (define (my-length alos) [(empty? alos) 0] [else (+ 1 (my-length (rest alos)))])) (my-length empty) alos
More informationHow to Design Programs
How to Design Programs How to (in Racket): represent data variants trees and lists write functions that process the data See also http://www.htdp.org/ 1 Running Example: GUIs Pick a fruit: Apple Banana
More informationGraph Algorithms: Part 1. Dr. Baldassano Yu s Elite Education
Graph Algorithms: Part 1 Dr. Baldassano chrisb@princeton.edu Yu s Elite Education Last week recap: Machine Learning Unsupervised learning: cluster datapoints without labels K-means clustering Hierarchical
More informationLecture 5: Graphs. Rajat Mittal. IIT Kanpur
Lecture : Graphs Rajat Mittal IIT Kanpur Combinatorial graphs provide a natural way to model connections between different objects. They are very useful in depicting communication networks, social networks
More informationDiscrete Mathematics and Probability Theory Fall 2013 Vazirani Note 7
CS 70 Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 7 An Introduction to Graphs A few centuries ago, residents of the city of Königsberg, Prussia were interested in a certain problem.
More informationModule 8: Binary trees
Module 8: Binary trees Readings: HtDP, Section 14 We will cover the ideas in the text using different examples and different terminology. The readings are still important as an additional source of examples.
More informationEulerian Cycle (2A) Young Won Lim 4/26/18
Eulerian Cycle (2A) Copyright (c) 2015 2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any
More informationL Modelling and Simulating Social Systems with MATLAB
851-0585-04L Modelling and Simulating Social Systems with MATLAB Lesson 6 Graphs (Networks) Anders Johansson and Wenjian Yu (with S. Lozano and S. Wehrli) ETH Zürich 2010-03-29 Lesson 6 Contents History:
More informationGraph Theory. Part of Texas Counties.
Graph Theory Part of Texas Counties. We would like to visit each of the above counties, crossing each county only once, starting from Harris county. Is this possible? This problem can be modeled as a graph.
More informationIntroduction To Graphs and Networks. Fall 2013 Carola Wenk
Introduction To Graphs and Networks Fall 2013 Carola Wenk What is a Network? We have thought of a computer as a single entity, but they can also be connected to one another. Internet What are the advantages
More informationFirst Semester - Question Bank Department of Computer Science Advanced Data Structures and Algorithms...
First Semester - Question Bank Department of Computer Science Advanced Data Structures and Algorithms.... Q1) What are some of the applications for the tree data structure? Q2) There are 8, 15, 13, and
More informationCS1 Lecture 31 Apr. 3, 2019
CS Lecture 3 Apr. 3, 209 HW6 due Fri. Q3: think carefully about overlaps draw pictures Think dimension by dimension three D problems if they don t overlap in x, they don t overlap» Express this in terms
More informationComputer Science 21b (Spring Term, 2015) Structure and Interpretation of Computer Programs. Lexical addressing
Computer Science 21b (Spring Term, 2015) Structure and Interpretation of Computer Programs Lexical addressing The difference between a interpreter and a compiler is really two points on a spectrum of possible
More informationFundamentals of Graph Theory MATH Fundamentals of Graph Theory. Benjamin V.C. Collins, James A. Swenson MATH 2730
MATH 2730 Fundamentals of Graph Theory Benjamin V.C. Collins James A. Swenson The seven bridges of Königsberg Map: Merian-Erben [Public domain], via Wikimedia Commons The seven bridges of Königsberg Map:
More informationRACKET BASICS, ORDER OF EVALUATION, RECURSION 1
RACKET BASICS, ORDER OF EVALUATION, RECURSION 1 COMPUTER SCIENCE 61AS 1. What is functional programming? Give an example of a function below: Functional Programming In functional programming, you do not
More informationAlgorithms: Lecture 10. Chalmers University of Technology
Algorithms: Lecture 10 Chalmers University of Technology Today s Topics Basic Definitions Path, Cycle, Tree, Connectivity, etc. Graph Traversal Depth First Search Breadth First Search Testing Bipartatiness
More informationCopyright 2000, Kevin Wayne 1
Chapter 3 - Graphs Undirected Graphs Undirected graph. G = (V, E) V = nodes. E = edges between pairs of nodes. Captures pairwise relationship between objects. Graph size parameters: n = V, m = E. Directed
More informationLecture 26: Graphs: Traversal (Part 1)
CS8 Integrated Introduction to Computer Science Fisler, Nelson Lecture 6: Graphs: Traversal (Part ) 0:00 AM, Apr, 08 Contents Introduction. Definitions........................................... Representations.......................................
More informationUNIT Name the different ways of representing a graph? a.adjacencymatrix b. Adjacency list
UNIT-4 Graph: Terminology, Representation, Traversals Applications - spanning trees, shortest path and Transitive closure, Topological sort. Sets: Representation - Operations on sets Applications. 1. Name
More informationStreet-Routing Problems
Street-Routing Problems Lecture 26 Sections 5.1-5.2 Robb T. Koether Hampden-Sydney College Wed, Oct 25, 2017 Robb T. Koether (Hampden-Sydney College) Street-Routing Problems Wed, Oct 25, 2017 1 / 21 1
More informationCS/COE
CS/COE 151 www.cs.pitt.edu/~lipschultz/cs151/ Graphs 5 3 2 4 1 Graphs A graph G = (V, E) Where V is a set of vertices E is a set of edges connecting vertex pairs Example: V = {, 1, 2, 3, 4, 5} E = {(,
More informationNetworks: Lecture 1. General Comments
Networks: Lecture 1 Amedeo R. Odoni November 1, 200 * Thanks to Prof. R.. Larson for some of the slides General omments From continuous to a more discretized travel environment Enormous literature and
More informationThis course is intended for 3rd and/or 4th year undergraduate majors in Computer Science.
Lecture 9 Graphs This course is intended for 3rd and/or 4th year undergraduate majors in Computer Science. You need to be familiar with the design and use of basic data structures such as Lists, Stacks,
More informationBrief History. Graph Theory. What is a graph? Types of graphs Directed graph: a graph that has edges with specific directions
Brief History Graph Theory What is a graph? It all began in 1736 when Leonhard Euler gave a proof that not all seven bridges over the Pregolya River could all be walked over once and end up where you started.
More informationGraph. Vertex. edge. Directed Graph. Undirected Graph
Module : Graphs Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS E-mail: natarajan.meghanathan@jsums.edu Graph Graph is a data structure that is a collection
More informationOutline. Introduction. Representations of Graphs Graph Traversals. Applications. Definitions and Basic Terminologies
Graph Chapter 9 Outline Introduction Definitions and Basic Terminologies Representations of Graphs Graph Traversals Breadth first traversal Depth first traversal Applications Single source shortest path
More informationAlgorithms. Graphs. Algorithms
Algorithms Graphs Algorithms Graphs Definition: A graph is a collection of edges and vertices. Each edge connects two vertices. Algorithms 1 Graphs Vertices: Nodes, points, computers, users, items,...
More informationGraphs. Motivations: o Networks o Social networks o Program testing o Job Assignment Examples: o Code graph:
Graphs Motivations: o Networks o Social networks o Program testing o Job Assignment Examples: o Code graph: S1: int x S2: If x > 0 then S3: X = x + 2; Else S4: X =x -1; End if S5: While x > 1 do S6: Print
More informationTrees. Example: Binary expression trees. Example: Evolution trees. Readings: HtDP, sections 14, 15, 16.
Trees Readings: HtDP, sections 14, 15, 16. We will cover the ideas in the text using different examples and different terminology. The readings are still important as an additional source of examples.
More information8. The Postman Problems
8. The Postman Problems The Chinese postman problem (CPP) A postal carrier must pick up the mail at the post office, deliver the mail along blocks on the route, and finally return to the post office. To
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 4 Graphs Definitions Traversals Adam Smith 9/8/10 Exercise How can you simulate an array with two unbounded stacks and a small amount of memory? (Hint: think of a
More informationGraph Theory. ICT Theory Excerpt from various sources by Robert Pergl
Graph Theory ICT Theory Excerpt from various sources by Robert Pergl What can graphs model? Cost of wiring electronic components together. Shortest route between two cities. Finding the shortest distance
More informationIntroduction to Networks
LESSON 1 Introduction to Networks Exploratory Challenge 1 One classic math puzzle is the Seven Bridges of Königsberg problem which laid the foundation for networks and graph theory. In the 18th century
More informationWorking with recursion. From definition to template. Readings: HtDP, sections 11, 12, 13 (Intermezzo 2).
Working with recursion Readings: HtDP, sections 11, 12, 13 (Intermezzo 2). We can extend the idea of a self-referential definition to defining the natural numbers, which leads to the use of recursion in
More informationWorking with recursion
Working with recursion Readings: HtDP, sections 11, 12, 13 (Intermezzo 2). We can extend the idea of a self-referential definition to defining the natural numbers, which leads to the use of recursion in
More informationIntroduction to Graphs
Introduction to Graphs Historical Motivation Seven Bridges of Königsberg Königsberg (now Kaliningrad, Russia) around 1735 Problem: Find a walk through the city that would cross each bridge once and only
More informationIntroduction to Graphs. Tecniche di Programmazione A.A. 2015/2016
Introduction to Graphs Tecniche di Programmazione A.A. 2015/2016 Summary Definition: Graph Related Definitions Applications Graph representation Graph visits 2 Definition: Graph Introduction to Graphs
More informationCS 135 Winter 2018 Tutorial 8: Mutual recursion, nested lists, and local. CS 135 Winter 2018 Tutorial 8: Mutual recursion, nested lists, and local 1
CS 135 Winter 2018 Tutorial 8: Mutual recursion, nested lists, and local CS 135 Winter 2018 Tutorial 8: Mutual recursion, nested lists, and local 1 Goals of this tutorial You should be able to... write
More informationTheory of Computing. Lecture 10 MAS 714 Hartmut Klauck
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck Seven Bridges of Königsberg Can one take a walk that crosses each bridge exactly once? Seven Bridges of Königsberg Model as a graph Is there a path
More informationEulerian Cycle (2A) Young Won Lim 5/11/18
ulerian ycle (2) opyright (c) 2015 2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the NU ree ocumentation License, Version 1.2 or any later
More informationGraph Algorithms Using Depth First Search
Graph Algorithms Using Depth First Search Analysis of Algorithms Week 8, Lecture 1 Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Graph Algorithms Using Depth
More informationCrossing bridges. Crossing bridges Great Ideas in Theoretical Computer Science. Lecture 12: Graphs I: The Basics. Königsberg (Prussia)
15-251 Great Ideas in Theoretical Computer Science Lecture 12: Graphs I: The Basics February 22nd, 2018 Crossing bridges Königsberg (Prussia) Now Kaliningrad (Russia) Is there a way to walk through the
More informationEuler and Hamilton paths. Jorge A. Cobb The University of Texas at Dallas
Euler and Hamilton paths Jorge A. Cobb The University of Texas at Dallas 1 Paths and the adjacency matrix The powers of the adjacency matrix A r (with normal, not boolean multiplication) contain the number
More informationBRONX COMMUNITY COLLEGE of the City University of New York DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE. Sample Final Exam
BRONX COMMUNITY COLLEGE of the City University of New York DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE CSI33 Sample Final Exam NAME Directions: Solve problems 1 through 5 of Part I and choose 5 of the
More informationMaterial handling and Transportation in Logistics. Paolo Detti Dipartimento di Ingegneria dell Informazione e Scienze Matematiche Università di Siena
Material handling and Transportation in Logistics Paolo Detti Dipartimento di Ingegneria dell Informazione e Scienze Matematiche Università di Siena Introduction to Graph Theory Graph Theory As Mathematical
More informationAn Interactive Introduction to Graph Theory
An Interactive Introduction to Graph Theory An Interactive Introduction to Graph Theory Chris K. Caldwell 1995 This the first of a series of interactive tutorials introducing the basic concepts of graph
More informationCS490: Problem Solving in Computer Science Lecture 6: Introductory Graph Theory
CS490: Problem Solving in Computer Science Lecture 6: Introductory Graph Theory Dustin Tseng Mike Li Wednesday January 16, 2006 Dustin Tseng Mike Li: CS490: Problem Solving in Computer Science, Lecture
More informationL10 Graphs. Alice E. Fischer. April Alice E. Fischer L10 Graphs... 1/37 April / 37
L10 Graphs lice. Fischer pril 2016 lice. Fischer L10 Graphs... 1/37 pril 2016 1 / 37 Outline 1 Graphs efinition Graph pplications Graph Representations 2 Graph Implementation 3 Graph lgorithms Sorting
More informationHomework Assignment #3 Graph
CISC 4080 Computer Algorithms Spring, 2019 Homework Assignment #3 Graph Some of the problems are adapted from problems in the book Introduction to Algorithms by Cormen, Leiserson and Rivest, and some are
More informationLecture 9 Graph Traversal
Lecture 9 Graph Traversal Euiseong Seo (euiseong@skku.edu) SWE00: Principles in Programming Spring 0 Euiseong Seo (euiseong@skku.edu) Need for Graphs One of unifying themes of computer science Closely
More informationCSE 373 Final Exam 3/14/06 Sample Solution
Question 1. (6 points) A priority queue is a data structure that supports storing a set of values, each of which has an associated key. Each key-value pair is an entry in the priority queue. The basic
More informationGraph Data Processing with MapReduce
Distributed data processing on the Cloud Lecture 5 Graph Data Processing with MapReduce Satish Srirama Some material adapted from slides by Jimmy Lin, 2015 (licensed under Creation Commons Attribution
More informationHow can we lay cable at minimum cost to make every telephone reachable from every other? What is the fastest route between two given cities?
1 Introduction Graph theory is one of the most in-demand (i.e. profitable) and heavily-studied areas of applied mathematics and theoretical computer science. May graph theory questions are applied in this
More informationUnweighted Graphs & Algorithms
Unweighted Graphs & Algorithms Zachary Friggstad Programming Club Meeting References Chapter 4: Graph (Section 4.2) Chapter 22: Elementary Graph Algorithms Graphs Features: vertices/nodes/dots and edges/links/lines
More informationCSE 158. Web Mining and Recommender Systems. Midterm recap
CSE 158 Web Mining and Recommender Systems Midterm recap Midterm on Wednesday! 5:10 pm 6:10 pm Closed book but I ll provide a similar level of basic info as in the last page of previous midterms CSE 158
More informationCS/COE 1501 cs.pitt.edu/~bill/1501/ Graphs
CS/COE 1501 cs.pitt.edu/~bill/1501/ Graphs 5 3 2 4 1 0 2 Graphs A graph G = (V, E) Where V is a set of vertices E is a set of edges connecting vertex pairs Example: V = {0, 1, 2, 3, 4, 5} E = {(0, 1),
More information! Tree: set of nodes and directed edges. ! Parent: source node of directed edge. ! Child: terminal node of directed edge
Trees (& Heaps) Week 12 Gaddis: 20 Weiss: 21.1-3 CS 5301 Spring 2015 Jill Seaman 1 Tree: non-recursive definition! Tree: set of nodes and directed edges - root: one node is distinguished as the root -
More informationInstruction Selection. Problems. DAG Tiling. Pentium ISA. Example Tiling CS412/CS413. Introduction to Compilers Tim Teitelbaum
Instruction Selection CS42/CS43 Introduction to Compilers Tim Teitelbaum Lecture 32: More Instruction Selection 20 Apr 05. Translate low-level IR code into DAG representation 2. Then find a good tiling
More informationCS115 - Module 10 - General Trees
Fall 2017 Reminder: if you have not already, ensure you: Read How to Design Programs, Sections 15 and 16. Arithmetic Expressions Recall with binary trees we could represent an expression containing binary
More informationAnnouncements. The current topic: Scheme. Review: BST functions. Review: Representing trees in Scheme. Reminder: Lab 2 is due on Monday at 10:30 am.
The current topic: Scheme! Introduction! Object-oriented programming: Python Functional programming: Scheme! Introduction! Numeric operators, REPL, quotes, functions, conditionals! Function examples, helper
More informationYOUR NAME PLEASE: *** SOLUTIONS ***
YOUR NAME PLEASE: *** SOLUTIONS *** Computer Science 201b SAMPLE Exam 1 SOLUTIONS February 15, 2015 Closed book and closed notes. No electronic devices. Show ALL work you want graded on the test itself.
More informationGraph definitions. There are two kinds of graphs: directed graphs (sometimes called digraphs) and undirected graphs. An undirected graph
Graphs Graph definitions There are two kinds of graphs: directed graphs (sometimes called digraphs) and undirected graphs start Birmingham 60 Rugby fill pan with water add salt to water take egg from fridge
More informationGraphs. CS16: Introduction to Data Structures & Algorithms Spring 2018
Graphs CS16: Introduction to Data Structures & Algorithms Spring 2018 Outline What is a Graph Terminology Properties Graph Types Representations Performance BFS/DFS Applications 2 What is a Graph A graph
More informationCS 61B, Spring 1999 MT3 Professor M. Clancy
CS 61B, Spring 1999 MT3 Professor M. Clancy Problem #1 One approach to producing debugging output is to use inheritance to create objects that print any changes to themselves. For instance, instead of
More informationVarying Applications (examples)
Graph Theory Varying Applications (examples) Computer networks Distinguish between two chemical compounds with the same molecular formula but different structures Solve shortest path problems between cities
More informationMa/CS 6a Class 8: Eulerian Cycles
Ma/CS 6a Class 8: Eulerian Cycles By Adam Sheffer The Bridges of Königsberg Can we travel the city while crossing every bridge exactly once? 1 How Graph Theory was Born Leonhard Euler 1736 Eulerian Cycle
More informationLists of Lists. CS 5010 Program Design Paradigms Bootcamp Lesson 5.3
Lists of Lists CS 5010 Program Design Paradigms Bootcamp Lesson 5.3 Mitchell Wand, 2012-2017 This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. 1 Learning
More informationCS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 19: Efficient IL Lowering 5 March 08
CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 19: Efficient IL Lowering 5 March 08 CS 412/413 Spring 2008 Introduction to Compilers 1 IR Lowering Use temporary variables for the translation
More information