{"id":13432564,"url":"https://github.com/fkling/JSNetworkX","last_synced_at":"2025-03-17T09:31:33.000Z","repository":{"id":2953032,"uuid":"3966929","full_name":"fkling/JSNetworkX","owner":"fkling","description":"Build, process and analyze graphs in JavaScript (port of NetworkX)","archived":false,"fork":false,"pushed_at":"2024-02-22T04:38:26.000Z","size":2534,"stargazers_count":773,"open_issues_count":43,"forks_count":182,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-03-10T17:01:50.248Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://felix-kling.de/jsnetworkx/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fkling.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2012-04-08T21:09:47.000Z","updated_at":"2025-03-01T06:14:46.000Z","dependencies_parsed_at":"2024-06-12T18:14:44.365Z","dependency_job_id":"8d673fb3-2e1d-4a13-b2ff-1498ca3a2018","html_url":"https://github.com/fkling/JSNetworkX","commit_stats":{"total_commits":218,"total_committers":5,"mean_commits":43.6,"dds":"0.022935779816513735","last_synced_commit":"6854f88d9f0bb98fa951cb20ce13eb497f204274"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkling%2FJSNetworkX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkling%2FJSNetworkX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkling%2FJSNetworkX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkling%2FJSNetworkX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fkling","download_url":"https://codeload.github.com/fkling/JSNetworkX/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244009086,"owners_count":20382968,"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":[],"created_at":"2024-07-31T02:01:13.448Z","updated_at":"2025-03-17T09:31:32.560Z","avatar_url":"https://github.com/fkling.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# JSNetworkX [![Build Status](https://travis-ci.org/fkling/JSNetworkX.svg?branch=es6_WIP)](https://travis-ci.org/fkling/JSNetworkX)\n\nJSNetworkX allows you to build, process and analyze graphs in JavaScript. It\ncan be used together with D3.js in the browser to create interactive graph\nvisualizations.\n\nIt is a port of [NetworkX](http://networkx.lanl.gov/) (v1.6), a\npopular graph library for Python, to JavaScript. Extensive information can\nbe found on:\n\n- the [website][]\n- the [API documentation][api]\n- the [wiki][]\n\n## Install\n\n### Node.js\n\nInstall from [npm][]:\n\n```\nnpm install jsnetworkx\n```\n\n### Browser\n\nDownload [jsnetworkx.js](./jsnetworkx.js) and include it in your page with\n\n```\n\u003cscript src=\"/path/to/jsnetworkx.js\"\u003e\u003c/script\u003e\n```\n\nThis will create the global variable `jsnx`, with which all functions can be\naccessed.\n\n## Usage\n\nJSNetworkX consists of multiple parts which work closely together:\n\n- Graph classes (`Graph`, `DiGraph`, `MultiGraph` and `MultiDiGraph`) to model\n  the data\n- Graph generators for common graphs\n- Various graph algorithms\n- Graph visualization (in the browser)\n\nMost classes and functions are available on the root object (`jsnx` in\nbrowsers, `require('jsnetworkx')` in Node).\n\nInformation about which algorithms are available and the API of the classes,\ncan be found in the auto-generated [API documentation][api].\n\n### Example\n\n```js\n// var jsnx = require('jsnetworkx'); // in Node\n\n// a tree of height 4 with fan-out 2\nvar G = jsnx.balancedTree(2, 4);\n\n// Compute the shortest path between node 2 and 7\nvar path = jsnx.bidirectionalShortestPath(G, 2, 7);\n// [ 2, 0, 1, 3, 7 ]\n\n// or asynchronously\njsnx.genBidirectionalShortestPath(G, 2, 7).then(function(path) {\n  // path = [ 2, 0, 1, 3, 7 ]\n});\n```\n\nMore examples can be found on the [website][].\n\n### Asynchronous computation\n\nAll the algorithms are implemented in a synchronous fashion (for now at least).\nHowever, many algorithms are also available as asynchronous version. Their\nnames are `gen\u003cSyncFunctionName\u003e` (see example above) and they return a\nPromise.\n\nThis is achieved in **browsers** by creating a [WebWorker][]. The WebWorker has\nto be passed the path to the `jsnetworkx.js` file. You have to set the path\nexplicitly if the file is not located at the root:\n\n```js\njsnx.workerPath = '/path/to/jsnetworkx.js';\n```\n\nIn **Node**, a subprocess will be spawned (no setup is required).\n\n**Caveat:** In both cases the input data has to be serialized before it can be\nsent to the worker or subprocess. However, not every value can be serialized, in\nwhich case JSNetworkX will use the synchronous version instead. If you\nencounter a situation where a value is not serialized, but it should be\nserializable, please file an [issue][].\n\n\n### Iterables\n\nMany methods return generators or Maps. In an ES2015 environment, these can be\neasily consumed with a [`for/of`][forof] loop or [`Array.from`][arrayfrom].\n\nIf those are not available to you, JSNetworkX provides two helper methods for\niterating iterables and converting them to arrays: `jsnx.forEach` and\n`jsnx.toArray`\n\n---\n\n## How to contribute\n\nYou can contribute by:\n\n- Porting code from Python\n- Improving the documentation/website\n\nIf you plan on converting/porting a specific part, please create an issue\nbeforehand.\n\n### Build JSNetworkX\n\nJSNetworkX is written in ES2015 (ES6) and [Babel][] is used to convert it to\nES5. For the browser, all modules are bundled together with [browserify][].\n\nTo build JSNetworkX, all dependencies have to be installed via\n\n    npm install\n\n#### Build for the browser\n\n    npm run build:browser\n\ncreates `jsnetworkx.js`,  a minified version for production.\n\n    npm run build:browser:dev\n    npm run watch:browser\n\nCreates `jsnetworkx-dev.js`, an unminified version with inline source maps for\ndevelopment. The second version automatically rebuilds the file on change.\n\n#### Build for Node\n\n    npm run build:node\n\nTransforms all modules to ES5 and saves them inside the `node/` directory.\n\n    npm run build:node:dev\n\nSame as above but with inline source maps. These modules are also used to tun\nthe unit tests.\n\n    npm run watch:node\n\nIncrementally transform modules when files change.\n\n### Create and run tests\n\nTests are stored in the respective `__tests__` directories and have to follow\nthe naming convention `\u003ctestname\u003e-test.js`. The tests can be run with\n\n    npm test\n    # or\n    npm run test:fast # if you also run `npm run watch:node`\n\nThis will run all tests by default. To consider only those files whose path\nmatches a specific string, pass the `-g` option:\n\n    # Runs all digraph tests but no graph tests\n    npm run test:fast -- -g digraph\n\nThe difference between `npm test` and `npm run test:fast` is that the former\nwill always transplile all files from ES6 to ES5 first. This is slow and\nannoying during development. Therefore you can use\n\n    npm run watch:node\n\nto automatically convert only the changed file and run `npm run test:fast` to\nquickly test them.\n\nIdeally, every module has corresponding unit test. If you port a module from\nNetworkX, make sure to implement the same tests.\n\n### Run coverage\n\nWe use [istanbul][] to generate a coverage report. We are not enforcing any coverage\nyet, but there should not be a regression. The report can be created via\n\n    npm run cover\n\nand written to `coverage/`.\n\n\n[issue]: https://github.com/fkling/JSNetworkX/issues\n[npm]: https://www.npmjs.com/\n[website]: http://jsnetworkx.org\n[api]: http://jsnetworkx.org/api/\n[wiki]: https://github.com/fkling/JSNetworkX/wiki\n[WebWorker]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers\n[Babel]: https://babeljs.io/\n[browserify]: http://browserify.org/\n[istanbul]: https://gotwarlost.github.io/istanbul/\n[forof]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of\n[arrayfrom]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffkling%2FJSNetworkX","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffkling%2FJSNetworkX","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffkling%2FJSNetworkX/lists"}