Questions tagged [minimum-spanning-tree]

A minimum spanning tree (MST) or minimum weight spanning tree is a spanning tree of a connected, undirected graph with the least possible weight.

A connected, undirected graph can have many different s. We can assign a weight to each edge, which is a number representing how unfavorable it is, and use this to assign a weight to a spanning tree by computing the sum of the weights of the edges in that spanning tree. A minimum spanning tree (MST) or minimum weight spanning tree is then a spanning tree with weight less than or equal to the weight of any other spanning tree. More generally, any undirected graph (not necessarily connected) has a minimum spanning forest, which is a union of minimum spanning trees for its connected components.

One example would be a cable TV company laying cable to a new neighborhood. If it is constrained to bury the cable only along certain paths, then there would be a graph representing which points are connected by those paths. Some of those paths might be more expensive, because they are longer, or require the cable to be buried deeper; these paths would be represented by edges with larger weights. A spanning tree for that graph would be a subset of those paths that has no cycles but still connects to every house. There might be several spanning trees possible. A minimum spanning tree would be one with the lowest total cost.

(Source: Wikipedia)

560 questions
8
votes
2 answers

How to find total number of minimum spanning trees in a graph?

I don't want to find all the minimum spanning trees but I want to know how many of them are there, here is the method I considered: Find one minimum spanning tree using prim's or kruskal's algorithm and then find the weights of all the spanning…
2147483647
  • 1,107
  • 3
  • 12
  • 29
8
votes
2 answers

Complexity of Prims Algorithm using Priority Queue?

I am using an adjacency matrix, priority queue is the data structure. By my calculation, complexity is V^3 log V: While loop: V Checking adjacent Vertices: V Checking the queue if the entry is already present, and updating the same: V log v But, I…
7
votes
2 answers

Implementing Kruskal's algorithm in Ada, not sure where to start

With reference to Kruskal's algorithm in Ada, I'm not sure where to start. I'm trying to think through everything before I actually write the program, but am pretty lost as to what data structures I should be using and how to represent…
7
votes
2 answers

Finding a New Minimum Spanning Tree After a New Edge Was Added to The Graph

Let G = (V, E) be a weighted, connected and undirected graph and let T be a minimum spanning tree. Let e be any edge not in E (and has a weight W(e)). Prove or disprove: T U {e} is an edge set that contains a minimum spanning tree of G' = (V, E U…
7
votes
1 answer

What is a minimum spanning forest?

A minimum spanning tree gives the cheapest way an undirected graph. But what is a minimum spanning forest? Is it defined for connected graphs or unconnected graphs?
Nikunj Banka
  • 10,091
  • 15
  • 68
  • 105
7
votes
1 answer

Algorithm to find minimum spanning tree of chosen vertices

One can use Prim's algorithm or Kruskal's algorithm to find the minimum spanning tree/graph of a collection of vertices/nodes and edges/links. What I want though, is an algorithm that finds the minimum spanning graph of this collection, but the…
Tespa42
  • 547
  • 3
  • 12
6
votes
2 answers

Prims Algorithm Total Running time!

"Thus, the total time for Prim's algorithm is O(V lg V + E lg V) = O(E lg V), which is asymptotically the same as for our implementation of Kruskal's algorithm." From http://serverbob.3x.ro/IA/DDU0137.html But why is O(V lg V + E lg V) = O(E lg V) …
6
votes
1 answer

How to find a "minimal spanning set" for a collection of regular expressions?

CONTEXT: I have a smallish (currently less than 100) but growing collection of Regular Expressions, and I want to optimize the process of determining for a given text string which of the REs in my collection match the text string. Some of the REs…
Peter
  • 2,407
  • 22
  • 31
6
votes
3 answers

finding all minimal spanning trees

Possible Duplicate: All minimum spanning trees implementation How can I find all minimum spanning trees in an undirected graph in an efficient way?
user182513
6
votes
3 answers

Do minimum depth, spanning trees algorithms exist?

I'm currently optimizing electrical grid planning and the MST doesn't solve the problem well, because if the connection to the main grid is in a radial point all the power has to flow through one edge and will travel a long "electrical distance" to…
6
votes
3 answers

Graph Has Two / Three Different Minimal Spanning Trees ?

I'm trying to find an efficient method of detecting whether a given graph G has two different minimal spanning trees. I'm also trying to find a method to check whether it has 3 different minimal spanning trees. The naive solution that I've though…
user975343
5
votes
1 answer

dynamic minimum spanning tree

I want to make a dynamic minimum spanning tree. I have an existing MS tree over n vertices and I add one more vertex and edges to all the existing vertices from this new vertex. How can I update the MST for the new graph efficiently? O(n) would be…
anirudh
  • 552
  • 5
  • 21
5
votes
2 answers

Finding a Minimum Spanning Tree from an Adjacency List where the Adjacency List is in a string array using Prims Algorithm

So I need some help coming up with a way to find a Minimum spanning tree. Suppose I have my graph in the form of an adjacency list: A 2 B 12 I 25 B 3 C 10 H 40 I 8 C 2 D 18 G 55 D 1 E 44 E 2 F 60 G 38 F 0 G 1 H 35 H 1 I 35 The first letter tells…
Steffan Harris
  • 8,105
  • 28
  • 68
  • 98
5
votes
4 answers

Why do we need a priority queue in Prim's Algorithm

As my question speaks I want to know why do we use Priority queue in Prim's Algorithm? How does it saves us from using the naive way (yes I've heard of it but don't know why). I'd be very happy if anyone could explain step by step for adjacency list…
5
votes
3 answers

Networkx: Creating a complete graph for a given set of nodes

I have a list as c4_leaves = [56,78,90,112]. I'm trying to create a complete graph using these elements in c4_leaves as nodes. Here's what I've tried; V_ex = c4_leaves G_ex = nx.Graph() G_ex.add_nodes_from(V_ex) G_ex =…
ccc
  • 534
  • 6
  • 20
1 2
3
37 38