Skip to main content

Discrete Mathematics - Spanning Trees


A spanning tree of a connected undirected graph G is a tree that minimally includes all of the vertices of G. A graph may have many spanning trees.

Example

Graph in SpanSpanning Tree

Minimum Spanning Tree

A spanning tree with assigned weight less than or equal to the weight of every possible spanning tree of a weighted, connected and undirected graph G, it is called minimum spanning tree (MST). The weight of a spanning tree is the sum of all the weights assigned to each edge of the spanning tree.

Example

Minimum Spanning Tree

Kruskal's Algorithm

Kruskal's algorithm is a greedy algorithm that finds a minimum spanning tree for a connected weighted graph. It finds a tree of that graph which includes every vertex and the total weight of all the edges in the tree is less than or equal to every possible spanning tree.

Algorithm

Step 1 − Arrange all the edges of the given graph G(V,E) in non-decreasing order as per their edge weight.
Step 2 − Choose the smallest weighted edge from the graph and check if it forms a cycle with the spanning tree formed so far.
Step 3 − If there is no cycle, include this edge to the spanning tree else discard it.
Step 4 − Repeat Step 2 and Step 3 until (V1) number of edges are left in the spanning tree.
Problem
Suppose we want to find minimum spanning tree for the following graph G using Kruskal’s algorithm.
Kruskal Problem
Solution
From the above graph we construct the following table −
Edge No.Vertex PairEdge Weight
E1(a, b)20
E2(a, c)9
E3(a, d)13
E4(b, c)1
E5(b, e)4
E6(b, f)5
E7(c, d)2
E8(d, e)3
E9(d, f)14
Now we will rearrange the table in ascending order with respect to Edge weight −
Edge No.Vertex PairEdge Weight
E4(b, c)1
E7(c, d)2
E8(d, e)3
E5(b, e)4
E6(b, f)5
E2(a, c)9
E3(a, d)13
E9(d, f)14
E1(a, b)20
Kruskal Adding Vertex EdgeKruskal Adding Vertex Edge 1Kruskal Adding Vertex Edge 2
Since we got all the 5 edges in the last figure, we stop the algorithm and this is the minimal spanning tree and its total weight is (1+2+3+5+9)=20.

Prim's Algorithm

Prim's algorithm, discovered in 1930 by mathematicians, Vojtech Jarnik and Robert C. Prim, is a greedy algorithm that finds a minimum spanning tree for a connected weighted graph. It finds a tree of that graph which includes every vertex and the total weight of all the edges in the tree is less than or equal to every possible spanning tree. Prim’s algorithm is faster on dense graphs.

Algorithm

  • Initialize the minimal spanning tree with a single vertex, randomly chosen from the graph.
  • Repeat steps 3 and 4 until all the vertices are included in the tree.
  • Select an edge that connects the tree with a vertex not yet in the tree, so that the weight of the edge is minimal and inclusion of the edge does not form a cycle.
  • Add the selected edge and the vertex that it connects to the tree.
Problem
Suppose we want to find minimum spanning tree for the following graph G using Prim’s algorithm.
Prim
Solution
Here we start with the vertex ‘a’ and proceed.
prim' Vertex a addedprim' Vertex c b addedprim' Vertex d e addedprim' Vertex f added
This is the minimal spanning tree and its total weight is (1+2+3+5+9)=20.

Comments

Popular posts from this blog

Discrete Mathematics - Rules of Inference

To deduce new statements from the statements whose truth that we already know,  Rules of Inference  are used. What are Rules of Inference for? Mathematical logic is often used for logical proofs. Proofs are valid arguments that determine the truth values of mathematical statements. An argument is a sequence of statements. The last statement is the conclusion and all its preceding statements are called premises (or hypothesis). The symbol “ ∴ ∴ ”, (read therefore) is placed before the conclusion. A valid argument is one where the conclusion follows from the truth values of the premises. Rules of Inference provide the templates or guidelines for constructing valid arguments from the statements that we already have. Table of Rules of Inference Rule of Inference Name Rule of Inference Name P ∴ P ∨ Q P ∴ P ∨ Q Addition P ∨ Q ¬ P ∴ Q P ∨ Q ¬ P ∴ Q Disjunctive Syllogism P Q ∴ P ∧ Q P Q ∴ P ∧ Q Conjunction P → Q Q → R ∴ P → R P → Q Q → R ∴ P → R ...

5 best private search engines and why you need to use them.

5 best private search engines and why you need to use them  By:  Boniyeamin laju   ▪   May 31, 2019   ▪ 3 minute read 5 best private search engines and why you need to use  Normal browsers like Google and Bing are designed to track users’ activities and profile their online behavior. The primary reason for this is to create advertisements that will be attractive to the user. However, there-there is always the concern of  personal information being compromised  due to security breaches, state surveillance, and unauthorized data sharing. Fortunately,  private search engines  can help keep your private information safe. Simply put, Private Search Engines, also known as PSE, uses proxy and encrypted search request to  hide your personal information  from anyone looking to misuse your information. Below you will find more information about what a PSE is, how it works, and wh...

Discrete Mathematics - Propositional Logic

The rules of mathematical logic specify methods of reasoning mathematical statements. Greek philosopher, Aristotle, was the pioneer of logical reasoning. Logical reasoning provides the theoretical base for many areas of mathematics and consequently computer science. It has many practical applications in computer science like design of computing machines, artificial intelligence, definition of data structures for programming languages etc. Propositional Logic  is concerned with statements to which the truth values, “true” and “false”, can be assigned. The purpose is to analyze these statements either individually or in a composite manner. Prepositional Logic – Definition A proposition is a collection of declarative statements that has either a truth value "true” or a truth value "false". A propositional consists of propositional variables and connectives. We denote the propositional variables by capital letters (A, B, etc). The connectives connect the propositi...