{"id":22891524,"url":"https://github.com/urbdyn/petgraph-wasm","last_synced_at":"2025-05-07T16:56:29.688Z","repository":{"id":38331830,"uuid":"336564488","full_name":"urbdyn/petgraph-wasm","owner":"urbdyn","description":"A work in progress, selective WASM wrapper around the fantastic petgraph library in Rust.","archived":false,"fork":false,"pushed_at":"2023-02-13T21:57:20.000Z","size":71,"stargazers_count":11,"open_issues_count":12,"forks_count":1,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-04T05:18:48.568Z","etag":null,"topics":["nodejs","petgraph","rust","wasm"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/urbdyn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGE_LOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-06T15:06:53.000Z","updated_at":"2025-04-06T18:01:01.000Z","dependencies_parsed_at":"2023-02-12T06:30:21.533Z","dependency_job_id":null,"html_url":"https://github.com/urbdyn/petgraph-wasm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbdyn%2Fpetgraph-wasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbdyn%2Fpetgraph-wasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbdyn%2Fpetgraph-wasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbdyn%2Fpetgraph-wasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/urbdyn","download_url":"https://codeload.github.com/urbdyn/petgraph-wasm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252921953,"owners_count":21825632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["nodejs","petgraph","rust","wasm"],"created_at":"2024-12-13T22:34:07.432Z","updated_at":"2025-05-07T16:56:29.629Z","avatar_url":"https://github.com/urbdyn.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# petgraph-wasm\n\n[![NPM Version][npm-image]][npm-url]\n\nA work in progress, selective WASM wrapper around the fantastic [petgraph](https://github.com/petgraph/petgraph) library in Rust.\n\nThis project aims to provide a direct port of the petgraph library to an NPM packages which preserves as much of the original API structure and design as possible.\nFor more details please check out the [thoroughly documented petgraph API](https://docs.rs/petgraph/0.5.1/petgraph/).\n\n## Example\n\n```typescript\n// Typescript example\n\nimport {DiGraph, toposort} from 'petgraph-wasm'\n\n// Create new directional graph\nconst g = new DiGraph()\n\n// Add nodes to directional graph\nconst kno_index = g.addNode(\"Knoxville\")\nconst vil_index = g.addNode(\"Vilnius\")\nconst tai_index = g.addNode(\"Taipei\")\n\n// Connect them with edges\ng.addEdge(kno_index,vil_index)\ng.addEdge(kno_index,tai_index)\ng.addEdge(vil_index,tai_index)\n\n// Sort them\nconst sorted_g = toposort(g)\n\n// Detect cycles\ng.addEdge(tai_index,kno_index)\n//   Will throw error!\ntoposort(g)\n```\n\n## Performance\n\nYou should always measure you're exact needs to know how this library will work for you.\nBut here's a few order of magnitude examples as run on a GCP VM with a 2.25GHz AMD EPYC CPU. \nThere are probably overly \"optomistic\" in design as compared to real world needs.\n\n| Action     | Nodes     | Edges      | Time          |\n|------------|-----------|------------|---------------|\n| `toposort` | 10,000    | 9,000      | ~2ms          |\n| `toposort` | 10,000    | 90,000     | ~5ms          |\n| `toposort` | 10,000    | 900,000    | ~20ms         |\n| `toposort` | 100,000   | 99,000     | ~20ms         |\n| `toposort` | 100,000   | 990,000    | ~70ms         |\n| `toposort` | 100,000   | 900,000    | ~600ms        |\n| `toposort` | 1,000,000 | 999,000    | ~350ms        |\n| `toposort` | 1,000,000 | 9,990,000  | ~750ms        |\n| `toposort` | 1,000,000 | 99,900,000 | out-of-memory |\n\n\n## Development\n\nTo work on this you will need to install rust-up and wasm-pack.\n\n```bash\n# Build the npm package\nwasm-pack build --target nodejs\n# Test on node\nwasm-pack test --node\n# Create release build\n./bin/ci.sh\n# Try out benchmark of 100,000 nodes each with 15 edges\ntime ./example_js/benchmark.js 100000 15\n```\n\n[npm-image]: https://img.shields.io/npm/v/@urbdyn/petgraph-wasm.svg\n[npm-url]: https://npmjs.org/package/@urbdyn/petgraph-wasm\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbdyn%2Fpetgraph-wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furbdyn%2Fpetgraph-wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbdyn%2Fpetgraph-wasm/lists"}