{"name":"union-find","version":"0.0.4","description":"A union-find data structure for maintaining disjoint sets.","main":"index.js","repository":{"type":"git","url":"git://github.com/mikolalysenko/union-find.git"},"keywords":["union","find","link","disjoint","set","connected","component","graph"],"author":{"name":"Mikola Lysenko"},"license":"MIT","gitHead":"8fbd75feecd9d7154f4c2ff21754f483ad07ccab","_id":"union-find@0.0.4","dist":{"shasum":"b854b3301619bdad144b0014c78f96eac0d2f0f6","tarball":"http://registry-npm.ywwl.com/union-find/download/union-find-0.0.4.tgz","integrity":"sha512-207oken6EyGDCBK5l/LTPsWfgy8N8s6idwRK2TG0ssWhzPlxEDdBA8nIV+eLbkEMdA8pAwE8F7/xwv2sCESVjQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDclW/E43amwZT7pk7ZVCDCn93xkr2aM9m1aZbKvcKUOgIgUszmMm1xGwD0SCY0ln8Z1wTrECBzWrdlsZ126cavGU4="}],"size":1487,"noattachment":false,"key":"/union-find/-/union-find-0.0.4.tgz"},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"directories":{},"readme":"union-find\n==========\n\nA basic union-find data structure for node.js.  For more information, see wikipdia:\n\n[Disjoint Set Datastructures](http://en.wikipedia.org/wiki/Disjoint-set_data_structure)\n\nUnion find data structures solve the incremental connectivity problem. (That is maintaining a spanning forest under incremental insertions of edges.)  To handle fully dynamic connectivity, you can use a [dynamic forest](https://www.npmjs.org/package/dynamic-forest) data structure.\n\nUsage\n=====\nHere is an example showing how to do connected component labelling.  Assume we are given a graph with `VERTEX_COUNT` vertices and a list of edges stored in array represented by pairs of vertex indices:\n\n```javascript\n//Import data structure\nvar UnionFind = require('union-find')\n\nvar VERTEX_COUNT = 8\nvar edges = [\n    [0,1],\n    [1,2],\n    [2,3],\n    [5,6],\n    [7,1]\n]\n\n//Link all the nodes together\nvar forest = new UnionFind(VERTEX_COUNT)\nfor(var i=0; i<edges.length; ++i) {\n  forest.link(edges[i][0], edges[i][1])\n}\n\n//Label components\nvar labels = new Array(VERTEX_COUNT)\nfor(var i=0; i<VERTEX_COUNT; ++i) {\n  labels[i] = forest.find(i)\n}\n```\n\nInstallation\n============\n\n```\nnpm install union-find\n```\n\n# API\n\n```javascript\nvar UnionFind = require('union-find')\n```\n\n## Constructor\n\n### `var forest = new UnionFind(numVertices)`\nCreates a new union-find data structure.\n\n* `numVertices` is the number of vertices in the graph\n\n**Returns** A new union-find data structure\n\n## Methods\n\n### `forest.length`\nReturns the number of vertices in the forest\n\n### `forest.makeSet()`\nCreates a new vertex\n\n**Returns** An integer id for the new vertex\n\n### `forest.find(v)`\nReturns an identifier representing the connected component of any given vertex\n\n**Returns** An integer id representing the connected component of `v`\n\n### `forest.link(s, t)`\nLinks a pair of connected components together\n\n* `s` and `t` are both vertices\n    \nCredits\n=======\n(c) 2013-2014 Mikola Lysenko.  MIT License","publish_time":1364781973884,"_cnpm_publish_time":1364781973884,"dist-tags":{"latest":"1.0.2"}}