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
-1
votes
1 answer

Prevent Cycles in Maximum Spanning Tree

I am trying to create a maximum spanning tree in C++ but am having trouble preventing cycles. The code I have works alright for some cases, but for the majority of cases there is a cycle. I am using an adjacency matrix to find the edges. double…
Tanner
  • 435
  • 6
  • 20
-1
votes
3 answers

Why heap is printing in incorrect order?

I am not sure why my heap method is not printing the heap in the correct order. Can someone tell me what am I doing wrong here? Here is my getHeap method: public static String getHeap(ArrayBasedList edgeList) { // Build the…
-1
votes
1 answer

could someone help clarify this implementation of a Minimum Spanning Tree?

I am currently working on a project for data structures due in a couple days and I do not understand the instructions. We are to make a minimum spanning tree via kruskal's algorithm but also need to implement it using an ArrayBasedList, a heap, up…
-1
votes
1 answer

Calculating the set of computers infected by malware, in a network of communicating computers?

A little backstory: It has been a really long time since I've coded in C (a year. Jumping back into this is really overwhelming. I need some advice on implementation. Could someone could explain how you would go about designing this? I understand…
-1
votes
2 answers

C# timetable show working hours as string like 9:00-13:00; 14:00-18:00

I have a list of objects for each day of week, that store working and not working hours for each day of week. public class Schedule { public bool IsOn { get; set; } public DayOfWeek DayOfWeek { get; set; } public short TimeFrom { get;…
Vladimir Rodchenko
  • 902
  • 10
  • 25
-1
votes
1 answer

awkward behaviour of file reading in c program (SIGSEV signal)

I implemented a program which is supposed to find minimum spanning tree using Prim. The graph's edges are described in a file. So first of all, the program reads this file and stocks edges in a data structure. After that, it runs the algorithm. Here…
codeless
  • 135
  • 3
  • 12
-1
votes
1 answer

find minimum spanning tree using depth first search in C

I'm trying to implement an algorithm in c which finds MST using DFS. I've already found the DFS algortihm and i understand it pretty well. I also know that i should follow these steps to achieve my purpose : 1 Run DFS till you find an edge going…
-1
votes
1 answer

Maximum edge weight in R (igraph)

I have found a minimum spanning tree (MST) of a graph using igraph (minimum.spanning.tree). From this MST I extracted an adjacency matrix with weights. Now I want to get a matrix of the shortest paths in this MST. This is quite easily done using…
-1
votes
1 answer

trouble implementing Brovuka's Algorithm for finding a MST

i dunno why when running the code , there is access violation in the find function in the 1st loop , i am kinda lost , here is my code, if you guys any exisiting brovuka's c++ or java implementation that exists ? #include using namespace…
user3510049
  • 23
  • 1
  • 4
-1
votes
1 answer

Printing out 2d arrays based on rank

For a homework assignment, we were assigned to make spanning trees for each graph, separate them by region and later display their spanning trees in ascending order. I have a function that does breadth-first search to define connected components in…
carriwitchet
  • 111
  • 1
  • 1
  • 8
-1
votes
1 answer

Please help me with Boost Graph Library

I want to use the dense_boruvka_minimum_spanning_tree function in Boost Graph Library, C++. What I want to do is to generate a random graph and then input it into that function to run the Boruvka's algorithm in parallel. Could anybody help me with…
Logan Yang
  • 1,615
  • 5
  • 22
  • 39
-1
votes
1 answer

Finding most effective upper bound for TSP using MST

I'm curious as to what the most effective methods are to find the most optimal (or close to optimal) upper bound for the TSP using a MST. I'm trying to optimize my algorithms for speed, but I'm having trouble algorithmically computing "good"…
Bob John
  • 3,504
  • 14
  • 35
  • 55
-1
votes
2 answers

MST-related algorithm

Given an undirected and connected graph G(V,E) with weight function w:E->R, an edge e(u,v) belongs to E. Which algorithm that runs in linear run-time complexity can assure if there's a minimal spanning tree that contains the edge e?
winuall
  • 339
  • 4
  • 12
-2
votes
1 answer

it's not sorted using "sorted", and getting a wrong answer. And I am not sure if the algorithm is right

I am using Kruskal's Algorithm to find the Minimum Spanning Tree. I just followed the algorithm that has been provided during the lecture and I should keep the format of having Edge class. sorted is not working so I can't figure out if the logic is…
Jassica
  • 119
  • 1
  • 7
-2
votes
1 answer

How to generate 1000 random vertices and edges in Python?

I need to generate 1000 vertices and edges, where the edges have different weights and all the vertices are connected to each other as shown in the image. The output of the code should be represented in numerical values, like (0, 1, 10) <--point 0…
1 2 3
37
38