Presentation is loading. Please wait.

Presentation is loading. Please wait.

Discrete Maths 9. Graphs Objective

Similar presentations


Presentation on theme: "Discrete Maths 9. Graphs Objective"— Presentation transcript:

1 Discrete Maths 9. Graphs Objective
242/ , Semester 2, 9. Graphs Objective introduce basic graph concepts(e.g. Euler and Hamiltonian cycles)

2 1. Graph Terms (Strongly) Connected Component Vertices/Nodes Edges
Sub Graph Complete Graph Directed Acyclic Graph (DAG) Euler/Hamiltonian Cycle Vertices/Nodes Edges Un/Weighted Un/Directed In/Out Degree Self-Loop/Multiple Edges Sparse/Dense Path, Cycle Isolated, Reachable

3 A graph has two parts (V, E), where: V are the nodes, called vertices
E are the links between vertices, called edges PVD ORD SFO LGA HNL LAX DFW MIA

4 A weighted graph adds edge numbers.
8 b a 6 2 6 4 c 3 d 5 9 12 4 e

5 Directed graph the edges are directed e.g., bus cost network Undirected graph the edges are undirected e.g., road network

6 End vertices (or endpoints) of an edge
U and V are the endpoints Edges incident on a vertex a, d, and b are incident Adjacent vertices U and V are adjacent Degree of a vertex X has degree 5 Parallel edges h and i are parallel edges Self-loop j is a self-loop X U V W Z Y a c b e d f g h i j

7 Path Simple path Examples sequence of alternating vertices and edges
begins with a vertex ends with a vertex each edge is preceded and followed by its endpoints Simple path path such that all its vertices and edges are distinct Examples P1=(V,b,X,h,Z) is a simple path P2=(U,c,W,e,X,g,Y,f,W,d,V) is a path that is not simple V a b P1 d U X Z P2 h c e W g f Y

8 Cycle Simple cycle Examples
circular sequence of alternating vertices and edges each edge is preceded and followed by its endpoints Simple cycle cycle such that all its vertices and edges are distinct Examples C1=(V,b,X,g,Y,f,W,c,U,a) is a simple cycle C2=(U,c,W,e,X,g,Y,f,W,d,V,a,) is a cycle that is not simple V a b d U X Z C2 h e C1 c W g f Y

9 A graph is connected if there is a path between every pair of vertices
Connected graph Non connected graph with two connected components

10 Strong Connectivity Each vertex can reach all other vertices a g c d e
b e f g

11 Complete Graphs All pairs of vertices are connected by an edge.

12 Directed Acyclic Graph (DAG)
A DAG has no cycles Some algorithms become simpler/faster when used on DAGs instead of general graphs

13 2. The Euler Cycle If a graph G has a simple cycle from vertex v to v, which uses every edge exactly once, only if there are an even number of edges connected to each vertex. The first graph theory result, proved by by Leonhard Euler in 1736 for the Konigsberg Bridge Problem.

14 From Map to Graph

15 Infact, none of the nodes have an even degree!
If at least one node has an odd degree then an Euler cycle is impossible. Infact, none of the nodes have an even degree! a b

16 Practical Uses of Euler Cycles
In computer networks, edge traversal (i.e. moving between network nodes) is expensive. Euler’s definition is a very fast algorithm for checking whether a graph (network) can be traversed efficiently.

17 Example Can this network be traversed efficiently (e.g. by a Web search engine collecting information)? e.g. start at a, finish at a, travel each edge only once? a b c f e d g h i

18 3. Hamiltonian Cycle Sir William Rowan Hamilton’s puzzle (1850’s)
it made him very rich Each corner is labelled with a city name. The shape is a dodecahedron. My version uses country names. continued

19 Problem: start at any city (letter), travel along the edges, visit each city exactly once, and return to the starting city. Note: not all edges need to be used

20 Graph of Hamilton’s Puzzle

21 Hamiltonian Cycle Formalised
In a graph G, find a cycle that contains each vertex exactly once, except for the starting/ending vertex that appears twice.

22 A Solution not all edges used b a g f h p t i o q s r j c n e m k l d

23 Hamilton vs. Euler? A Euler cycle visits each edge once.
A Hamiltonian cycle visits each vertex once. They sound similar, but mathematicians have much harder problems with Hamiltonian cycles e.g. it is easy to check for a Euler cycle, but there is no simple test for a Hamiltonian cycle

24 Algorithms for Finding Cycles
There are algorithms for finding a Euler cycle in a graph which take time proportional to the number of edges in the graph Algorithms for finding a Hamiltonian cycle time proportional to the factorial of the number of edges in the graph much too slow for real graphs continued

25 For that reason, algorithms designed for real-world data only generate near-minimum length cycles
they are less time consuming, but may not give the best answer

26 Some Properties of Hamiltonian Cycles
1) If a graph has N verticies, then the Hamiltonian cycle must use N edges. e.g. s a b t w v d c u 2) Every vertex in a Hamiltonian cycle has a degree of 2 (some edges may not be used).

27 Example 1. Is there a H.C? Assume that the graph does have a H.C.
The H.C must include the two edges connected to v1 and v3. This creates a loop, but without v5, so not a H.C. v1 v2 v5 v4 v3 continued

28 Example 2: Is there is a H.C?
b c a e d f i k g h j l m continued

29 Assume that the graph does have a H.C.
Edges (a,b), (a,g), (b,c), (c,k) must be in the H.C. since verticies ‘a’, ‘c’ have degree 2. Therefore, edges (b,d), (b,f) must not be in the H.C. since ‘b’ is fully used already. continued

30 But there is now a cycle:
Therefore, edges (g,d), (d,e), (e,f), (f,k) must be in the H,C,. since that is the only way to have ‘d’ and ‘f’ in the H.C. But there is now a cycle: {a, b, c, k, f, e, d, g, a} We cannot connect any more edges to g, e, k since their degree is 2 already so it is not possible to create a H.C.

31 4. The Travelling Salesman Problem
This problem is related to the Hamiltonian cycle, but the graph is weighted. Given a weighted graph G, find a minimum length Hamiltonian cycle in G.

32 Example 1 Answer: {a,b,c,d,a} with minimum length 11.
Proof: try replacing any edge (e.g. (d,c) by either of the ‘long’ edges. b a 2 11 3 3 d 3 c 11

33 Why Travelling Salesman?
Think of the verticies as cities, edge weights as distances. The problem becomes: find a shortest route in which a salesman (or woman) can visit each city once, starting and ending at the same city.

34 4. Further Information Discrete Mathematics and its Applications Kenneth H. Rosen McGraw Hill, 2007, 7th edition chapter 10, sections 10.1, 10.2


Download ppt "Discrete Maths 9. Graphs Objective"

Similar presentations


Ads by Google