Download presentation
Presentation is loading. Please wait.
1
Concepts of Computation
Session 8b Graphs Dr Oded Lachish (Slides prepared with the support of Dr Paul Newman and Eva Szatmari)
2
Graphs Graphs Connected Component Special types of graphs
Planar graphs Directed graphs Trees Minimum Spanning Tree
3
Connected component of a graph
A connected component of a graph is an induced subgraph H such that there is a path between every two vertices in H and there does not exists a path in G between any vertex in H and vertex not in H. In the example on the right, the connected components are H1, H2,H3, H4, and H5 . G (all the vertices below) H1 H2 H3 H4 H5
4
Special graphs A graph is complete if each vertex is connected to every other vertex. The complete graph with n vertices is denoted Kn A graph or multigraph is k-regular (or regular of degree k) is every vertex has degree k
5
Complete Graph examples
K1 K2 K3 K4 K5
6
k-regular graphs 0-regular 1-regular 2-regular 3-regular
7
Bipartite Graphs In a bipartite graph G, the vertex set V is partitioned into two subsets subsets (say S and T ) Every edge in the graph is adjacent to a vertex in S and to a vertex in T A complete bipartite graph means that every vertex in S is connected to each vertex in T. We use the notation Km,n, two denote the bipartite graph with vertex sets S and T such that |S|=m and |T|=n.
8
Bipartite Graph examples
K1,3 K2,3 K3,1 non-complete
9
Planar Graphs A graph which can be drawn on a plane such that no edges cross each other is called a Planar graph. A particular representation of a planar graph is called a Map. Example: The “can” is emphasized, because seeing a drawing of a graph that is not planar, doesn’t mean that the graph does not have one and hence is not planar. K5 and K3,3 are not planar. If your not convinced, try to prove this is wrong, by drawing it on a plane without crossing edges
10
Maps R1 R2 R3 A map divides the plane into various regions.
In the example below there is one region in each triangle and all the area outside is also considered a region. R1 R R3
11
Maps R1 R2 R3 A map divides the plane into various regions.
Euler’s formula: Connected map: |V| – |E| + |R| = 2 Disconnected map: |V| – |E| + |R| = k V = set of Vertices, E = set of Edges, R = set of Regions, k = no. of connected components R1 R R3
12
Map Examples Connected Map R1 R R3 Disconnected Map R1 R R3 |V| = 6, |E| = 7, |R| = 3, |V| – |E| + |R| = 2 => 6 – = 2 |V| = 6, |E| = 6, |R| = 3, k=2, |V| – |E| + |R| = k+1 => 6 – = 1+2
13
Labelled graph example
v2 v3 v4 2 2 1 3 2 3 1 2 4 1 5 v0 v1 v8 2 4 v5 3 v6 5 v7 May be important to find the path of least weight.
14
Tree graphs A graph is acyclic or cycle-free if it contains no cycles.
A connected, acyclic graph is called a tree. Generally, a forest is a disconnected acyclic graph (but it can also consist of a single tree or an empty graph). The connected subgraphs of a forest are trees.
15
Tree examples All the trees with six vertices, together they are a forest.
16
Rooted tree A tree with a designated vertex r, called the root of the tree, is a rooted tree R. The length of the path, from r to any vertex v, is called the level, depth or generation of v. The endpoints of R are called the leaves of R, the path from r to a leaf is a branch. Any tree can be made into a rooted tree by picking a vertex to be the root.
17
Rooted Tree example a r b e c d h i j f g l m k
18
Spanning trees For a graph G, the sub-graph T is called at spanning tree if it contains all the vertices of G. We used dashed lines to for the edges of the spanning tree. Note that they indeed form a tree
19
Labelled graphs A graph G, is called a labelled graph if edges and/or vertices are assigned data. If each edge e, of G is assigned a number l(e) greater or equal to 0, then l(e) is called the weight or length of e.
20
Minimum spanning tree If the graph G has weighted edges, then a minimal spanning tree of G is that spanning tree with the least weight of the edges. The spanning tree formed by the dashed lines is a minimal spanning tree. Any other spanning tree must have one of the edges with weight larger than 1, and the weight of the minimum spanning tree, which is 4. Can we easily find a spanning tree? Yes! 1 23 22 21 24
21
Finding a minimum Spanning Tree
Pick one edge with the smallest weight We picked an edge of weight 1. There are two, this works regardless which edge we took. The edge is marked by a dashed line 1 2 5 3 4
22
Finding a minimum Spanning Tree
Before choice 2 2 2. Pick one edge with the smallest weight amongst the edges that share exactly one vertex with the edges we already chose The edges to choose from are dotted We picked an edge of weight 2, because it had the smallest weight amongst the dotted ones The before and after are illustrated on the right 3 1 2 4 1 5 2 5 After choice 2 2 3 1 2 4 1 5 2 5
23
Finding a minimum Spanning Tree
Before choice 2 2 3. Pick one edge with the smallest weight amongst the edges that share exactly one vertex with the edges we already chose The edges to choose from are dotted We picked one of edges of weight 2, because it had the smallest weight amongst the dotted ones (there are two. This would still work if we picked the other.) 3 1 2 4 1 5 3 5 After choice 2 2 3 1 2 4 1 5 2 5
24
Finding a minimum Spanning Tree
Before choice 2 2 4. Pick one edge with the smallest weight amongst the edges that share exactly one vertex with the edges we already chose We picked one of edges of weight 2, because it had the smallest weight amongst the dotted ones We notice, the we ignored the edges that share both vertices with edges that we already selected. We notice that these edges together with the ones already selected create a cycle. Meaning that if we chose them we wouldn’t have a tree. 3 1 2 4 1 5 2 5 After choice 2 2 3 1 2 4 1 5 2 5
25
Finding a minimum Spanning Tree
Before choice 2 2 5. Pick one edge with the smallest weight amongst the edges that share exactly one vertex with the edges we already chose We picked one of edges of weight 1, because it had the smallest weight amongst the dotted ones Now all the edges we selected are those of a spanning tree, because it is connected has no cycles and has all the vertices of the graph. So we are done. The total weight is = 8 3 1 2 4 1 5 2 5 After choice 2 2 3 1 2 4 1 5 2 5
26
Finding a minimum spanning tree
The only thing we did was one initial step and then repeat the same step again and again until we had a spanning tree. Pick one edge with the smallest weight amongst the edges Select one edge with the smallest weight amongst the edges that share exactly one vertex with the edges we already chose Lets try a different order on the same example
27
Finding a minimum spanning tree
Step 1 Step 3 Step 5 2 2 2 2 1 2 5 3 4 3 3 4 4 1 2 1 1 2 1 5 5 2 5 2 5 2 2 2 2 3 3 Step 2 4 4 1 2 1 1 2 1 1 2 5 3 4 5 5 2 5 2 5 Step 4 2 2 The weight of the spanning tree is = 8 We notice that it is not the same spanning tree as in the previous time 3 2 2 4 1 2 1 5 3 4 1 2 1 2 5 5 2 2 2 5 3 4 1 2 1 5 2 5
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.