1 / 15

A - L

Emergency. A - L. • Danny Fan • Peter Hsiao • Eric Joel • Alwin Kwok • Jeremy Lau. • Gabriel Lam • Jeffrey Lee • Marvin Lee • Heedong Park • Andrew Samuel. • Greg Yi • Alison Ystma • Bu Yu. ↑↓ 3 sorted stacks! →. M - Z. An introduction to graphs.

tawana
Download Presentation

A - L

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Emergency A - L • Danny Fan • Peter Hsiao • Eric Joel • Alwin Kwok • Jeremy Lau • Gabriel Lam • Jeffrey Lee • Marvin Lee • Heedong Park • Andrew Samuel • Greg Yi • Alison Ystma • Bu Yu ↑↓ 3 sorted stacks! → M - Z

  2. An introduction to graphs

  3. An introduction to graphs What is a graph? Basic implementation Answering questions Hash table: Theory and chaining

  4. What is a graph?

  5. What is a graph? A graph is a set of elements called nodes, connected via edges. Bowen Island Mayne Island Nanaimo Vancouver Victoria Transportation Network An introduction to graphs

  6. What is a graph? A graph is a set of elements called nodes, connected via edges. Satellite Network An introduction to graphs

  7. What is a graph? Arash Pranil Peter Ibn Phil A graph is a set of elements called nodes, connected via edges. Social Network An introduction to graphs

  8. What is a graph? A graph is a set of elements called nodes, connected via edges. It’s a very common modeling tool: as soon as you have entities and some sort of relationship, you can use it. Commonly, nodes are represented by and edges byaaaaa An introduction to graphs

  9. What is a graph? A graph is a set of elements called nodes, connected via edges. It’s a very common modeling tool: as soon as you have entities and some sort of relationship, you can use it. Commonly, nodes are represented by and edges byaaaaa As it’s a modeling tool, if you need to model more features, just get them in. The graph can be undirected or directed (edges have a direction). Roads have a direction. An introduction to graphs

  10. What is a graph? A graph is a set of elements called nodes, connected via edges. It’s a very common modeling tool: as soon as you have entities and some sort of relationship, you can use it. Commonly, nodes are represented by and edges byaaaaa As it’s a modeling tool, if you need to model more features, just get them in. 4 0 4 2 In weighted graphs, edges have numerical values. 1 1 3 0 2 (length of the road, delay of signal between satellites, how much you like somebody, …) 2 An introduction to graphs

  11. Starting to answer questions

  12. What’s the path to go from Alison Ystma to Marvin Lee? A simple question is to find the path between two nodes, i.e. the sequence of nodes that we have to visit to go from one to the other. The whole point of representing a problem as a graph is to be able to carry on analysis on the relationships. Alison Ystma→ Mike Kubanski → Andreea Says Hi → Priyam Banerjee → Marvin Lee Now, how would you make that into an algorithm ?

  13. Finding a path, simple approach Lets say that we have some graphs and we want the path from A to B. You can proceed by successive waves. A B An introduction to graphs

  14. Finding a path, simple approach Lets say that we have some graphs and we want the path from A to B. You can proceed by successive waves. This is called a breadth-first search (BFS). BFS(from, destination): // do we have a path? Queue ← from While there is a node C to get from the queue If C is the destination, return true Otherwise add C’s neighbours to the queue Return false At each step, we look if we have found the element. If not, the next nodes to visit are the neighbours of the next ‘wave’ or ‘layer’. The only thing to be careful about is not to go to the same node twice. So, use flags! An introduction to graphs

  15. Aram Pranil Marvin Andrrea Philippe Behdad Priyam Danish BFS(from, destination): // do we have a path? Queue ← from While there is a node C to get from the queue If C is the destination, return true Otherwise add C’s neighbours to the queue Return false Shivam Robin Jeffrey Go from Shivam to Aram.

More Related