My DS Teacher told us to implement Minimum Spanning Tree, Prim's Algorithm and Kruskal's "MST" algorithm?

So I'm a 2nd year SW Engineering student, and I think my Data Structure professor is an idiot, or I'm an idiot.

So the professor gave us a homework to implement Minimum Spanning Tree, Prim's MST Algorithm and Kruskal's Algorithm. I asked the professor whether they meant implementing Minimum Spanning Tree using Prims and Kruskal's. The professor told me that I have to do all three of them. I just implemented the two.

We were also told that MST and Djkastra are the same thing, even though on the same slide that we got it states that MST might not necessarily find the shortest path between nodes.

But we learned BFS and DFS perfectly. Also the professor tried to teach us about Red Black Tree and tried to show us the visualization but couldn't explain what was happening and just left it at that. The next week the professor came and told us that we should have googled it. (I think I'm at a bad university, or am i just feeling entitled by thinking that th professor should actually explain the topics? IDK!)

The prof also explained Hash Tables in 2 minutes.

Anyways, I could get all of that from YouTube. But I'm still mad that the professor isn't getting ready for a class, and that is expecting us to do all the work while also telling us that they did all the work.

Rant Over!

πŸ‘︎ 21
πŸ’¬︎
πŸ‘€︎ u/Ok_Perspective599
πŸ“…︎ Dec 27 2021
🚨︎ report
Minimum Spanning Tree Prim vs Kruskal?

Do the Prim’s algorithm and the Kruskal’s algorithm always obtain the same minimum spanning tree (MST) on a given input graph?

I have tried drawing a bunch of graphs with non-unique edges and executing both algorithms (for Prim, I tried every different starting node) and always end up with the same MST as Kruskal.

πŸ‘︎ 39
πŸ’¬︎
πŸ“…︎ Nov 30 2021
🚨︎ report
Finding minimum spanning tree with Prim's algorithm in matlab

So hello guys, i have a task where i need to find minimum spanning tree using Prim's algorithm in matlab, but i kind a have no idea where to start. And btw teachers didn't really taught us how to use matlab XD. So maybe any idea where to start with the task?

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/tautwelio
πŸ“…︎ Nov 19 2021
🚨︎ report
[Help] What frameworks or languages can I use to iteratively visualize Minimum spanning tree?

I want to iteratively visualize MST. I am looking for JS frameworks or languages combination which I can employ for this task? One option I found from my research is to use D3.js for this task?

Are there any other options which might be more adaptable to customized user input or be more easier/ intuitive to implement?

Any suggestions are greatly appreciated :)

πŸ‘︎ 5
πŸ’¬︎
πŸ“…︎ Sep 27 2021
🚨︎ report
Minimum Spanning Tree Problem

I have a problem that involves finding the minimum spanning tree. It is a picture and can't be done in a text. If someone if willing to help can you send me a message?

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Petedoug85
πŸ“…︎ Apr 09 2021
🚨︎ report
Phase unwrapping with a rapid opensource minimum spanning tree algorithm (ROMEO) onlinelibrary.wiley.com/d…
πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/NicNic8
πŸ“…︎ Apr 08 2021
🚨︎ report
Coupling Cellular Automaton and Prim's minimum spanning tree algorithm to generate levels in our Rogue-Lite game
πŸ‘︎ 24
πŸ’¬︎
πŸ‘€︎ u/MoltonStudio
πŸ“…︎ Oct 05 2020
🚨︎ report
Does the transitive property not work for any vertex in a minimum spanning tree?

For instance, for any vertices a, b, and c, if (a, b) is a direct path in E, and (b, c) is a direct path in E, then there is never a case where (a, c) is in E. This seems to be the case but I’m not sure if there’s a formal proof to this, or if it’s just part of the definition of spanning trees.

πŸ‘︎ 16
πŸ’¬︎
πŸ“…︎ Mar 28 2020
🚨︎ report
Procedural Alphabet using a minimum-spanning tree of random nodes
ArrayList<PVector> nodes = new ArrayList<PVector>();
ArrayList<PVector> reached = new ArrayList<PVector>();
ArrayList<PVector> unreached = new ArrayList<PVector>();
int nodeCount;
float nodeSize;
float gridSize;
float cellBuffer;
int rowCount;

void setup() {
  size(500, 500);
  background(255);
  rowCount = 7;
  gridSize = width / rowCount;
  cellBuffer = gridSize * 0.1;
  float left, top;

  for (int j = 0; j < rowCount; j++) {
    for (int i = 0; i < rowCount; i++) {
      nodes.clear();
      left = i * gridSize;
      top = j * gridSize;
      stroke(127,64);
      strokeWeight(1);
      rect(left, top, gridSize, gridSize);
      nodeCount = int(random(4,8));
      for (int k = 0; k < nodeCount; k++) {
        PVector n = new PVector(random(left + cellBuffer, left + gridSize - cellBuffer), random(top + cellBuffer, top + gridSize - cellBuffer));
        nodes.add(n);
      }
      ConnectNodes();
    }
  }
}

void ConnectNodes() {
  stroke(0);
  strokeWeight(4);
  unreached.clear();
  reached.clear();

  for (PVector n : nodes) {
    unreached.add(n);
  }

  reached.add(unreached.get(0));
  unreached.remove(0);

  while (!unreached.isEmpty()) {
    float record = 99999;
    int n1 = 0, n2 = 0;

    for (PVector n : reached) {
      for (PVector m : unreached) {
        float d = dist(n.x, n.y, m.x, m.y);
        if (d < record) {
          record = d;
          n1 = reached.indexOf(n);
          n2 = unreached.indexOf(m);
        }
      }
    }

    line(reached.get(n1).x, reached.get(n1).y, unreached.get(n2).x, unreached.get(n2).y);

    reached.add(unreached.get(n2));
    unreached.remove(n2);
  }
}
πŸ‘︎ 7
πŸ’¬︎
πŸ‘€︎ u/thudly
πŸ“…︎ Dec 05 2019
🚨︎ report
Looking for minimum spanning tree be like
πŸ‘︎ 39
πŸ’¬︎
πŸ‘€︎ u/asianNakahata
πŸ“…︎ Feb 27 2020
🚨︎ report
Minimum Spanning Tree total weight vs. All pairs shortest paths total weight

Suppose you have a graph with multiple edges of the same weight. In this case, there is more than one minimum spanning tree.

An algorithm like Kruskal's would simply return an arbitrary MST from the set of valid MSTs.

Are there applications where you might want an algorithm to output a minimum spanning tree that also satisfies another constraint compared to the other minimum spanning trees? Does that application also overlap with use cases where there are likely to be edges with the same weight (or at least valid reasons to truncate/estimate weights so that they are likely to be the same)? The constraint I have in mind is the total weight of all shortest paths between all pairs of vertices a la Floyd-Warshall algorithm.

πŸ‘︎ 11
πŸ’¬︎
πŸ‘€︎ u/psdanielxu
πŸ“…︎ May 16 2019
🚨︎ report
TIP a visualization for Kruskal's algorithm for finding a Minimum Spanning Tree

It's a simple visualization made using vanilla Javascript with 2d canvas. I originally made this for a different project that required finding the MST of a graph as an approximation to an NP problem.

While debugging my code, i made a simple visualization that felt like a shame to get rid of after I ditched the project, so I polished it a bit, and put it up on Github Pages, for your viewing enjoyment: https://sebastianmestre.github.io/kruskal-viz/

πŸ‘︎ 10
πŸ’¬︎
πŸ‘€︎ u/sebamestre
πŸ“…︎ Oct 08 2019
🚨︎ report
Prim's algorithm to find the minimum spanning tree of graph twitter.com/Quantum_36/st…
πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Quantum_Duck34
πŸ“…︎ Jun 21 2019
🚨︎ report
Algorithm that will return the path between two nodes in a minimum spanning tree?

I have a minimum spanning tree created using Kruskal's algorithm stored in a map of key:string and data:set(string)

mst = { "A" : ["B"]
        "B" : ["A", "C", "D"]
        "C" : ["B"]
        "D" : ["B", "E"]
        "E" : ["D", "F"] }

I am trying to write an algorithm that will return the path between a specified start and end node

$ findPath A F
> A B D E F

$ findPath F C
> F E D B C

I think I should use some kind of modified depth first search but I am not sure how to implement the algorithm or how to store the nodes that form the path. I don't believe I have to worry about marking nodes as "visited" since there are no cycles in a MST.

Is there an algorithm for this already that I haven't been able to find/how would I make one myself?

How can I go about this?

πŸ‘︎ 10
πŸ’¬︎
πŸ‘€︎ u/Bolcik
πŸ“…︎ Dec 12 2018
🚨︎ report
Which minimum spanning tree algorithm is easier to code or Kruskal or Prim?

I have a variant of the travelling salesman problem and I want to construct the minimum spanning tree to use as a heuristic i.e like Christofide's algorithm (https://en.wikipedia.org/wiki/Christofides_algorithm). Is Kruskal or Prim generally considered easier to code? It looks like Prim may be more efficient for dense graphs and Kruskal uses something called disjoint sets.

UPDATE:

I ended up using Prim's as described on Wikipedia. If anyone's curious I'm using AStar for the travelling salesman problem. It turns out using the sum of the edges of the minimum spanning tree is a very effective heuristic and pretty easy to implement.

Using what seems like a pretty good heuristic 'number of unvisited cities' my algorithm had a running time of 6.5 seconds on a toy example and expanded about 500,000 nodes. Using the cost of the minimum spanning tree it had a running time of about 0.1 seconds and expanded less than 1,000 nodes.

πŸ‘︎ 13
πŸ’¬︎
πŸ‘€︎ u/Dhxbxnxx
πŸ“…︎ Mar 10 2017
🚨︎ report
[14/04/2014] Challenge #152 [Hard] Minimum Spanning Tree

(Hard): Minimum Spanning Tree

First, a bit of back story. In graph theory, a graph is a set of points called vertices, joined up by lines or edges. Those edges can have a number called weight associated with them, which would represent distance, cost, or whatever you like. It's an abstract idea and is usually used for modeling real-world situations such as a neighborhood, a network of computers or a set of steps. A spanning tree is a subgraph (a graph deriving from another one) that connects all of the vertices of the parent graph.
This means several things:

  • A spanning tree must contain every vertex of G - but not necessarily every edge.
  • Because it's a tree, it must not have any loops or cycles - that is, it must have no closed shapes within it.
  • You must only use edges from the original graph to form the spanning tree.
  • The tree must be connected. This means all the edges must be joined in some way. This is illustrated with an example below.

Here are some examples to illustrate this concept. Take this graph G.
Here is one possible spanning tree. Note there may be (and probably will be) more than one valid spanning tree for a given graph. Here are some examples of invalid spanning trees, for several reasons:

Because representing graphs visually like this makes it complicated to do computations with them, you can represent graphs as a matrix instead, such as this one. This is called a distance matrix because it shows you the distances between any two vertices - like those distance charts you find at the back of diaries. (These are very similar to adjacency matrices, except they show the weight of the connecting edges rather than just its existence.) Note how it is symmetric along the diagonal. A dash (-) means there is no edge connecting those two vertices.

Your challenge is, given any (non-directional) graph in matrix form as shown above, to find the minimum spanning tree. This is the spanning tree with the smallest possible sum dista

... keep reading on reddit ➑

πŸ‘︎ 69
πŸ’¬︎
πŸ‘€︎ u/Elite6809
πŸ“…︎ Mar 13 2014
🚨︎ report
Minimum Spanning Tree #1: Kruskal Algorithm youtube.com/watch?v=5xosH…
πŸ‘︎ 6
πŸ’¬︎
πŸ‘€︎ u/fonderkarma113
πŸ“…︎ Mar 10 2019
🚨︎ report
Anyone in cs112 and want to talk about the assignment? Minimum Spanning Tree (MST)

Anyone else having trouble with this assignment? http://www.cs.rutgers.edu/courses/112/classes/fall_2015_venugopal/progs/prog5/prog5.html

I have asked some of my upper level cs friends for help and they told me it was strange .

Anyone have any advice for this? So far I'm struggling to even get it functioning ...and I consider myself a decent programer averaging within 10 points of the top score on the other assignments so far.

πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/good4y0u
πŸ“…︎ Dec 02 2015
🚨︎ report
When is a Minimum Spanning Tree Unique?

It doesn't say anywhere online so this is the first place I could think of.

πŸ‘︎ 10
πŸ’¬︎
πŸ‘€︎ u/Azehnuu
πŸ“…︎ Jun 12 2017
🚨︎ report
Finding a Minimum Spanning Tree: Prim's Algorithm blog.mousereeve.com/findi…
πŸ‘︎ 27
πŸ’¬︎
πŸ‘€︎ u/bemmu
πŸ“…︎ Aug 20 2016
🚨︎ report
Finding the minimum spanning tree on a grid graph

Are there any MST algorithms, which have a better complexity, if the graph is a 4-connected grid graph?

πŸ‘︎ 7
πŸ’¬︎
πŸ‘€︎ u/jjiiijj
πŸ“…︎ Jan 05 2015
🚨︎ report
Datasets for clustering with Minimum Spanning Tree

I have came across the idea of Minimum Spanning Tree recently and found out that it has an application in clustering. I'm looking for a real-world dataset (preferably clean) that can be used as data source for various clustering algorithms. There's an information that MST clustering works good enough on spherical and non-spherical data. This is why non-spherical datasets are sought after as well.

EDIT: Datasets that I have in mind should contain ground truth info (labels) so the effectiveness of various algos can be measured by something different than WSS.

#posted also in r/datascience/

πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/balkon16
πŸ“…︎ Jun 12 2018
🚨︎ report
Minimum Spanning Tree with edge weight

I am having some troubles solving a problem about Minimum Spanning Tree. So each node in a graph is a city, and is possible to have weight edges connecting two nodes, which is the cost of building a road between two cities. The problem is basically telling the minimum cost of building the roads and have all cities connected some way. I can easily solve this by using Prim or Kruskal algorithm to solve this sub-problem of my biggest problem.

The tricky part comes now: Each city (node) can have an airport and each airport has a one time cost (if you decide to build it). You can travel between two cities using an airport if both cities have airports. Now I have to calculate the minimum cost of building roads AND airports in order to have all cities connected, but I am having difficulty representing the connections with the airports with the rest of the network. Can somebody help me here? Maybe I am completely wrong about using MST?

The only solution I came up is: For each city that has an airport, I will connect that city with another cities that have airports. Also If the cost of building two airports is lower then building a road I take it in consideration. I run Kruskal in order to get the cheapest edge, but If Kruskal chooses an "airport" edge, I will add it to the spanning tree and then 0 the cost of both airports (if they havent been built in the past). I believe, that by doing this dynamic weight changes while runing kruskal, I am destroying the idea of getting the minimum cost.

πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/DanielAPO
πŸ“…︎ Apr 30 2017
🚨︎ report
Finding minimum spanning tree with Prim's algorithm in matlab

So hello guys, i have a task where i need to find minimum spanning tree using Prim's algorithm in matlab, but i kind a have no idea where to start. And btw teachers didn't really taught us how to use matlab XD. So maybe any idea where to start with the task?

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/tautwelio
πŸ“…︎ Nov 19 2021
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.