You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -17,9 +18,16 @@ It produces this Minimum Spanning Tree
17
18
- Requires **distinct nodes named with consecutive integers**. If they really **do** have the same "name", convert them to integer ID's to use this algorithm
18
19
Example graph has 8 nodes numbered 1-8 (array ignores the 0th index)
19
20
-**You must hardcode the graph structure in constructor** as a **list of edges**
21
+
-`graphEdges` is **indexed from 1** to make it more human-readable. In the constructor:
`graphEdges.add(new Edge(0, 0, 0));` //adds dummy edge before any actual edges
24
+
**The 0th index is ignored because the loop starts @ 1**
25
+
-`DisjointSet nodeSet = new DisjointSet(nodeCount+1);` also skips the 0th index by creating a Disjoint Set **1 larger than the number of nodes**
20
26
-**Make sure `nodeCount` is accurate**. There's no error checking between `nodeCount` & the actual edge list
27
+
-`outputMessage` is a string that records the steps the algorithm takes. It's printed to the screen & to a file once complete
21
28
- My implementation has **early termination**. If a graph has **N nodes** the MST has **(N-1) edges**
22
29
Hence `&& mstEdges.size()<(nodeCount-1)` in my loop
30
+
- The `Edge` class simply packages an edge's weight & 2 vertices together as 1 object
23
31
24
32
####Sources
25
33
-[Disjoint Sets by Mark Allen Weiss](http://users.cis.fiu.edu/~weiss/dsaajava3/code/DisjSets.java) Author of *Data Structures and Algorithm Analysis in Java (3rd Edition), 2011*
0 commit comments