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
12
votes
2 answers

A fast algorithm for minimum spanning trees when edge lengths are constrained?

Suppose that you have a directed graph with nonnegative, integer edge lengths that are in the range 0 to U - 1, inclusive. What is the fastest algorithm for computing a minimum spanning tree of this graph? We can still use existing minimum…
templatetypedef
  • 328,018
  • 92
  • 813
  • 992
12
votes
2 answers

Will a minimum spanning tree and shortest path tree always share at least one edge?

I'm studying graph theory and I have a question about the connection between minimum spanning trees and shortest path trees. Let G be an undirected, connected graph where all edges are weighted with different costs. Let T be an MST of G and let Ts…
12
votes
2 answers

How to update element priorities in a heap for Prim's Algorithm?

I am studying Prim's Algorithm. There is a part within the code the next vertex across the cut will be coming to the set of the vertices belonging to the MST. While doing that, we also have to 'update all vertices in the other set which are…
11
votes
3 answers

Find whether a minimum spanning tree contains an edge in linear time?

I have the following problem on my homework: Give an O(n+m) algorithm to find that whether an edge e would be a part of the MST of a graph (We are allowed to get help from others on this assignment, so this isn't cheating.) I think that I could do…
noddy
  • 900
  • 2
  • 12
  • 26
11
votes
5 answers

A two way minimum spanning tree of a directed graph

Given a directed graph with weighted edges, what algorithm can be used to give a sub-graph that has minimum weight, but allows movement from any vertex to any other vertex in the graph (under the assumption that paths between any two vertices always…
10
votes
2 answers

The fastest minimum spanning tree algorithm

http://en.wikipedia.org/wiki/Minimum_spanning_tree I'm looking to benchmark my minimum spanning tree algorithm against the best of the best. Does someone know where I can find a C++ implementation of these algorithms? I binged and googled the and…
toto
  • 864
  • 11
  • 20
10
votes
2 answers

Efficient minimal spanning tree in metric space

I have a large set of points (n > 10000 in number) in some metric space (e.g. equipped with Jaccard Distance). I want to connect them with a minimal spanning tree, using the metric as the weight on the edges. Is there an algorithm that runs in…
Yakov Galka
  • 61,035
  • 13
  • 128
  • 192
10
votes
4 answers

Modeling a graph in Python

I'm trying to solve a problem related to graphs in Python. Since its a comeptitive programming problem, I'm not using any other 3rd party packages. The problem presents a graph in the form of a 5 X 5 square grid. A bot is assumed to be at a user…
kaalobaadar
  • 329
  • 1
  • 2
  • 9
9
votes
1 answer

How to calculate minimum spanning tree in R

Given a graph of N vertices and the distance between the edges of the vertices stored in tuple T1 = (d11, d12, …, d1n) to Tn = (dn1, dn2, …, dnn). Find out a minimum spanning tree of this graph starting from the vertex V1. Also, print the total…
Magie
  • 177
  • 9
9
votes
4 answers

Is there a minimum spanning tree that does not contain the min/max weighted edge?

If we have an (arbitrary) connected undirected graph G, whose edges have distinct weights, does every MST of G contains the minimum weighted edge? is there an MST of G that does not contain the maximum weighted edge? Also, I'm more thankful if…
Martin08
  • 19,490
  • 20
  • 80
  • 91
9
votes
5 answers

Faster second-best MST algorithm?

I am struggling with this. We can get MST using Kruskal's algorithm or Prim's algorithm for the MST. And for "second-best" MST, I can: first get MST using either of the algorithm mentioned above. For each V-1 of the optimal edge from the MST: a.…
noooooooob
  • 1,718
  • 2
  • 19
  • 27
9
votes
3 answers

Prim's MST: Does the start node matter?

I intuitively feel that if one is using Prim's algorithm to find a graph's minimum spanning tree, it doesn't matter which root node is picked - the resultant MST will have the same weight regardless. Is this correct?
Nick Heiner
  • 108,809
  • 177
  • 454
  • 689
9
votes
4 answers

Algorithm to find MST in a huge complete graph

Let's assume a complete graph of > 25000 nodes. Each node is essentially a point on a plane. It has 625M edges. Each edge has length which should be stored as a floating point number. I need an algorithm to find its MST (on a usual PC). If I take…
Roman
  • 59,060
  • 84
  • 230
  • 322
8
votes
1 answer

Determine if a given weighted graph has unique MST

I'm looking for an algorithm (or any other way) to determine if a given weighted graph has unique MST (Minimum spanning tree) in O(ElogV)? I don't know anything about the weights (e.g. weight(e1) != weight(e2)), and the algorithm just return True if…
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
  • 10,091
  • 15
  • 68
  • 105
1
2
3
37 38