• Tidak ada hasil yang ditemukan

NPTEL MOOC,JAN-FEB 2015 Week 3, Module 1

N/A
N/A
Protected

Academic year: 2024

Membagikan "NPTEL MOOC,JAN-FEB 2015 Week 3, Module 1"

Copied!
30
0
0

Teks penuh

(1)

DESIGN AND ANALYSIS OF ALGORITHMS

Introduction to graphs

MADHAVAN MUKUND, CHENNAI MATHEMATICAL INSTITUTE http://www.cmi.ac.in/~madhavan

NPTEL MOOC,JAN-FEB 2015

Week 3, Module 1

(2)

Map Colouring

Assign each

state or country a colour

States that

share a border should be

coloured differently How many

colours do we need?

(3)

Map Colouring

Mark each state

(4)

Map Colouring

Mark each state Connect states that share a

border

(5)

Map Colouring

Mark each state Connect states that share a

border

Assign colours to dots so that no two

connected dots have the same colour

(6)

Map Colouring

Mark each state Connect states that share a

border

Assign colours to dots so that no two

connected dots have the same colour

(7)

Map Colouring

Mark each state Connect states that share a

border

Assign colours to dots so that no two

connected dots have the same colour

(8)

Map Colouring

Mark each state Connect states that share a

border

Assign colours to dots so that no two

connected dots have the same colour

(9)

Map Colouring

Mark each state Connect states that share a

border

Assign colours to dots so that no two

connected dots have the same colour

(10)

Map Colouring

Mark each state Connect states that share a

border

Assign colours to dots so that no two

connected dots have the same colour

(11)

Map Colouring

(12)

Map Colouring

In fact, the

actual map is irrelevant!

(13)

Map Colouring

In fact, the

actual map is irrelevant!

All we need is the underlying pattern of dots and connections

(14)

Map Colouring

This kind of diagram is

called a graph Dots are nodes or vertices

One vertex,

many vertices Connections are edges

(15)

Graph

Colouring

The problem we

have solved is called graph colouring

We used 4 colours In fact, 4 colours are always enough for

such maps

This is a theorem that is surprisingly hard to prove!

(16)

Graph

Colouring

Observe that the original map

used more than 4 colours

(17)

Graph

Colouring

Observe that the original map

used more than 4 colours

(18)

Graph

Colouring

The graph

emphasizes the essential features of the problem

What is

connected to what?

(19)

Graph

Colouring

The graph

emphasizes the essential features of the problem

What is

connected to what?

We can distort

this figure and the problem remains the same

(20)

More graph

problems

(21)

More graph problems

Airline routing

(22)

More graph problems

Airline routing

Can I travel from New Delhi to

Trivandrum without

changing airlines?

(23)

More graph problems

Airline routing

Can I travel from New Delhi to

Trivandrum without

changing airlines?

Again, all that is important is the underlying

graph

(24)

Graphs, formally

G = (V,E)

Set of vertices V Set of edges E

E is a subset of pairs (v,v’): E V × V

Undirected graph: (v,v’) and (v’,v) are the same edge Directed graph:

(v,v’) is an edge from v to v’

Does not guarantee that (v’,v) is also an edge

(25)

Graph

Colouring

Undirected graph

(26)

Graph

Colouring

Undirected graph

Colouring C assigns each

vertex v a colour C(v)

Legal colouring:


if (v,v’) is in E, then C(v) ≠ C(v’)

(27)

Finding a

route

(28)

Finding a route

Directed graph

(29)

Finding a route

Directed graph Find a sequence of vertices v0, v1,

…, vk such that v0 is New

Delhi

Each (vi,vi+1) is an edge in E vk is

Trivandrum

v0

v1

v2

v3

v4

v5

(30)

Finding a route

Also makes sense for undirected

graphs

Find a sequence of vertices v0, v1,

…, vk such that v0 is New Delhi Each (vi,vi+1) is an edge in E

vk is Trivandrum

v0

v1

v2

v3

v4

v5

Referensi

Dokumen terkait