MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / union

Method union

JSAT/src/jsat/utils/UnionFind.java:56–72  ·  view source on GitHub ↗
(UnionFind<X> y)

Source from the content-addressed store, hash-verified

54 }
55
56 public void union(UnionFind<X> y)
57 {
58 UnionFind<X> xRoot = this.find();
59 UnionFind<X> yRoot = y.find();
60 if (xRoot == yRoot)
61 return; // x and y are not already in same set. Merge them.
62
63 if (xRoot.rank < yRoot.rank)
64 xRoot.parent = yRoot;
65 else if (xRoot.rank > yRoot.rank)
66 yRoot.parent = xRoot;
67 else
68 {
69 yRoot.parent = xRoot;
70 xRoot.rank = xRoot.rank + 1;
71 }
72 }
73
74}

Callers

nothing calls this directly

Calls 1

findMethod · 0.95

Tested by

no test coverage detected