{"id":13430844,"url":"https://github.com/feross/p2p-graph","last_synced_at":"2025-04-05T15:07:41.749Z","repository":{"id":37821824,"uuid":"68768365","full_name":"feross/p2p-graph","owner":"feross","description":"Real-time P2P network visualization with D3","archived":false,"fork":false,"pushed_at":"2021-03-30T13:01:53.000Z","size":2464,"stargazers_count":288,"open_issues_count":6,"forks_count":33,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-29T14:09:24.856Z","etag":null,"topics":["d3","demo","graph","network","networking","p2p","p2p-graph","p2p-network-visualization","peer","visualization","webtorrent"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/feross.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-21T01:39:43.000Z","updated_at":"2025-03-21T07:09:20.000Z","dependencies_parsed_at":"2022-08-19T05:50:11.956Z","dependency_job_id":null,"html_url":"https://github.com/feross/p2p-graph","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feross%2Fp2p-graph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feross%2Fp2p-graph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feross%2Fp2p-graph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/feross%2Fp2p-graph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/feross","download_url":"https://codeload.github.com/feross/p2p-graph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353745,"owners_count":20925329,"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":["d3","demo","graph","network","networking","p2p","p2p-graph","p2p-network-visualization","peer","visualization","webtorrent"],"created_at":"2024-07-31T02:00:58.345Z","updated_at":"2025-04-05T15:07:41.723Z","avatar_url":"https://github.com/feross.png","language":"JavaScript","readme":"# p2p-graph [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]\n\n[travis-image]: https://img.shields.io/travis/feross/p2p-graph/master.svg\n[travis-url]: https://travis-ci.org/feross/p2p-graph\n[npm-image]: https://img.shields.io/npm/v/p2p-graph.svg\n[npm-url]: https://npmjs.org/package/p2p-graph\n[downloads-image]: https://img.shields.io/npm/dm/p2p-graph.svg\n[downloads-url]: https://npmjs.org/package/p2p-graph\n[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg\n[standard-url]: https://standardjs.com\n\n### Real-time P2P network visualization with D3\n\n![demo](demo.gif)\n\nThis package is used by [WebTorrent](https://webtorrent.io). You can see this\npackage in action on the [webtorrent.io](https://webtorrent.io) homepage or\nplay with it on the\n[esnextb.in demo](https://esnextb.in/?gist=6d2ede2438db14c108d30343f352ad8c).\n\n## Install\n\n```\nnpm install p2p-graph\n```\n\nThis package works in the browser with [browserify](https://browserify.org). If you do not use a bundler, you can use the [standalone script](https://bundle.run/p2p-graph) directly in a `\u003cscript\u003e` tag.\n\n## Usage\n\n```js\nvar Graph = require('p2p-graph')\n\nvar graph = new Graph('.root')\n\ngraph.on('select', function (id) {\n  console.log(id + ' selected!')\n})\n\n// Add two peers\ngraph.add({\n  id: 'peer1',\n  me: true,\n  name: 'You'\n})\ngraph.add({\n  id: 'peer2',\n  name: 'Another Peer'\n})\n\n// Connect them\ngraph.connect('peer1', 'peer2')\n```\n\n# API\n\n**Heads Up!** : Represented Graphs are directed!\n\n\u003e In graph theory, a directed graph (or digraph) is a graph that is a set of vertices connected by edges, where the edges have a direction associated with them.\n\n### graph = new Graph(rootElem)\n\nCreate a new P2P graph at the root DOM element `rootElem`. In addition to an\n`Element`, a query selector string (like `'.my-cool-element'`) can also be passed\nin.\n\n### graph.add(peer)\n\nAdd a peer to the graph. The `peer` object should contain:\n\n```\n{\n  id: 'unique-identifier', // should be unique across all peers\n  me: true, // is this the current user?\n  name: 'display name' // name to show in the graph UI\n}\n```\n\n### graph.connect(id1, id2)\n\nConnect to two nodes, identified by `id1` and `id2`, to each other.\n\n### graph.disconnect(id1, id2)\n\nDisconnect two nodes, identified by `id1` and `id2`, from each other.\n\n### graph.areConnected(id1, id2)\n\nCheck whether two nodes identified by `id1` and `id2` are somehow connected (`id1 --\u003e id2` or `id2 --\u003e id1`).\n\n### graph.getLink(id1, id2)\n\nIf exists return the link between `id1` and `id2`, otherwise `null`.\n\n### graph.hasPeer(Id1[, ...IdX])\n\nReturn `true` if all the given Nodes exists, otherwise `false`.\n\n### graph.hasLink(Id1, Id2)\n\nReturn `true` the given Link exists, otherwise `false` (direction matters!).\n\n### graph.remove(id)\n\nRemove a node, identified by `id`, from the graph.\n\n### graph.seed(id, isSeeding)\n\nChange a node's status identified by `id`, `isSeeding` must be true or false.\n\n### graph.rate(id1, id2, speed)\n\nUpdate the transfer rate between two nodes identified by `id1` and `id2`. `speed` must be expressed in bytes.\n\n### graph.list()\n\nReturn an array of Nodes.\n\n### graph.destroy()\n\nDestroys the graph and all the listeners related to it.\n\n### graph.on('select', function (id) {})\n\nEvent is fired when a node is selected (clicked on) by the user. The `id` argument is either the id\nof the selected peer, `false` to indicate that the peer has been deselected. Only one peer can be\nselected at any given time.\n\n## license\n\nMIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).\n","funding_links":[],"categories":["JavaScript","p2p","P2P","visualization","Libraries"],"sub_categories":["React Components"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeross%2Fp2p-graph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffeross%2Fp2p-graph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffeross%2Fp2p-graph/lists"}