minimum-spanning-tree

How to update MST after deleting an edge from the graph?

被刻印的时光 ゝ 提交于 2019-12-12 08:59:12
问题 I have a graph represented with adjacency lists and his MST represented by parent array. My problem is that I need to delete an edge from the graph and update parent array. I've already manage to do the cases when: the edge doesn't exist; the edge is in graph but not in MST (MST doesn't change); and the edge is the only path from two nodes(in this case I return null, because the graph is not connected). What can I do when the edge is in MST and the edge in graph is in a cycle? I need to do

Find a minimum spanning tree

南笙酒味 提交于 2019-12-11 19:51:23
问题 Could you please tell me why this MATLAB code is wrong? I don't understand why. Thank you so much in advance. function [mst, cost] = prim(A) [n,n] = size(A); A, n, pause, if norm(A-A','fro') ~= 0 , disp(' Error: Adjacency matrix must be symmetric ') return, end; intree = [1]; number_in_tree = 1; number_of_edges = 0; notintree = [2:n]'; number_notin_tree= n-1; in = intree(1:number_in_tree), out = notintree(1:number_notin_tree), pause, while number_in_tree < n, mincost = Inf; for i=1:number_in

Jgraph: General Traversal & Forest Traversal

我的未来我决定 提交于 2019-12-11 06:02:23
问题 Good morning/afternoon/evening. So our data structures course gave us an assignment to segment a grayscale image in java using the following algorithm: Input: A gray-scale image with P pixels and number R Output: An image segmented into R regions 1. Map the image onto a primal weighted graph. 2. Find an MST of the graph. 3. Cut the MST at the R – 1 most costly edges. 4. Assign the average tree vertex weight to each vertex in each tree in the forest 5. Map the partition onto a segmentation

pre-order traversal of a Minimum spanning tree

╄→гoц情女王★ 提交于 2019-12-11 03:01:44
问题 Is there any way to print the pre-order traversal of the output given by MST (using Kruskal or Prim's algorithm). I have a confusion because the output may be or not a binary tree always. So, how the pre-order traversal is possible here? Can a normal DFS do the task? 回答1: The main issue when working with this kind of problem is the ambiguity of the word tree in algorithmic problems. There are two main definitions (those may in fact differ slightly): A tree is an acyclic connected (undirected)

Find a spanning tree with maximum number of edges with same weight

久未见 提交于 2019-12-11 02:08:53
问题 Here's the problem. A weighted undirected connected graph G is given. The weights are constant. The task is to come up with an algorithm that would find the total weight of a spanning tree for G that fulfills these two conditions ( ordered by priority ): The spanning tree has to have maximum number of edges with the same weight (the actual repeated weight value is irrelevant); The total spanning tree weight should be minimized. That means, for example, that the spanning tree T1 with weight

Network X , which depth searching option to select for this use?

北城以北 提交于 2019-12-10 11:45:56
问题 I am trying to ensure a global correct orientation of my normals. I.e make sure they point outwards everywhere. This is my method: I have a coordinate list x y c n . At each point in coordinate list I create edges from the point to its 5 nearest neighbours. I Weight each edge with ( 1-n1.n2 ). Compute a minimal spanning tree. Traverse this tree in depth first order. Start traversing at the point with the greatest z value, force the normal of this point to be orientated towards the positive z

Optimal distribution of power plants on a city

China☆狼群 提交于 2019-12-10 11:19:23
问题 I've searched both Google and Stack Overflow for an answer to my problem but I can't find one. I need to find the optimal distribution for the power network of a city. The city is represented by a connected graph. I want to distribute power plants among some of those nodes in order to cover all of them in the electrical grid. The problem being that every power plant has a certain "range" (it can only cover for example in a "radius" of two nodes). My program needs to find the minimum number of

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

大城市里の小女人 提交于 2019-12-09 04:39:36
问题 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 adjacent to the departing vertex'. This is a snapshot from CLRS : The interesting part lies in line no. 11. But since we are using a heap here, we have access to only the minimum element, right ( heap[0] )? So how do we search and update vertices from the

Use Dijkstra's to find a Minimum Spanning Tree?

牧云@^-^@ 提交于 2019-12-09 02:36:35
问题 Dijkstra's is typically used to find the shortest distance between two nodes in a graph. Can it be used to find a minimum spanning tree? If so, how? Edit: This isn't homework, but I am trying to understand a question on an old practice exam. 回答1: Strictly, the answer is no. Dijkstra's algorithm finds the shortest path between 2 vertices on a graph. However, a very small change to the algorithm produces another algorithm which does efficiently produce an MST. The Algorithm Design Manual is the

Correlation Network Implementation

感情迁移 提交于 2019-12-08 07:00:18
问题 I have been working on my graph/network problem, and I think I finally know what I want to do. Now that I am getting into the implementation, I am having issues deciding what libraries to use. The graph itself is pretty simple, each node is labeled by a string, and each each is a probability/correlation coefficient between the two nodes(variables), and is undirected. The operations that I want to perform on the graph are: Inserting new nodes/edges (fast) Finding the all pairs shortest (1