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)

603 questions
8
votes
2 answers

Find all critical edges of an MST

I have this question from Robert Sedgewick's book on algorithms. Critical edges. An MST edge whose deletion from the graph would cause the MST weight to increase is called a critical edge. Show how to find all critical edges in a graph in time…
Nikunj Banka
  • 11,117
  • 16
  • 74
  • 112
8
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
  • 11,117
  • 16
  • 74
  • 112
8
votes
3 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

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
  • 567
  • 4
  • 12
7
votes
3 answers

Time complexity of Prim's MST Algorithm

Can someone explain to me why is Prim's Algorithm using adjacent matrix result in a time complexity of O(V2)?
6
votes
2 answers

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
  • 562
  • 6
  • 23
6
votes
1 answer

MST that crosses a graph cut exactly N times

Given two connected weighted graphs and a set of pairs of vertices that can "cross the river" between the two graphs, the task is to find an MST (minimum spanning tree) of a graph made of both graphs connected with the crossings that contains…
tomashauser
  • 561
  • 3
  • 16
6
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…
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,526
  • 1
  • 23
  • 32
6
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 = nx.complete_graph(4) for u,v…
ccc
  • 574
  • 2
  • 9
  • 22
6
votes
3 answers

Difference between Boruvka and Kruskal in finding MST

I would like to know the difference between Boruvkas algorithm and Kruskals algorithm. What they have in common: both find the minimum spanning tree (MST) in a undirected graph both add the shortest edge to the existing tree until the MST is…
User12547645
  • 6,955
  • 3
  • 38
  • 69
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
1 2
3
40 41