{"id":38539648,"url":"https://github.com/xyflow/node-collision-algorithms","last_synced_at":"2026-01-17T07:08:07.376Z","repository":{"id":322840446,"uuid":"1091062626","full_name":"xyflow/node-collision-algorithms","owner":"xyflow","description":"Testing various algorithms for resolving node overlaps in a flow","archived":false,"fork":false,"pushed_at":"2025-11-26T14:47:07.000Z","size":1576,"stargazers_count":6,"open_issues_count":11,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-28T17:19:26.879Z","etag":null,"topics":["graph-algorithms","node-based-ui","react-flow","svelte-flow"],"latest_commit_sha":null,"homepage":"https://node-collision-algorithms.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xyflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-06T14:03:55.000Z","updated_at":"2025-11-26T14:47:10.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/xyflow/node-collision-algorithms","commit_stats":null,"previous_names":["xyflow/node-collision-algorithms"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xyflow/node-collision-algorithms","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyflow%2Fnode-collision-algorithms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyflow%2Fnode-collision-algorithms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyflow%2Fnode-collision-algorithms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyflow%2Fnode-collision-algorithms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xyflow","download_url":"https://codeload.github.com/xyflow/node-collision-algorithms/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyflow%2Fnode-collision-algorithms/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28503061,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graph-algorithms","node-based-ui","react-flow","svelte-flow"],"created_at":"2026-01-17T07:08:07.231Z","updated_at":"2026-01-17T07:08:07.355Z","avatar_url":"https://github.com/xyflow.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node Collision Algorithms\n\nA playground to explore, develop, and benchmark algorithms that resolve overlapping nodes in the browser. Although the primary use cases are [React Flow](https://reactflow.dev/) \u0026 [Svelte Flow](https://svelteflow.dev/), the implementations aim to be use‑case agnostic.\n\n\u003e [!NOTE]\n\u003e _Fiddle with the [demo](https://xyflow.com/node-collisions) or read our [blog post](https://xyflow.com/blog/node-collision-detection-algorithms)._\n\n### Features\n\n- **Playground** for comparing and developing algorithms \u0026 datasets using [SvelteKit](https://github.com/sveltejs/kit), [shadcn-svelte](https://github.com/huntabyte/shadcn-svelte) \u0026 [Svelte Flow](https://github.com/xyflow/xyflow)\n- **WebAssembly Toolchain via Rust** to easily test out non-Javascript solutions using [wasm-bindgen](https://github.com/wasm-bindgen/wasm-bindgen) \u0026 [binaryen](https://github.com/WebAssembly/binaryen)\n- **Benchmark** for comparing the performance on different datasets using [Vitest](https://github.com/vitest-dev/vitest) \u0026 [tinybench](https://github.com/tinylibs/tinybench)\n\n![Title](static/title.gif)\n\n### Algorithms\n\nEach algorithm implements the same [`CollisionAlgorithm`](src/lib/algorithms/index.ts) interface (nodes in, nodes out) but uses different strategies for collision detection.\n\n- **[Naive](src/lib/algorithms/naive.ts)**: Simple nested loop checking all node pairs - O(n²) complexity\n- **[NaiveWasm](src/lib/algorithms/naiveWasm.ts)**: Same as the JS version, except [SoA instead of AoS](https://en.wikipedia.org/wiki/AoS_and_SoA)\n\n#### Using different spatial index implementations\n\n- **[Rbush](src/lib/algorithms/rbush.ts)**: R-tree based spatial index using [rbush](https://github.com/mourner/rbush) library with bulk insert mode\n- **[RbushReplace](src/lib/algorithms/rbushReplace.ts)**: [rbush](https://github.com/mourner/rbush) library with updating single nodes\n- **[Flatbush](src/lib/algorithms/flatbush.ts)**: Memory-efficient flat and static R-tree implementation using [flatbush](https://github.com/mourner/flatbush) (bulk insert)\n- **[GeoIndex](src/lib/algorithms/geoIndex.ts)**: Rust based R-tree index with same data structure as flatbush using [geo-index](https://github.com/kylebarron/geo-index) (bulk insert)\n- **[Quadtree](src/lib/algorithms/quadtree.ts)**: Recursive spatial partitioning into quadrants for fast lookups using [quadtree-ts](https://github.com/timohausmann/quadtree-js) (bulk insert)\n\n## Benchmark Results\n\n\u003e [!IMPORTANT]  \n\u003e _Every benchmark is incomplete and flawed. Always expect mistakes, either in the implementation, the test environment, or in the method of measurement._\n\nThere are outstanding optimizations to be done to better leverage spatial indexes and further reduce overhead. Check out the [issues tab](https://github.com/xyflow/node-collision-algorithms/issues) if you are interested.\n\n### Packed\n\nNodes are positioned in a dense grid with maximum overlap. This scenario stresses algorithms with many collision pairs.\n\n![Packed benchmark results](static/benchmarks/packed.png)\n\n### Separated\n\nNodes are spaced apart with no overlaps. This tests the best-case scenario where algorithms can early-exit without collision resolution.\n\n![Separated benchmark results](static/benchmarks/separated.png)\n\n### Clustered\n\nNodes form several clusters with overlaps within each cluster. This represents a realistic use case with localized collision groups.\n\n![Clustered benchmark results](static/benchmarks/clustered.png)\n\n## Running the project\n\n### Prerequisites\n\n1. **Rust/Rustup** (required to build WebAssembly algorithms)\n\n```bash\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n```\n\n2. **Binaryen** (required for WASM optimization)\n\n```bash\n# macOS\nbrew install binaryen\n\n# Debian/Ubuntu\nsudo apt install binaryen\n\n# Arch Linux\nsudo pacman -S binaryen\n```\n\n3. **Node.js** (v22 or higher)\n\n4. **pnpm**\n\n```bash\nnpm install -g pnpm\n```\n\n### Installation\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/xyflow/node-collision-algorithms.git\ncd node-collision-algorithms\n```\n\n2. Install dependencies:\n\n```bash\npnpm install\n```\n\n3. Build WebAssembly modules:\n\n```bash\npnpm run build:wasm\n```\n\n4. Start the development server:\n\n```bash\npnpm run dev\n```\n\nThe application will be available at `http://localhost:5173`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxyflow%2Fnode-collision-algorithms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxyflow%2Fnode-collision-algorithms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxyflow%2Fnode-collision-algorithms/lists"}