4.5 Small World Phenomenon

Size: px
Start display at page:

Download "4.5 Small World Phenomenon"

Transcription

1 Small World Phenomenon.5 Small World Phenomenon Small world phenomenon. Six handshakes away from anyone. n experiment to quantify effect. [Stanley Milgram, 960s]! You are given personal info of another person.! oal: deliver message. e.g., occupation and age! Restriction: can only forward to someone you know by first name.! Outcome: message delivered with average of 5 intermediaries. Stanley Milgram Kevin acon ntroduction to omputer Science Sedgewick and Wayne opyright pplications of Small World Phenomenon raph ata Type Sociology applications.! Looking for a job.! Marketing products or ideas.! ormation and spread of fame and fads.! Train of thought followed in a conversation.! efining representative-ness of political bodies.! Kevin acon game (movies, rock groups, facebook, etc.). pplication demands a new data type.! raph = data type that represents pairwise connections.! Vertex = element.! dge = connection between two vertices. Other applications.! lectronic circuits.! Synchronization of neurons. Reference. uncan J. Watts, Small Worlds: The ynamics of Networks between Order and Randomness, Princeton University Press, 999. vertex! nalysis of World Wide Web.! esign of electrical power grids.! Modeling of protein interaction networks. edge! Phase transitions in coupled Kuramoto oscillators.! Spread of infectious diseases and computer viruses.! volution of cooperation in multi-player iterated Prisoner's ilemma. 3

2 raph pplications nternet Movie atabase graph vertices edges nput format. Movie followed by list of performers, separated by slashes. communication telephones, computers fiber optic cables circuits gates, registers, processors wires mechanical joints rods, beams, springs hydraulic reservoirs, pumping stations pipelines financial stocks, currency transactions transportation street intersections, airports highways, airway routes scheduling tasks precedence constraints software systems functions function calls internet web pages hyperlinks games board positions legal moves social relationship people, actors friendships, movie casts neural networks neurons synapses % more movies.txt... Tin Men (987)/eoy, avid/lumenfeld, lan/... /eppi, indy/ershey, arbara Tirez sur le pianiste (960)/eymann, laude/.../erger, Nicole () Titanic (997)Paxton, ill/iaprio, Leonardo/.../Winslet, Kate Titus (999)/Weisskopf, ermann/rhys, Matthew/.../Mcwan, eraldine To ll a ood Night (980)/eorge, Michael ()/.../entile, Linda To e or Not to e (9)/Verebes, rnö ()/.../Lombard, arole () To e or Not to e (983)/rooks, Mel ()/.../ancroft, nne To atch a Thief (955)/París, Manuel/rant, ary/.../kelly, race To ie or (989)/ond, Steve ()/Jones, uane ()/.../Maddalena, Julie To ie or (995)/Smith, Kurtwood/Kidman, Nicole/.../Tucci, Maria To ie Standing (990)/Sacha, Orlando/nthony, erald/.../rose, Jamie To nd ll Wars (00)/Kimura, Sakae/llis, reg ()/.../Sutherland, Kiefer To Kill a lown (97)/lda, lan/lavering, ric/lamberts, eath/anner, lythe To Live and ie in L.. (985)/Mcroarty, Pat/Williams, onnie/.../afoe, Willem... protein networks proteins protein-protein interactions chemical compounds molecules bonds 5 nternet Movie atabase raph P Q. ow to represent the movie-performer relationships?. Use a graph.! Vertex: performer or movie.! dge: connect performer to movie. raph data type. % more tiny.txt // // /// / // /// /// // 3

3 raph Representation Set ata Type raph representation: use a symbol table.! Key = name of vertex (e.g., performer or movie).! Value = set of neighbors. Set data type. Unordered collection of distinct keys. Symbol Table Key Value Q. ow to implement?. dentical to symbol table, but ignore values. String ST 5 raph mplementation raph mplementation (continued) public class raph { private ST<String, ST<String>> st; public raph() { st = new ST<String, ST<String>>(); public void adddge(string v, String w) { if (!st.contains(v)) addvertex(v); if (!st.contains(w)) addvertex(w); st.get(v).add(w); add w to v's set of neighbors st.get(w).add(v); add v to w's set of neighbors Second constructor. To read graph from input stream. public raph(n in) { st = new ST<String, ST<String>>(); while (!in.ismpty()) { String line = in.readline(); String[] names = line.split("/"); for (int i = ; i < names.length; i++) adddge(names[0], names[i]); private void addvertex(string v) { st.put(v, new ST<String>()); add new vertex v with no neighbors public terable<string> adjacentto(string v) { return st.get(v); n in = new n("tiny.txt"); raph = new raph(); % more tiny.txt // // /// / // /// /// // 6 7

4 raph lient Warmup: Movie inder raph lient Warmup: Movie inder Performer and movie queries.! iven a performer, find all movies in which they appeared.! iven a movie, find all performers. public class Movieinder { public static void main(string[] args) { n in = new n(args[0]); raph = new raph(in); while (!Stdn.ismpty()) { String v = Stdn.readLine(); for (String w :.adjacentto(v)) StdOut.println(v); read in graph from a file process queries % java Movieinder action.txt acon, Kevin eath Sentence (007) River Wild, The (99) Tremors (990) Roberts, Julia lood Red (989) Love Trouble (99) Mexican, The (00) Ocean's leven (00) Tilghman, Shirley % java Movieinder mpaa.txt acon, Kevin ir reathe, The (007) ir Up There, The (99) nimal ouse (978) pollo 3 (995) alto (995) eauty Shop (005) ig Picture, The (989) Sleepers (996) Starting Over (979) Stir of choes (999) Telling Lies in merica (997) Trapped (00) Tremors (990) We Married Margo (000) Where the Truth Lies (005) White Water Summer (987) Wild Things (998) Woodsman, The (00) 8 9 Kevin acon ame Kevin acon Numbers ame. iven a performer, find (shortest) chain of movies connecting them to Kevin acon. Performer Kevin Kline Meg Ryan Tom anks Kevin acon Was in rench Kiss Sleepless in Seattle pollo 3 With Meg Ryan Tom anks Kevin acon 0

5 omputing acon Numbers Path inder P ow to compute. ind shortest path in performer-movie graph. Path finder P. public class Pathinder (data type to compute shortest paths) int void Pathinder(raph, String s) distanceto(string v) showpath(string v) process graph with source s return shorest distance between s and v print shortest path between s and v esign principles.! ecouple graph algorithm from graph data type.! void feature creep. 3 omputing acon Numbers: Java mplementation omputing Shortest Paths public class acon { public static void main(string[] args) { n in = new n(args[0]); raph = new raph(in); String s = "acon, Kevin"; Pathinder finder = new Pathinder(, s); while (!Stdn.ismpty()) { String actor = Stdn.readLine(); finder.showpathrom(actor); % java acon top-grossing.txt Stallone, Sylvester Rocky (98) Tamburro, harles. Terminator : Judgment ay (99) erkeley, Xander pollo 3 (995) acon, Kevin read in the graph from a file create object to return shortest paths process queries % java acon top-grossing.txt oldberg, Whoopi Sister ct (99) rodénchik, Max pollo 3 (995) acon, Kevin Tilghman, Shirley To compute shortest paths:! Source vertex is at distance 0.! ts neighbors are at distance.! Their remaining neighbors are at distance.! Their remaining neighbors are at distance 3.! 0 3 5

6 readth irst Search readth irst Searcher: Preprocessing oal. iven a vertex s, find shortest path to every other vertex v. S from source vertex s Put s onto a O queue. Repeat until the queue is empty:! dequeue the least recently added vertex v! add each of v's unvisited neighbors to the queue, and mark them as visited. Key observation. Vertices are visited in increasing order of distance from s because we use a O queue. public class Pathinder { private ST<String, String> prev = new ST<String, String>(); private ST<String, nteger> dist = new ST<String, nteger>(); public Pathinder(raph, String s) { Queue<String> q = new Queue<String>(); q.enqueue(s); dist.put(s, 0); while (!q.ismpty()) { String v = q.dequeue(); for (String w :.adjacentto(v)) { if (!dist.contains(w)) { q.enqueue(w); dist.put(w, + dist.get(v)); prev.put(w, v); 6 7 readth irst Searcher: Printing the Path Running Time nalysis To print shortest path: follow prev[] from vertex v back to source s.! Print v, prev[v], prev[prev[v]],, s. nalysis. S scales to solve huge problems.! x: shortest path from to : data ile movies performers edges read input build graph S show null key prev dist.txt,88,77 8K 0.6 sec 0.5 sec 0.3 sec source P3.txt action.txt mpaa.txt,538,938,86 70,35 39,86 80,6 00K 70K 60K 0.3 sec 0.7 sec. sec 0.99 sec.8 sec 7.5 sec 0.7 sec. 5.5 sec all.txt 85,6 933,86 3.3M 5 sec 56 sec 39 sec 3 60M data as of pril 9, 007 public void showpath(string v) { while (prev.contains(v)) { StdOut.println(v); v = prev.get(v); symbol tables 8 9

7 ata nalysis pplications of readth irst Search xercise. ompute histogram of Kevin acon numbers. nput. 85,6 movies, 933,86 actors. acon # 0 requency,9 More S applications.! Particle tracking.! mage processing.! rawling the Web.! Routing nternet packets.!... 8,088 uzz Mauro, Jessica rizd, Pablo apussi rgentine short film Sweet reams (005) ,6,9 7,905 xtensions. oogle maps red Ott, solo actor in red Ott olding a ird (89) 8! 3,9 data as of pril 9, onclusions Linked list. Ordering of elements. inary tree. ierarchical structure of elements. raph. Pairwise connections between elements. ata structures.! Queue: linked list.! Set: binary tree.! Symbol table: binary tree.! raph: symbol table of sets.! readth first searcher: graph + queue + symbol table. mportance of data structures.! nables us to build and debug large programs.! nables us to solve large problems efficiently. 3

4.5 Small World Phenomenon

4.5 Small World Phenomenon Small World Phenomenon 4.5 Small World Phenomenon Small world phenomenon. Six handshakes away from anyone. n experiment to quantify effect. [Stanley Milgram, 960s] You are given personal info of another

More information

4.5 Small World Phenomenon

4.5 Small World Phenomenon Small World Phenomenon.5 Small World Phenomenon Small world phenomenon. Six handshakes away from anyone. n experiment to quantify effect. [Stanley Milgram, 960s] You are given personal info of another

More information

3/18/12. CS 112 Introduction to Programming. Lecture #29: Small World Phenomenon. Small World Phenomenon. (Spring 2012) Zhong Shao

3/18/12. CS 112 Introduction to Programming. Lecture #29: Small World Phenomenon. Small World Phenomenon. (Spring 2012) Zhong Shao 3/8/2 Small World Phenomenon S 2 ntroduction to Programming Small world phenomenon. Six handshakes away from anyone. (Spring 202) n experiment to quantify effect. [Stanley Milgram, 960s] You are given

More information

4.5 Small World Phenomenon

4.5 Small World Phenomenon 4.5 Small World Phenomenon Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2010 6/26/10 8:10 AM Small World Phenomenon Small world phenomenon.

More information

Lecture 17: Small World Phenomenon

Lecture 17: Small World Phenomenon Small World Phenomenon Lecture 7: Small World Phenomenon Small world phenomenon.! Six handshakes away from anyone else in the world.! Long a matter of folklore.! "It's a small world after all." Stanley

More information

4.5 Small World Phenomenon

4.5 Small World Phenomenon 4.5 Small World Phenomenon Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2010 04/05/12 10:08:45 PM Small World Phenomenon Small world

More information

4.5 Small World Phenomenon

4.5 Small World Phenomenon 4.5 Small World Phenomenon Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2010 04/05/12 10:08:45 PM Small World Phenomenon Small world

More information

Graph Data Type. Graph = data type that represents pairwise connections. Vertex = element. Edge = connection between two vertices. vertex.

Graph Data Type. Graph = data type that represents pairwise connections. Vertex = element. Edge = connection between two vertices. vertex. Networks Graph Data Type Graph = data type that represents pairwise connections. Vertex = element. Edge = connection between two vertices. vertex A B C D edge E F G H I 2 Graph API Graph data type. to

More information

CS 112 Introduction to Programming

CS 112 Introduction to Programming CS 112 Introduction to Programming (Spring 2012) Lecture #29: Small World Phenomenon Zhong Shao Department of Computer Science Yale University Office: 314 Watson http://flint.cs.yale.edu/cs112 Acknowledgements:

More information

UNDIRECTED GRAPHS BBM 201 DATA STRUCTURES DEPT. OF COMPUTER ENGINEERING

UNDIRECTED GRAPHS BBM 201 DATA STRUCTURES DEPT. OF COMPUTER ENGINEERING Acknowledgement: he course slides are adapted from the slides prepared by R. Sedgewick and K. Wayne of Princeton Uniersity. BBM DAA SRUCURES DEP. O COMPUER ENGINEERING UNDIRECED GRAPHS Undirected Graphs

More information

! Interesting and broadly useful abstraction. ! Challenging branch of computer science and discrete math. ! Hundreds of graph algorithms known.

! Interesting and broadly useful abstraction. ! Challenging branch of computer science and discrete math. ! Hundreds of graph algorithms known. Undirected Graphs Undirected Graphs Graph. Set of objects with pairwise connections. Why study graph algorithms?! Interesting and broadly useful abstraction.! Challenging branch of computer science and

More information

Graph Algorithms. Parallel and Distributed Computing. Department of Computer Science and Engineering (DEI) Instituto Superior Técnico.

Graph Algorithms. Parallel and Distributed Computing. Department of Computer Science and Engineering (DEI) Instituto Superior Técnico. Graph Algorithms Parallel and Distributed Computing Department of Computer Science and Engineering (DEI) Instituto Superior Técnico May, 0 CPD (DEI / IST) Parallel and Distributed Computing 0-0-0 / Outline

More information

! Vertex = species. ! Edge = from prey to predator.

! Vertex = species. ! Edge = from prey to predator. irected Graphs irected Graphs igraph. Set of objects with oriented pairwise connections. x. One-way street, hyperlink. Reference: Chapter 19, Algorithms in Java, 3 rd dition, Robert Sedgewick. Robert Sedgewick

More information

Undirected Graphs. graph API maze exploration depth-first search breadth-first search connected components challenges.

Undirected Graphs. graph API maze exploration depth-first search breadth-first search connected components challenges. Undirected graphs Graph. Set of vertices connected pairwise by edges. Undirected Graphs References: Algorithms in Java, Chapters and Why study graph algorithms? Interesting and broadly useful abstraction.

More information

Directed Graphs. digraph API digraph search transitive closure topological sort strong components. Directed graphs

Directed Graphs. digraph API digraph search transitive closure topological sort strong components. Directed graphs irected graphs igraph. Set of vertices connected pairwise by oriented edges. irected raphs digraph AP digraph search transitive closure topological sort strong components References: Algorithms in Java,

More information

UNDIRECTED GRAPHS BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING

UNDIRECTED GRAPHS BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING BBM - ALGORIHMS DEP. O COMPUER ENGINEERING UNDIRECED GRAPHS Acknowledgement: he course slides are adapted from the slides prepared by R. Sedgewick and K. Wayne of Princeton Uniersity. Undirected Graphs

More information

CS 4407 Algorithms Lecture 5: Graphs an Introduction

CS 4407 Algorithms Lecture 5: Graphs an Introduction CS 4407 Algorithms Lecture 5: Graphs an Introduction Prof. Gregory Provan Department of Computer Science University College Cork 1 Outline Motivation Importance of graphs for algorithm design applications

More information

Undirected Graphs. introduction Graph API maze exploration depth-first search breadth-first search connected components challenges.

Undirected Graphs. introduction Graph API maze exploration depth-first search breadth-first search connected components challenges. Undirected Graphs Graph. Set of vertices connected pairwise by edges. Undirected Graphs Why study graph algorithms? Interesting and broadly useful abstraction. Challenging branch of computer science and

More information

3. GRAPHS. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Copyright 2013 Kevin Wayne. Last updated on Sep 8, :19 AM

3. GRAPHS. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Copyright 2013 Kevin Wayne. Last updated on Sep 8, :19 AM 3. GRAPHS basic definitions and applications graph connectivity and graph traversal testing bipartiteness connectivity in directed graphs DAGs and topological ordering Lecture slides by Kevin Wayne Copyright

More information

UNDIRECTED GRAPHS TODAY BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING. Undirected graphs. Graph applications

UNDIRECTED GRAPHS TODAY BBM ALGORITHMS DEPT. OF COMPUTER ENGINEERING. Undirected graphs. Graph applications BBM - ALGORIHMS ODAY DEP. O COMPUER ENGINEERING UNDIRECED GRAPHS Undirected Graphs Graph API Depth-first search Challenges Acknowledgement: he course slides are adapted from the slides prepared by R. Sedgewick

More information

COP 4531 Complexity & Analysis of Data Structures & Algorithms

COP 4531 Complexity & Analysis of Data Structures & Algorithms COP Complexity & Analysis of Data Structures & Algorithms Overview of Graphs Breadth irst Search, and Depth irst Search hanks to several people who contributed to these slides including Piyush Kumar and

More information

DIRECTED GRAPHS BBM 201 DATA STRUCTURES DEPT. OF COMPUTER ENGINEERING

DIRECTED GRAPHS BBM 201 DATA STRUCTURES DEPT. OF COMPUTER ENGINEERING Acknowledgement: he course slides are adapted from the slides prepared by R. Sedgewick and K. Wayne of Princeton University. BBM DAA SRUCURES DEP. O COMPUER ENGINEERING DIRECED GRAPHS Directed Graphs Digraph

More information

Background: This programming assignment focuses on implementation and usage of a graph data structure.

Background: This programming assignment focuses on implementation and usage of a graph data structure. CSE 373, Spring 2012 Homework #7: Six Degrees of Kevin Bacon (75 points) Step 0: Due Wednesday, May 23, 2012, 2:30 PM Steps 1 and 2: Due Wednesday, May 30, 2012, 2:30 PM This programming assignment focuses

More information

Graph Algorithms. Andreas Klappenecker

Graph Algorithms. Andreas Klappenecker Graph Algorithms Andreas Klappenecker Graphs A graph is a set of vertices that are pairwise connected by edges. We distinguish between directed and undirected graphs. Why are we interested in graphs? Graphs

More information

Background: This programming assignment focuses on implementation and usage of a graph data structure.

Background: This programming assignment focuses on implementation and usage of a graph data structure. CSE 373, Winter 2011 Programming Project #4: Six Degrees of Kevin Bacon (75 points) Step 0: Due Sunday, March 6, 2011, 10:00 PM Steps 1 and 2: Due Sunday, March 13, 2011, 10:00 PM This programming assignment

More information

Basic Graph Search. Algorithms and Data Structures, Fall Rasmus Pagh. Based on slides by Kevin Wayne, Princeton

Basic Graph Search. Algorithms and Data Structures, Fall Rasmus Pagh. Based on slides by Kevin Wayne, Princeton Algorithms and Data Structures, Fall Basic Graph Search Rasmus Pagh Based on slides by Kevin Wayne, Princeton Algorithms, th Edition Robert Sedgewick and Kevin Wayne Copyright Mid-term evaluation Thanks

More information

An Early Problem in Graph Theory. Clicker Question 1. Konigsberg and the River Pregel

An Early Problem in Graph Theory. Clicker Question 1. Konigsberg and the River Pregel raphs Topic " Hopefully, you've played around a bit with The Oracle of acon at Virginia and discovered how few steps are necessary to link just about anybody who has ever been in a movie to Kevin acon,

More information

An Early Problem in Graph Theory

An Early Problem in Graph Theory raphs Topic 2 " Hopefully, you've played around a bit with The Oracle of acon at Virginia and discovered how few steps are necessary to link just about anybody who has ever been in a movie to Kevin acon,

More information

Directed Graphs. digraph API digraph search transitive closure topological sort strong components. Directed graphs

Directed Graphs. digraph API digraph search transitive closure topological sort strong components. Directed graphs Directed graphs Digraph. Set of vertices connected pairwise by oriented edges. Directed Graphs digraph API digraph search transitive closure topological sort strong components References: Algorithms in

More information

Copyright 2010 North Carolina State University: MINDSET 9-1

Copyright 2010 North Carolina State University: MINDSET 9-1 In this chapter, we present two mathematical techniques that use networks. irst, a technique is used to find paths between houses after a tornado destroyed the road network. These paths are important for

More information

3.1 Basic Definitions and Applications

3.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 information

Data Organization: Creating Order Out Of Chaos

Data Organization: Creating Order Out Of Chaos ata Organization: reating Order Out Of haos 3 Non-linear data structures 5-5 Principles of omputation, arnegie Mellon University - ORTIN Trees tree is a hierarchical (usually non-linear) data structure.

More information

CMSC 132: Object-Oriented Programming II

CMSC 132: Object-Oriented Programming II CMSC 132: Object-Oriented Programming II DIRECTED GRAPHS Graphs slides are modified from COS 126 slides of Dr. Robert Sedgewick. 1 Directed graphs Digraph Set of vertices connected pairwise by directed

More information

Data Structures Lecture 14

Data Structures Lecture 14 Fall 2018 Fang Yu Software Security Lab. ept. Management Information Systems, National hengchi University ata Structures Lecture 14 Graphs efinition, Implementation and Traversal Graphs Formally speaking,

More information

Introduction to Graphs. common/notes/ppt/

Introduction to Graphs.   common/notes/ppt/ Introduction to Graphs http://people.cs.clemson.edu/~pargas/courses/cs212/ common/notes/ppt/ Introduction Graphs are a generalization of trees Nodes or verticies Edges or arcs Two kinds of graphs irected

More information

CMPS 240 Data Structures and Algorithms Test #2 Fall 2017 November 15

CMPS 240 Data Structures and Algorithms Test #2 Fall 2017 November 15 CMPS 240 Data Structures and Algorithms Test #2 Fall 2017 November 15 Name The test has six problems. You ll be graded on your best four answers. 1. Suppose that we wanted to modify the Java class NodeOutDeg1

More information

Algorithms ROBERT SEDGEWICK KEVIN WAYNE 3.1 SYMBOL TABLES Algorithms F O U R T H E D I T I O N API elementary implementations ordered operations ROBERT SEDGEWICK KEVIN WAYNE http://algs4.cs.princeton.edu

More information

ECE 242 Data Structures and Algorithms. Graphs II. Lecture 27. Prof.

ECE 242 Data Structures and Algorithms.  Graphs II. Lecture 27. Prof. 242 ata Structures and lgorithms http://www.ecs.umass.edu/~polizzi/teaching/242/ Graphs II Lecture 27 Prof. ric Polizzi Summary Previous Lecture omposed of vertices (nodes) and edges vertex or node edges

More information

Algorithms. Algorithms 3.1 SYMBOL TABLES. API elementary implementations ordered operations ROBERT SEDGEWICK KEVIN WAYNE

Algorithms. Algorithms 3.1 SYMBOL TABLES. API elementary implementations ordered operations ROBERT SEDGEWICK KEVIN WAYNE Algorithms ROBERT SEDGEWICK KEVIN WAYNE 3.1 SYMBOL TABLES Algorithms F O U R T H E D I T I O N API elementary implementations ordered operations ROBERT SEDGEWICK KEVIN WAYNE https://algs4.cs.princeton.edu

More information

State Transition Graph of 8-Puzzle E W W E W W 3 2 E

State Transition Graph of 8-Puzzle E W W E W W 3 2 E rrays. Lists. inary search trees. ash tables. tacks. Queues. tate Transition raph of 8-Puzzle oal: Understand data structures by solving the puzzle problem lementary tructures 4 7 5 6 8 4 6 5 7 8. Trees

More information

Chapter 3. Graphs CLRS Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 3. Graphs CLRS Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 3 Graphs CLRS 12-13 Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 3.1 Basic Definitions and Applications Undirected Graphs Undirected graph. G = (V, E) V

More information

Analysis of Algorithms Prof. Karen Daniels

Analysis 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 information

DFS on Directed Graphs BOS. Outline and Reading ( 6.4) Digraphs. Reachability ( 6.4.1) Directed Acyclic Graphs (DAG s) ( 6.4.4)

DFS on Directed Graphs BOS. Outline and Reading ( 6.4) Digraphs. Reachability ( 6.4.1) Directed Acyclic Graphs (DAG s) ( 6.4.4) S on irected Graphs OS OR JK SO LX W MI irected Graphs S 1.3 1 Outline and Reading ( 6.4) Reachability ( 6.4.1) irected S Strong connectivity irected cyclic Graphs (G s) ( 6.4.4) Topological Sorting irected

More information

Reading. Graph Introduction. What are graphs? Graphs. Motivation for Graphs. Varieties. Reading. CSE 373 Data Structures Lecture 18

Reading. Graph Introduction. What are graphs? Graphs. Motivation for Graphs. Varieties. Reading. CSE 373 Data Structures Lecture 18 Reading Graph Introduction Reading Section 9.1 S 373 ata Structures Lecture 18 11/25/02 Graph Introduction - Lecture 18 2 What are graphs? Yes, this is a graph. Graphs Graphs are composed of Nodes (vertices)

More information

CS1800: Graph Algorithms (2nd Part) Professor Kevin Gold

CS1800: Graph Algorithms (2nd Part) Professor Kevin Gold S1800: raph lgorithms (2nd Part) Professor Kevin old Summary So ar readth-irst Search (S) and epth-irst Search (S) are two efficient algorithms for finding paths on graphs. S also finds the shortest path.

More information

Introduction To Graphs and Networks. Fall 2013 Carola Wenk

Introduction To Graphs and Networks. Fall 2013 Carola Wenk Introduction To Graphs and Networks Fall 203 Carola Wenk On the Internet, links are essentially weighted by factors such as transit time, or cost. The goal is to find the shortest path from one node to

More information

Chapter 3. Graphs. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 3. Graphs. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 3 Graphs Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 3.1 Basic Definitions and Applications Undirected Graphs Undirected graph. G = (V, E) V = nodes. E

More information

Basic Network Concepts

Basic Network Concepts Basic Network Concepts Basic Vocabulary Alice Graph Network Edges Links Nodes Vertices Chuck Bob Edges Alice Chuck Bob Edge Weights Alice Chuck Bob Apollo 13 Movie Network Main Actors in Apollo 13 the

More information

Minimum Spanning Trees and Shortest Paths

Minimum Spanning Trees and Shortest Paths Minimum Spanning Trees and Shortest Paths Kruskal's lgorithm Prim's lgorithm Shortest Paths pril 04, 018 inda eeren / eoffrey Tien 1 Kruskal's algorithm ata types for implementation Kruskalslgorithm()

More information

3.1 Symbol Tables. API sequential search binary search ordered operations

3.1 Symbol Tables. API sequential search binary search ordered operations 3.1 Symbol Tables API sequential search binary search ordered operations Algorithms in Java, 4 th Edition Robert Sedgewick and Kevin Wayne Copyright 2009 February 23, 2010 8:21:03 AM Symbol tables Key-value

More information

ECS 253 / MAE 253, Lecture 8 April 21, Web search and decentralized search on small-world networks

ECS 253 / MAE 253, Lecture 8 April 21, Web search and decentralized search on small-world networks ECS 253 / MAE 253, Lecture 8 April 21, 2016 Web search and decentralized search on small-world networks Search for information Assume some resource of interest is stored at the vertices of a network: Web

More information

Mystery Algorithm! ALGORITHM MYSTERY( G = (V,E), start_v ) mark all vertices in V as unvisited mystery( start_v )

Mystery Algorithm! ALGORITHM MYSTERY( G = (V,E), start_v ) mark all vertices in V as unvisited mystery( start_v ) Mystery Algorithm! 0 2 ALGORITHM MYSTERY( G = (V,E), start_v ) mark all vertices in V as unvisited mystery( start_v ) 3 1 4 7 6 5 mystery( v ) mark vertex v as visited PRINT v for each vertex w adjacent

More information

Example 1: An algorithmic view of the small world phenomenon

Example 1: An algorithmic view of the small world phenomenon Lecture Notes: Social Networks: Models, Algorithms, and Applications Lecture 1: Jan 17, 2012 Scribes: Preethi Ambati and Azar Aliyev Example 1: An algorithmic view of the small world phenomenon The story

More information

Biological Networks Analysis Dijkstra s algorithm and Degree Distribution

Biological Networks Analysis Dijkstra s algorithm and Degree Distribution iological Networks nalysis ijkstra s algorithm and egree istribution Genome 373 Genomic Informatics Elhanan orenstein Networks: Networks vs. graphs The Seven ridges of Königsberg collection of nodes and

More information

Copyright 2000, Kevin Wayne 1

Copyright 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 information

3.1 Basic Definitions and Applications. Chapter 3. Graphs. Undirected Graphs. Some Graph Applications

3.1 Basic Definitions and Applications. Chapter 3. Graphs. Undirected Graphs. Some Graph Applications Chapter 3 31 Basic Definitions and Applications Graphs Slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley All rights reserved 1 Undirected Graphs Some Graph Applications Undirected graph G = (V,

More information

Graphs and Graph Algorithms. Slides by Larry Ruzzo

Graphs and Graph Algorithms. Slides by Larry Ruzzo Graphs and Graph Algorithms Slides by Larry Ruzzo Goals Graphs: defns, examples, utility, terminology Representation: input, internal Traversal: Breadth- & Depth-first search Three Algorithms: Connected

More information

CMSC 132, Object-Oriented Programming II Summer Lecture 9:

CMSC 132, Object-Oriented Programming II Summer Lecture 9: CMSC 132, Object-Oriented Programming II Summer 2018 Lecturer: Anwar Mamat Lecture 9: Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 9.1 QUEUE

More information

Algorithms. Algorithms GEOMETRIC APPLICATIONS OF BSTS. 1d range search line segment intersection kd trees interval search trees rectangle intersection

Algorithms. Algorithms GEOMETRIC APPLICATIONS OF BSTS. 1d range search line segment intersection kd trees interval search trees rectangle intersection Algorithms ROBERT SEDGEWICK KEVIN WAYNE GEOMETRIC APPLICATIONS OF BSTS Algorithms F O U R T H E D I T I O N ROBERT SEDGEWICK KEVIN WAYNE 1d range search line segment intersection kd trees interval search

More information

Graph ADT. Lecture18: Graph II. Adjacency Matrix. Representation of Graphs. Data Vertices and edges. Methods

Graph ADT. Lecture18: Graph II. Adjacency Matrix. Representation of Graphs. Data Vertices and edges. Methods Graph T S33: ata Structures (0) Lecture8: Graph II ohyung Han S, POSTH bhhan@postech.ac.kr ata Vertices and edges endvertices(e): an array of the two endvertices of e opposite(v,e): the vertex opposite

More information

THE KNOWLEDGE MANAGEMENT STRATEGY IN ORGANIZATIONS. Summer semester, 2016/2017

THE KNOWLEDGE MANAGEMENT STRATEGY IN ORGANIZATIONS. Summer semester, 2016/2017 THE KNOWLEDGE MANAGEMENT STRATEGY IN ORGANIZATIONS Summer semester, 2016/2017 SOCIAL NETWORK ANALYSIS: THEORY AND APPLICATIONS 1. A FEW THINGS ABOUT NETWORKS NETWORKS IN THE REAL WORLD There are four categories

More information

What is Search? Intro to Search. Search problems. Finding goals in trees. Why is goal search not trivial? Blind Search Methods

What is Search? Intro to Search. Search problems. Finding goals in trees. Why is goal search not trivial? Blind Search Methods What is Search? lind Search Methods Search as an Tool S, DS, DS, US, ids Search is one of the most powerful approaches to problem solving in Search is a universal problem solving mechanism that Systematically

More information

M.E.J. Newman: Models of the Small World

M.E.J. Newman: Models of the Small World A Review Adaptive Informatics Research Centre Helsinki University of Technology November 7, 2007 Vocabulary N number of nodes of the graph l average distance between nodes D diameter of the graph d is

More information

Biological Networks Analysis

Biological Networks Analysis iological Networks nalysis Introduction and ijkstra s algorithm Genome 559: Introduction to Statistical and omputational Genomics Elhanan orenstein The clustering problem: partition genes into distinct

More information

Algorithms. Algorithms GEOMETRIC APPLICATIONS OF BSTS. 1d range search line segment intersection kd trees interval search trees rectangle intersection

Algorithms. Algorithms GEOMETRIC APPLICATIONS OF BSTS. 1d range search line segment intersection kd trees interval search trees rectangle intersection Algorithms ROBERT SEDGEWICK KEVIN WAYNE GEOMETRIC APPLICATIONS OF BSTS Algorithms F O U R T H E D I T I O N ROBERT SEDGEWICK KEVIN WAYNE 1d range search line segment intersection kd trees interval search

More information

Graphs. Data Structures and Algorithms CSE 373 SU 18 BEN JONES 1

Graphs. 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 information

CS 3410 Ch 14 Graphs and Paths

CS 3410 Ch 14 Graphs and Paths CS 3410 Ch 14 Graphs and Paths Sections 14.1-14.3 Pages 527-552 Exercises 1,2,5,7-9 14.1 Definitions 1. A vertex (node) and an edge are the basic building blocks of a graph. Two vertices, (, ) may be connected

More information

Algorithms. Algorithms GEOMETRIC APPLICATIONS OF BSTS. 1d range search line segment intersection kd trees interval search trees rectangle intersection

Algorithms. Algorithms GEOMETRIC APPLICATIONS OF BSTS. 1d range search line segment intersection kd trees interval search trees rectangle intersection Algorithms ROBERT SEDGEWICK KEVIN WAYNE GEOMETRIC APPLICATIONS OF BSTS Algorithms F O U R T H E D I T I O N ROBERT SEDGEWICK KEVIN WAYNE 1d range search line segment intersection kd trees interval search

More information

Algorithms. Algorithms 4.4 SHORTEST PATHS. APIs properties Bellman Ford algorithm Dijkstra s algorithm ROBERT SEDGEWICK KEVIN WAYNE

Algorithms. Algorithms 4.4 SHORTEST PATHS. APIs properties Bellman Ford algorithm Dijkstra s algorithm ROBERT SEDGEWICK KEVIN WAYNE Algorithms ROBERT SEDGEWICK KEVIN WAYNE 4.4 SHORTEST PATHS Algorithms F O U R T H E D I T I O N APIs properties Bellman Ford algorithm Dijkstra s algorithm ROBERT SEDGEWICK KEVIN WAYNE https://algs4.cs.princeton.edu

More information

Biological Networks Analysis

Biological Networks Analysis Biological Networks Analysis Introduction and Dijkstra s algorithm Genome 559: Introduction to Statistical and Computational Genomics Elhanan Borenstein The clustering problem: partition genes into distinct

More information

1/19/2010. Usually for static, deterministic environment

1/19/2010. Usually for static, deterministic environment To download the discussion slides, go to http://april.eecs.umich.edu/courses/eecs492_w10/wiki/index.php/iscussion_lides eterministic, tochastic and trategic nvironment eterministic ompletely predictable

More information

CS 5114: Theory of Algorithms. Graph Algorithms. A Tree Proof. Graph Traversals. Clifford A. Shaffer. Spring 2014

CS 5114: Theory of Algorithms. Graph Algorithms. A Tree Proof. Graph Traversals. Clifford A. Shaffer. Spring 2014 epartment of omputer Science Virginia Tech lacksburg, Virginia opyright c 04 by lifford. Shaffer : Theory of lgorithms Title page : Theory of lgorithms lifford. Shaffer Spring 04 lifford. Shaffer epartment

More information

Lesson 18. Laura Ricci 08/05/2017

Lesson 18. Laura Ricci 08/05/2017 Lesson 18 WATTS STROGATZ AND KLEINBERG MODELS 08/05/2017 1 SMALL WORLD NETWORKS Many real networks are characterized by a diameter very low. In several social networks, individuals tend to group in clusters

More information

Algorithms COMBINATORIAL SEARCH. permutations backtracking counting subsets paths in a graph

Algorithms COMBINATORIAL SEARCH. permutations backtracking counting subsets paths in a graph COMBINATORIAL SEARCH Algorithms F O U R T H E D I T I O N permutations backtracking counting subsets paths in a graph R O B E R T S E D G E W I C K K E V I N W A Y N E Algorithms, 4 th Edition Robert Sedgewick

More information

Graphs: Topological Sort / Graph Traversals (Chapter 9)

Graphs: Topological Sort / Graph Traversals (Chapter 9) Today s Outline raphs: Topological Sort / raph Traversals (hapter 9) S 373 ata Structures and lgorithms dmin: omework #4 - due Thurs, Nov 8 th at pm Midterm 2, ri Nov 6 raphs Representations Topological

More information

false, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4

false, import, new 1 class Lecture2 { 2 3 Data types, Variables, and Operators 4 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4 5 } 6 7 // Keywords: 8 byte, short, int, long, char, float, double, boolean, true, false, import, new Zheng-Liang Lu Java Programming 44

More information

Graphs: A graph is a data structure that has two types of elements, vertices and edges.

Graphs: A graph is a data structure that has two types of elements, vertices and edges. Graphs: A graph is a data structure that has two types of elements, vertices and edges. An edge is a connection between two vetices If the connection is symmetric (in other words A is connected to B B

More information

4.2 Directed Graphs. digraph API digraph search topological sort strong components

4.2 Directed Graphs. digraph API digraph search topological sort strong components 4.2 Directed Graphs digraph API digraph search topological sort strong components Algorithms, 4 th Edition Robert Sedgewick and Kevin Wayne Copyright 2002 2010 November 8, 2010 8:43:22 PM Directed graphs

More information

What are graphs? (Take 1)

What are graphs? (Take 1) Lecture 22: Let s Get Graphic Graph lgorithms Today s genda: What is a graph? Some graphs that you already know efinitions and Properties Implementing Graphs Topological Sort overed in hapter 9 of the

More information

Web 2.0 Social Data Analysis

Web 2.0 Social Data Analysis Web 2.0 Social Data Analysis Ing. Jaroslav Kuchař jaroslav.kuchar@fit.cvut.cz Structure(1) Czech Technical University in Prague, Faculty of Information Technologies Software and Web Engineering 2 Contents

More information

Chapter 4 Review. 1. Write a summary of what you think are the important points of this chapter. 2. Draw a graph for the following task table.

Chapter 4 Review. 1. Write a summary of what you think are the important points of this chapter. 2. Draw a graph for the following task table. hapter Review 1. Write a summary of what you think are the important points of this chapter.. raw a graph for the following task table. Task Time Prerequisites Start 0 None 1 5,, I, inish. a. List the

More information

Review Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Review Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Review Chapters 1 to 4 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Introduction to Java Chapters 1 and 2 The Java Language Section 1.1 Data & Expressions Sections 2.1 2.5 Instructor:

More information

A quick review. The clustering problem: Hierarchical clustering algorithm: Many possible distance metrics K-mean clustering algorithm:

A quick review. The clustering problem: Hierarchical clustering algorithm: Many possible distance metrics K-mean clustering algorithm: The clustering problem: partition genes into distinct sets with high homogeneity and high separation Hierarchical clustering algorithm: 1. Assign each object to a separate cluster.. Regroup the pair of

More information

Algorithms ROBERT SEDGEWICK KEVIN WAYNE 3.1 SYMBOL TABLES Algorithms F O U R T H E D I T I O N API elementary implementations ordered operations ROBERT SEDGEWICK KEVIN WAYNE http://algs4.cs.princeton.edu

More information

ELEMENTARY SEARCH ALGORITHMS

ELEMENTARY SEARCH ALGORITHMS BBM 202 - ALGORITHMS DEPT. OF COMPUTER ENGINEERING ELEMENTARY SEARCH ALGORITHMS Acknowledgement: The course slides are adapted from the slides prepared by R. Sedgewick and K. Wayne of Princeton University.

More information

Data Struct. & Prob. Solving, M.C.Q. BANK, FOR UNIT 3, SECOND YEAR COMP. ENGG. SEM 1, 2012 PATTERN, U.O.P.

Data Struct. & Prob. Solving, M.C.Q. BANK, FOR UNIT 3, SECOND YEAR COMP. ENGG. SEM 1, 2012 PATTERN, U.O.P. UNIT distribution for +1+1 + 1 + + = 11 (Only 1 will be asked for marks, s will be asked for 1 & s asked for marks ) Syllabus for Graphs Programmers perspective of graphs, Graph operations, storage structure,

More information

Algorithms. Algorithms GEOMETRIC APPLICATIONS OF BSTS. 1d range search kd trees line segment intersection interval search trees rectangle intersection

Algorithms. Algorithms GEOMETRIC APPLICATIONS OF BSTS. 1d range search kd trees line segment intersection interval search trees rectangle intersection KdTree Next Assignment due /26 (Tuesday after Spring Break) This Thursday, precept will cover the assignment in detail using a great worksheet (thanks Maia!). Due two days after Spring break ends. Second

More information

Introduction to Engineering Systems, ESD.00. Networks. Lecturers: Professor Joseph Sussman Dr. Afreen Siddiqi TA: Regina Clewlow

Introduction to Engineering Systems, ESD.00. Networks. Lecturers: Professor Joseph Sussman Dr. Afreen Siddiqi TA: Regina Clewlow Introduction to Engineering Systems, ESD.00 Lecture 7 Networks Lecturers: Professor Joseph Sussman Dr. Afreen Siddiqi TA: Regina Clewlow The Bridges of Königsberg The town of Konigsberg in 18 th century

More information

CSI 2101 / Winter 2008: Discrete Structures.

CSI 2101 / Winter 2008: Discrete Structures. CSI2101 Discrete Structures (3,1.5,0) 3 cr. Discrete structures as they apply to computer science, algorithm analysis and design. Predicate logic. Review of proof techniques; application of induction to

More information

3.1 Basic Definitions and Applications

3.1 Basic Definitions and Applications Chapter 3 Graphs Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 3.1 Basic Definitions and Applications Undirected Graphs Undirected graph. G = (V, E) V = nodes. E

More information

Introduction To Graphs and Networks. Fall 2013 Carola Wenk

Introduction 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 information

Math 443/543 Graph Theory Notes 10: Small world phenomenon and decentralized search

Math 443/543 Graph Theory Notes 10: Small world phenomenon and decentralized search Math 443/543 Graph Theory Notes 0: Small world phenomenon and decentralized search David Glickenstein November 0, 008 Small world phenomenon The small world phenomenon is the principle that all people

More information

Combinatorial Search. permutations backtracking counting subsets paths in a graph. Overview

Combinatorial Search. permutations backtracking counting subsets paths in a graph. Overview Overview Exhaustive search. Iterate through all elements of a search space. Combinatorial Search Backtracking. Systematic method for examining feasible solutions to a problem, by systematically eliminating

More information

Single Source, Shortest Path Problem

Single Source, Shortest Path Problem Lecture : From ijkstra to Prim Today s Topics: ijkstra s Shortest Path lgorithm epth First Search Spanning Trees Minimum Spanning Trees Prim s lgorithm overed in hapter 9 in the textbook Some slides based

More information

ITEC2620 Introduction to Data Structures

ITEC2620 Introduction to Data Structures T2620 ntroduction to ata Structures Lecture 4a inary Trees Review of Linked Lists Linked-Lists dynamic length arbitrary memory locations access by following links an only traverse link in forward direction

More information

Goals! CSE 417: Algorithms and Computational Complexity!

Goals! CSE 417: Algorithms and Computational Complexity! Goals! CSE : Algorithms and Computational Complexity! Graphs: defns, examples, utility, terminology! Representation: input, internal! Traversal: Breadth- & Depth-first search! Three Algorithms:!!Connected

More information

A quick review. Which molecular processes/functions are involved in a certain phenotype (e.g., disease, stress response, etc.)

A quick review. Which molecular processes/functions are involved in a certain phenotype (e.g., disease, stress response, etc.) Gene expression profiling A quick review Which molecular processes/functions are involved in a certain phenotype (e.g., disease, stress response, etc.) The Gene Ontology (GO) Project Provides shared vocabulary/annotation

More information

Some major graph problems

Some major graph problems CS : Graphs and Blobs! Prof. Graeme Bailey http://cs.cs.cornell.edu (notes modified from Noah Snavely, Spring 009) Some major graph problems! Graph colouring Ensuring that radio stations don t clash! Graph

More information

Lecture 26: Graphs: Traversal (Part 1)

Lecture 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 information

Algorithms. Algorithms 3.1 SYMBOL TABLES. API elementary implementations ordered operations ROBERT SEDGEWICK KEVIN WAYNE

Algorithms. Algorithms 3.1 SYMBOL TABLES. API elementary implementations ordered operations ROBERT SEDGEWICK KEVIN WAYNE Algorithms ROBERT SEDGEWICK KEVIN WAYNE 3.1 SYMBOL TABLES Algorithms F O U R T H E D I T I O N API elementary implementations ordered operations ROBERT SEDGEWICK KEVIN WAYNE https://algs4.cs.princeton.edu

More information