Presentation is loading. Please wait.

Presentation is loading. Please wait.

Graphs, Trees and Algorithms 1

Similar presentations


Presentation on theme: "Graphs, Trees and Algorithms 1"— Presentation transcript:

1 Graphs, Trees and Algorithms 1
MATH10001 Project 4 Graphs, Trees and Algorithms 1 ugstudies/units/ /level1/MATH10001/

2 Four Colour Problem – can every map be coloured using 4 colours?
Graph theory started as a topic in pure mathematics but has now become a useful tool for applied mathematicians, biologists, economists, geographers and computer scientists. Four Colour Problem – can every map be coloured using 4 colours? Solved by Appel and Haken in 1976 using computer calculations.

3 A graph G is a pair of sets V(G) and E(G) called the vertices and the edges respectively.
V(G) = {v1, v2,…,vn} E(G) = {e1, e2, …, ep} where n  1 and p  0. Each edge is a pair of vertices e = uv or vu. We say two vertices are adjacent if they define an edge and that an edge is incident with its endpoints which are the defining vertices. The degree of a vertex v , d(v), is the number of edges incident with v. A vertex with degree 0 is called an isolated vertex.

4 Diagrams A diagram D(G) of a graph G is a visual representation in the plane where vertices are drawn as points joined by lines representing the edges. Let V(G) = {u, v, w, x, y, z} and E(G) = {uv, uw, vw, vx, yz, xw, xy} This is a diagram for G. u v x w y z

5 A loop is an edge joining a vertex to itself
A loop is an edge joining a vertex to itself. This contributes 2 to the degree of a vertex. A graph can have multiple edges between two vertices. If a graph has loops or multiple edges we call it a multigraph. If the graph has no loops or multiple edges we call it a simple graph. Proposition 1 Let G be a graph with n vertices and p edges. Then

6 An adjacency table for a graph lists the vertices in one column together with the vertices adjacent to them in the second column. Two graphs G and H are isomorphic if their vertices can be relabelled {v1, v2,…,vn} and {w1, w2,…,wn} so that vi and vj are adjacent in G iff wi and wj are adjacent in G for all 1  i,j  n. u v,w v u,w,x w u,v,x x v,w,y y x,z z

7 A path of length m from vertex u to vertex v is a sequence of vertices
u = v0, v1,…,vm = v where vi-1 is adjacent to vi for all i = 1,…,m. A closed path where u = v is called a cycle. The distance between two vertices u and v, (u,v), is the minimum length of any path from u to v. If there is no path we let (u,v) = . We say a graph G is connected if there is a path between any pair of vertices.

8 Graph Algorithms In practice, when studying properties of graphs it is often easier to use an algorithm. This is finite sequence of instructions (steps) with an INPUT and an OUTPUT, that stops after a finite number of steps.

9 Breadth First Search Algorithm
INPUT: a graph G with a root vertex u. OUTPUT: (u,v) for all v  V(G). 1. root:= u 2. i := 0 and label the root with i. 3. find all unlabelled vertices adjacent to a vertex with label i. 4. label all vertices from step 3 with i+1; if none go to step 6. 5. i := i+1 and go to step 3. 6. label all unlabelled vertices with . 7. output the labelled vertices and stop.


Download ppt "Graphs, Trees and Algorithms 1"

Similar presentations


Ads by Google