A New Approach To Find Minimum Spanning Tree For Undirected Graphs

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

International Journal of Emerging Trends & Technology in Computer Science (IJETTCS)

Web Site: www.ijettcs.org Email: editor@ijettcs.org, editorijettcs@gmail.com Volume 3, Issue 1, January February 2014 ISSN 2278-6856

A New Approach to Find Minimum Spanning Tree for Undirected Graphs


Marriswamy.R1 , Dr.Ravikumar H.Roogi2 and Dr.S.V.Shindhe3
1,2,3

Karnatak University, Dept of Computer Science, Dharwad, India

Abstract: This is new approach to finding the minimum


spanning tree for simple undirected graphs. The algorithm involves choosing the minimum edge that connects each disjoint component of the graph, until a single component is the minimum spanning tree of the given graph. The approach we take is a slight modification to Borvka's algorithm

that have multiple edges connecting them. The final single component is the required minimum spanning tree. In this paper, we give a proof as well as a pseudo code for our algorithm and illustrate it with an example.

2. Definitions and Graph Terminologies


2.1Graph: A graph G consists of two sets V and E. The set V is finite, nonempty set of vertices; these fairs are called edges. The notations V (G) and E (G) represent the sets of vertices and edges, respectively, of graph G. we also write G= (V, E) to represent a graph. [2] 2.2Tree: A tree is a type of connected graph. A directed graph is a tree if it is connected, has no cycles and all vertices have at most one parent. An undirected graph is considered a tree if it is connected, has vertices one more than the number of edges. Such a graph is acyclic. 2.3 Spanning tree: A spanning tree is a tree in which all nodes are connected without forming a closed path or circuit. Formally, a spanning tree of G is defined as a sub graph with the following properties. =V is connected is acyclic 2.4 Weighted Trees: A weighted tree associates a label (weight) with every edge in the graph. We denote the weight of an edge e as wt (e). The weight of tree wt (T) is the sum of the weights of the edges. 2.5 Minimum Spanning Tree: A minimum spanning tree of a given graph G is spanning tree whose cost is minimum. For the graph shown in below figure, the minimum spanning tree is

Keywords: Graph, Tree, Spanning Tree, MST

1. INTRODUCTION
To find a spanning tree of a graph, pick an initial node and call it part of the spanning tree do a search from the initial node: each time you find a node that is not in the spanning tree, add to the spanning tree both the new node and the edge you followed to get to it. Suppose you have connected undirected graph with a weight (or cost) associated with each edge. The cost of spanning tree would be some of the cost of it edges The applications of minimum spanning tree or MSTs are constructing a pipeline network to connect a number of towns using the smallest possible total length of pipeline. Due to the various uses of MSTs in everyday problems, efficient algorithms that can solve graphs with a large number of vertices are required. Traditionally, Prims and Kruskals algorithms have been used create minimum spanning trees, and do so efficiently. Their predecessor is Boruvkas (or Sollins) algorithm, which is where the MST algorithm in these papers derived from. Prims algorithm involves dividing vertices of a graph into two sets visited and unvisited, with the initial visited vertex being arbitrarily chosen as the starting vertex. On each iteration, the minimum edge connecting an unvisited vertex to a visited vertex is added to the tree. The final tree T formed, that spans the vertices of the graph is a minimum spanning tree. In Kruskals algorithm, each edge of the graph G is examined is ascending order of weight, and if the chosen edge does not form a cycle in the tree T, it is added to T. The process continues until n1 edges have been added. In this MST algorithm, each disjoint component of th spanning tree is connected by adding the minimum edge between any two components to the tree. The algorithm starts with all vertices of the graph as disjoint components and examines each component to determine the minimum edge incident on that component. Effectively , this algorithm continues until only final component remains, and in the worst case, each iteration halves the number of disjoint components reaming edge will be chosen between two components Volume 3, Issue 1 January February 2014

Page 18

International Journal of Emerging Trends & Technology in Computer Science (IJETTCS)


Web Site: www.ijettcs.org Email: editor@ijettcs.org, editorijettcs@gmail.com Volume 3, Issue 1, January February 2014 ISSN 2278-6856 3. Finding a spanning tree for Undirected Graph:
To find a spanning tree of a graph, pick an initial node and call it part of the spanning tree do a search from the initial node: each time you find a node that is not in the spanning tree, add to the spanning tree both the new node and the edge you followed to get to it. S is spanning graph because the algorithm ensures that all vertices of G are present. Since the algorithm stops when there is one connected component, the graph G is also connected. Further since we either do not add edges whose vertices already in S, or only add edges from the vertices of one component to the vertices of the other component, cycles are not formed. Hence S is a spanning tree. We now show that the spanning tree formed by this algorithm and the minimum spanning tree formed by this algorithm and the minimum spanning tree(MST) T obtained by any other standard algorithm like Prims or Kruskals have the same weight. Let e1, e2, en be the edges of S as added by the algorithm. Suppose the edge ek = ( u, v ) differs from that in T. Let p be a path between u and v in T and let e be the edge by which u is connected to T. Consider . This will create cycle in T since the algorithm has picked up ek, it means that ek is the edge with the least weight incident on either u or v. without loss of generality let us assume ek is the edge of least weight incident on u. Then wt (e) wt (ek). Therefore, delete from the tree and replace it by ek. Continuing this process we can replace edge that is present in T and not present in S by an edge present in S which is of less than equal to weight. Hence wt(S) wt (T). Since T is minimum spanning tree. Then wt(S) = wt (T), as T is minimum spanning tree weight of S cannot be less than less than the weight of T. Hence S is minimum spanning tree. 3.1 Algorithm Main() 1. Start 2. Input the number of vertices 3. Initialize vsriables Int i, j =0, min, u=0, v=0, components=n 4. Find the edges incident on each vertex that are of minimum weight For(i=0; i<n; i++) findMin(G,i); 5. Build an array of all the vertices connected to vertex 1. buildVisited(0); 6. Components are greater than 1, it means that the minimum spanning tree has not been formed and Volume 3, Issue 1 January February 2014 the least edge between each component must be added to the tree. If the number of components is 1, go to step While (components>1) { min= 99; for (i=0; i<n; i++) { if(visited[i]==1) { for(j=0;j<n;j++) { If (visited[j]==0 && min>G[i][j]) { min = G[i][j]; u = i; v = j; } } } } connect[v][u] = 1; buildVisited(u); } print (weight); } End; findMin() 1) start 2) Initialize the variables int j,min=99,pos=0; 3) Find the minimum edge incident on each vertex and add those edges to the tree for(j=0;j<n;j++) { if(min>X[i][j]) { min = X[i][j]; pos = j; } } connect[i][pos] = 1; } End; buildVisited(u) 1) Start 2) Declare local variables Page 19

International Journal of Emerging Trends & Technology in Computer Science (IJETTCS)


Web Site: www.ijettcs.org Email: editor@ijettcs.org, editorijettcs@gmail.com Volume 3, Issue 1, January February 2014 ISSN 2278-6856
Int I; 3) Set the source vertex u as visited Visited[u]=1 4) For each unvisited vertex connected to the source vertex, connect the least edge, and recursively find the least edge connect to this vertex as the source for(i=0;i<n;i++) { If(connect[i][u] ==1 && visited[i]==0) } Components--; Print(i+ +u) Weight+=g[i][u]; buildVisted(i); } } End; 3.2 Illustration:

4. 4. ACKNOWLEDGEMENTS
My sincere regards to Dr. H. B. Walikar, Professor, Department of Computer Science, Karnatak University, Dharwad, for his valuable suggestions and corrections

Conclusion:
The minimum spanning tree algorithm has been designed and tested to have a complexity of , which is comparable to prims algorithm in its adjacency matrix implementation.

References
[1] Otokar Boruvka. Wikipedia. [2] Ellis Horowitz, Sartaj Sahni, Sanguthevar Rajasekaran: Fundamental of computer algorithms, 2nd Edition, University press, 2007. [3] Thomas H. Cormen, Charles E. Leiserson and Ronald L. Rivest Introduction to Algorithms, PHI, Fourth Printing 2001 [4] Introduction to Design & Analysis of Algorithms - In Simple Way, K. Raghava Rao [5] A.M. Padma reddy Desgin and analysis of algorithms 6th Edition, 2012. [6] H.Nagamochi,"An approximation for finding a smallest 2-Edge connected subgraph containing a specified spanning tree", Discrete Applied Mathematics, 126, pp.83-113,2003. [7] A new approach to find MST(NAFMST), Dr.Ravikumar H. Roogi, IJECT,Vol.4, Issue 3, July Sep 2013

Fig.1

Fig.2

Fig.3

Fig.4 Volume 3, Issue 1 January February 2014 Page 20

You might also like