Download Jar. Uses 0K of libraries. Click here for Pure Java version (5865L/41K).
1 | !7 |
2 | |
3 | lib 1400172 // JGraphT core |
4 | |
5 | import org.jgrapht.alg.util.UnionFind; |
6 | |
7 | static UnionFind<S> union; |
8 | |
9 | p-exp { |
10 | union = new UnionFind(emptySet()); |
11 | union.addElement("a"); |
12 | printStats(); |
13 | union.addElement("b"); |
14 | printStats(); |
15 | union.union("a", "b"); |
16 | union.addElement("c"); |
17 | union.addElement("d"); |
18 | union.union("c", "d"); |
19 | printStats(); |
20 | union.union("b", "d"); |
21 | printStats(); |
22 | } |
23 | |
24 | svoid printStats() { |
25 | print("Elements: " + union.size() + ", Sets: " + union.numberOfSets()); |
26 | } |
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1020414 |
Snippet name: | Test UnionFind (disjoint-set algorithm) from JGraphT [OK] |
Eternal ID of this version: | #1020414/6 |
Text MD5: | f0a792efd7ba88088acbc41087b9a2dd |
Transpilation MD5: | 095a2c57f20fd7c43a3a990da374ae05 |
Author: | stefan |
Category: | javax / graphs |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-12-20 14:45:46 |
Source code size: | 509 bytes / 26 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 356 / 1009 |
Version history: | 5 change(s) |
Referenced in: | [show references] |