graphs edge(arc) vertices can be even or odd or undirected (two-way) edges can be directed (one-way)...

32
Graphs Edge(arc ) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected . Degree(order ) = 3 Odd vertex The degree(order) of a vertex is the number of edges meeting at a vertex vertex (node) Degree(Order) = 2 Even vertex This is a graph .

Upload: anabel-weaver

Post on 17-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

Graphs

Edge(arc)

Vertices can be even or odd

or undirected (two-way)

Edges can be directed (one-way)

This graph is connected.

Degree(order) = 3Odd vertex

The degree(order) of a vertex is the number of edges meeting at a vertex

vertex (node)

Degree(Order) = 2Even vertex

This is a graph.

Page 2: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

The stations are the nodes and the tracks are the arcs.

The London Tube map is an example.

The arcs only indicate which nodes are joined not the distance between them.

It should be called the London Tube Graph

Page 3: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

Graph

Page 4: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

Map

Page 5: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

Before Harry Beck redesigned the tube map 1931 (Beck was responsible for the iconic, more user-friendly version we use today), Londoners used this map to navigate the underground network. It has many lost stations on it as well as different names for some existing ones.

Page 6: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex
Page 7: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

49 mins

39 mins

28 mins

22 mins

24 mins

29 mins

34 mins

15 miles

17 miles

15 miles

12 miles

17 miles

21 miles

20 miles

Networks

Colchester

Stowmarket

IpswichSudbury

Bury St Edmunds

Harwich

In a Network the arcs have values such as distances or journey times or traffic flow

Page 8: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

Degree 3

Degree 2

loop

Multiple arc

arc

The Degree ( Order) of a node

An arc that starts and finishes at the same vertex is a LOOP.A graph with no loops or multiple edges is called a simple graph.

is the number of arcs that meet at that node.

Page 9: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

A connected graph has all nodes linked in.

A graph that ‘falls apart’ is disconnected.

disconnected simple connected graph

Page 10: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

A little history: the Bridges of Koenigsberg

• “Graph Theory” began in 1736• Leonhard Eüler

– Visited Koenigsberg– People wondered whether it is possible to take a walk, end up where you started from, and cross each bridge in Koenigsberg exactly once

Page 11: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

The Bridges of Koenigsberg

A

D

C

B

1 2

4

3

7

65

Is it possible to start in A, cross over each bridge exactly once,

and end up back in A?

Page 12: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

The Bridges of Koenigsberg

A

D

C

1 2

4

3

7

65

Translation into a graph problem: Land masses are “nodes”.

B

Page 13: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

The Bridges of Koenigsberg

1 2

4

3

7

65

Translation into a graph problem : Bridges are “arcs.”

A

C

D

B

Page 14: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

The Bridges of Koenigsberg

1 2

4

3

7

65

Is there a “walk” starting at A and ending at A and passing through each arc exactly once?

Such a walk is called an eulerian cycle.

A

C

D

B

Page 15: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

If every node is linked to every other node by a single edge it is complete.

Everything meets when its complete

If a graph is complete it is given the name Kn where n is the number of nodes.

K5K3

Page 16: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

If every node is linked to every other node by a single edge it is complete.

K5K3

How many arcs(edges)? Find a rule!Make a tableK3, K4, K5, K6 etc

Page 17: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

If a graph contains a closed trail then that section is called a cycle.

A,B,D is a cycle in the graph below.

B

A

D

C

A Cycle:

Page 18: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

A connected graph in which there are no cycles (not closed) is called a Tree.

The number of arcs of a tree is one less than the number of nodes.

No. Arcs = No. Nodes =

Tree

7 8

No. arcs = No. nodes -1

Page 19: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

PathsRoutes that do not visit any vertex more than onceand do not go along any edge more than once except the start.

A cycle forms a loop by returning to its starting point

Page 20: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

Colchester

Stowmarket

IpswichSudbury

Bury St Edmunds

Harwich

adjacency matrix

010001

100110

000100

011010

010101

100010B Su C H I St

B

Su

C

H

I

St

An Adjacency Matrix shows which vertices are joined

Page 21: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

Colchester

Stowmarket

IpswichSudbury

Bury St Edmunds

Harwich

distance matrix

B Su C H I St B

Su

C

H

I

St

15 miles

17 miles

15 miles

12 miles

17 miles

21 miles

20 miles

01200015

120017200

0002100

017210150

020015017

15000170

An Distance Matrix shows the distance between vertices.

As it is undirected the matrix is symmetricalHarwich to Colchester = Colchester to Harwich

Page 22: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

Directed Graphs (Digraph)If it is only possible to travel along the arcs in one direction then the graph is called a digraph.

If a graph represents a street plan then some of the streets may be one way.

Arrows are used to indicate the allowable direction.

Arcs without arrows can be travelled in either direction

Page 23: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

B

A D

C3

2 14

5

If the network is a directed graph then the direction matters and the matrix is not symmetrical as can be seen below.It is not possible to go From A To B as the route is directed. A To C is 4 whereas C To A is 5

A B C D

From

A 4

B 2 3

C 5 3 1

D 1

To

Page 24: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

DCBA

1

134

32

42

D

C

B

AB

A D

C3

2 14

Networks

A network is graph where each arc has a weight.

This could be a distance if it represents a map or the number of cars that can travel down a roadin a specified time without becoming congested.

Representing a network using a matrix

Page 25: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

Graphs in our daily livesGraphs in our daily lives

• Transportation• Telephone • Computer• Electrical (power)• Pipelines• Molecular structures in biochemistry

Page 26: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

Telephone network

Page 27: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex
Page 28: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

Molecular chain of atoms in protein

Page 29: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

Review of Graphs• A graph (or network) consists of

– a set of points– a set of lines connecting certain pairs of the points.

The points are called.

The lines are called• Example:

nodes (or vertices)

arcs (or edges or links).

Page 30: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

Terminology of Graphs: Paths

• A path between two nodes is a sequence of distinct nodes and edges connecting these nodes.

Example:

• Walks are paths that can repeat nodes and arcs.

a

b

Page 31: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

Adding two bridges creates such a walk

1 2

4

3

7

65

A

C

D

B

8

9

Here is the walk.

Note: the number of arcs incident to B is twice the number of times that B appears on the walk.

Page 32: Graphs Edge(arc) Vertices can be even or odd or undirected (two-way) Edges can be directed (one-way) This graph is connected. Degree(order) = 3 Odd vertex

Existence of Eulerian Cycle

1 2

4

3

7

65

A

C

D

B

8

9

The degree of a node is the number of arcs that meet at the node

6

4

4

4

Theorem. An undirected graph has an eulerian cycle if and only if (1) every node degree is even and (2) the graph is connected (that is, there is a path from each node to each other node).