Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

26
LINES

< > BotCompany Repo | #1020414 // Test UnionFind (disjoint-set algorithm) from JGraphT [OK]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 0K of libraries. Click here for Pure Java version (5865L/41K).

!7

lib 1400172 // JGraphT core

import org.jgrapht.alg.util.UnionFind;

static UnionFind<S> union;

p-exp {
  union = new UnionFind(emptySet());
  union.addElement("a");
  printStats();
  union.addElement("b");
  printStats();
  union.union("a", "b");
  union.addElement("c");
  union.addElement("d");
  union.union("c", "d");
  printStats();
  union.union("b", "d");
  printStats();
}

svoid printStats() {
  print("Elements: " + union.size() + ", Sets: " + union.numberOfSets());
}

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: 228 / 651
Version history: 5 change(s)
Referenced in: [show references]