Disjoint-set data structure: Difference between revisions

Content deleted Content added
Dcoetzee (talk | contribs)
m Rename section
Dcoetzee (talk | contribs)
Line 32:
Initially, we assume that every vertex in the graph is in its own connected component, and is not connected to any other vertex. To represent this, we use '''Make-Set''' to initially make a set for each vertex containing only that vertex.
 
Next, we simply visit each vertex and use '''Union''' to union its set with the sets of all its neighbors. Once this is done, we will have one group for each connected component, and can use '''Find''' to determine which connected component a particular vertex is in, or whether two vertices are in the same connected component.
 
=== Computing shorelines of a terrain ===