a - l

15
A - L M - Z Emergenc y • Danny Fan Peter Hsiao Eric Joel • Gabriel Lam Jeffrey Lee Marvin Lee • Greg Yi Alison Ystma Bu Yu ↑↓ 3 sorted stacks! →

Upload: tawana

Post on 07-Jan-2016

29 views

Category:

Documents


0 download

DESCRIPTION

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. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: A - L

A - L

M - Z

Emergency• 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! →

Page 2: A - L

An introduction to graphs

Page 3: A - L

Hash table: Theory and chaining

An introduction to graphs

What is a graph?

Basic implementation

Answering questions

Page 4: A - L

What is a graph?What is a graph?

Page 5: A - L

What is a graph?

An introduction to graphs

A graph is a set of elements called nodes, connected via edges.

Vancouver

Victoria

Mayne IslandBowen Island

Nanaimo

Transportation Network

Page 6: A - L

What is a graph?

An introduction to graphs

A graph is a set of elements called nodes, connected via edges.

Satellite Network

Page 7: A - L

Arash

What is a graph?

An introduction to graphs

A graph is a set of elements called nodes, connected via edges.

Social Network

Ibn Phil

Pranil Peter

Page 8: A - L

What is a graph?

An introduction to graphs

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

Page 9: A - L

What is a graph?

An introduction to graphs

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.

Page 10: A - L

What is a graph?

An introduction to graphs

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.

In weighted graphs, edges have numerical values.

4

4 2

2

2

0

0

1

1 3(length of the road, delay of signal between satellites, how much you like somebody, …)

Page 11: A - L

Starting to answer Starting to answer questionsquestions

Page 12: A - L

The whole point of representing a problem as a graph is to be able to

carry on analysis on the relationships.

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.

What’s the path to go from Alison Ystma to Marvin Lee?

Alison Ystma → Mike Kubanski → Andreea Says Hi → Priyam Banerjee → Marvin Lee

Now, how would you make that into an algorithm ?

Page 13: A - L

Finding a path, simple approach

An introduction to graphs

A

B

Lets say that we have some graphs and we want the path from A to B.

You can proceed by successive waves.

Page 14: A - L

Finding a path, simple approach

An introduction to graphs

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).

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’.

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

The only thing to be careful about is not to go to the same node twice. So, use flags!

Page 15: A - L

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

Aram

Pranil Marvin

Philippe Behdad

JeffreyRobin

Priyam

Andrrea

Danish

Shivam

Go from Shivam to Aram.