{"_id":"graphology-cores","name":"graphology-cores","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"graphology-cores","version":"0.0.1","description":"Graphology utilities related to k-cores.","main":"index.js","types":"./index.d.ts","scripts":{"prepublishOnly":"npm test","test":"mocha test.js"},"repository":{"type":"git","url":"git+https://github.com/graphology/graphology.git"},"keywords":["graph","graphology","core"],"contributors":[{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},{"name":"César Pichon","url":"http://github.com/16arpi"}],"license":"MIT","bugs":{"url":"https://github.com/graphology/graphology/issues"},"homepage":"https://github.com/graphology/graphology#readme","peerDependencies":{"graphology-operators":"^1.6.0","graphology-types":">=0.19.0"},"dependencies":{"graphology-utils":"^2.5.2"},"_id":"graphology-cores@0.0.1","gitHead":"38a97f9147099ba17b69a1ec7255b7d2748465b7","_nodeVersion":"20.11.0","_npmVersion":"10.4.0","dist":{"integrity":"sha512-sr8inFDbDE98lxoSt1rkKh0OQzMEiTYayRrbiVrhihJBwK3eZ9riw2/M0cZrXvsgc/7Yu0jiU/xFVGSTaDSJRA==","shasum":"830a886650e59e749e08c131df0ba4cdcdf5ddf1","tarball":"https://registry.npmjs.org/graphology-cores/-/graphology-cores-0.0.1.tgz","fileCount":4,"unpackedSize":17288,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG7bQ/LyiJsBArxnaJ8K0MbpdxtFYvF+LXCc6HRWdgGbAiBdFixZdTzWdhCMBDojENu+36JTNldh6suRUU0RmbQyWg=="}]},"_npmUser":{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"},"directories":{},"maintainers":[{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphology-cores_0.0.1_1711536885942_0.4835810548265005"},"_hasShrinkwrap":false}},"time":{"created":"2024-03-27T10:54:45.941Z","0.0.1":"2024-03-27T10:54:46.078Z","modified":"2024-03-27T10:54:46.594Z"},"maintainers":[{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"}],"description":"Graphology utilities related to k-cores.","homepage":"https://github.com/graphology/graphology#readme","keywords":["graph","graphology","core"],"repository":{"type":"git","url":"git+https://github.com/graphology/graphology.git"},"contributors":[{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},{"name":"César Pichon","url":"http://github.com/16arpi"}],"bugs":{"url":"https://github.com/graphology/graphology/issues"},"license":"MIT","readme":"# Graphology Cores\n\nVarious functions related to k-cores of graphs and to be used with [graphology](https://graphology.github.io).\n\nThe k-core of a graph is the maximal connected subgraph in which all nodes have a degree of k or more. The main core of a graph is the k-core subgraph with the highest possible k.\n\nIf the graph is directed, nodes' degree are considered as the sum of all the inbound and outbound neighbors of the node.\n\n> An O(m) Algorithm for Cores Decomposition of Networks Vladimir Batagelj and Matjaz Zaversnik, 2003. [https://arxiv.org/abs/cs.DS/0310049](https://arxiv.org/abs/cs.DS/0310049)\n\n> Generalized Cores Vladimir Batagelj and Matjaz Zaversnik, 2002. [https://arxiv.org/pdf/cs/0202039](https://arxiv.org/pdf/cs/0202039)\n\n## Installation\n\n```\nnpm install graphology-cores\n```\n\n## Usage\n\n- [coreNumber](#corenumber)\n- [kCore](#kcore)\n- [kShell](#kshell)\n- [kCrust](#kcrust)\n- [kCorona](#kcorona)\n- [kTruss](#ktruss)\n- [onionLayers](#onionlayers)\n\n### coreNumber\n\nReturns the core number for each node. The core number of a node is the largest k of a k-core subgraph containing this node.\n\nThis implementation doesn't allow graphs with parallel edges or self loops.\n\n```js\nimport coreNumber from 'graphology-cores/coreNumber';\n\n// Return the core number for each node\nconst numbers = coreNumber(graph);\n\n// Assign to each node its core number\ncoreNumber.assign(graph);\n\n// Assign with a custom attribute label\ncoreNumber.assign(graph, 'core');\n```\n\n_Arguments_\n\n- **graph** _Graph_: target graph.\n- **nodeCoreAttribute** _?string_ : the name of the attribute to use if core numbers are assigned to the nodes.\n\n### kCore\n\nReturns the maximal connected subgraph containing nodes with k degree or more. If k isn't provided, k is the highest core number present in the graph.\n\n```js\nimport kCore from 'graphology-cores/kCore';\n\n// Return the main k-core of the graph\nconst core = kCore(graph);\n\n// Return the k-core subgraph with an arbitrary k value\nconst core = kCore(graph, 4);\n```\n\n_Arguments_\n\n- **graph** _Graph_: target graph.\n- **k** _?number_: custom k value to use.\n- **customCore** _?object_: custom core numbers to use.\n\n### kShell\n\nReturns the k-shell subgraph. K-Shell subgraph is the maximal connected subgraph containing the nodes with k degree.\n\n```js\nimport kShell from 'graphology-cores/kShell';\n\n// Return the main k-shell of the graph\nconst shell = kShell(graph);\n\n// Return the k-shell subgraph with an arbitrary k value\nconst shell = kShell(graph, 5);\n```\n\n_Arguments_\n\n- **graph** _Graph_: target graph.\n- **k** _?number_: custom k value to use.\n- **customCore** _?object_: custom core numbers to use.\n\n### kCrust\n\nReturns the k-crust subgraph. K-Crust subgraph is the maximal connected subgraph containing nodes with less than k degree.\n\n```js\nimport kCrust from 'graphology-cores/kCrust';\n\n// Return the main k-crust of the graph\nconst crust = kCrust(graph);\n\n// Return the k-crust subgraph with an arbitrary k value\nconst crust = kCrust(graph, 4);\n```\n\n_Arguments_\n\n- **graph** _Graph_: target graph.\n- **k** _?number_: custom k value to use.\n- **customCore** _?object_: custom core numbers to use.\n\n### kCorona\n\nReturns the k-corona subgraph. K-Corona subgraph contains nodes in the k-core with exactly k neighbors in the k-core.\n\n```js\nimport kCorona from 'graphology-cores/kCorona';\n\n// Return the main k-corona of the graph\nconst corona = kCorona(graph);\n\n// Return the k-corona subgraph with an arbitrary k value\nconst corona = kCorona(graph, 4);\n```\n\n_Arguments_\n\n- **graph** _Graph_: target graph.\n- **k** _?number_: custom k value to use.\n- **customCore** _?object_: custom core numbers to use.\n\n### kTruss\n\nReturns the k-truss subgraph. K-Truss subgraph contains at least three nodes for which every edge is incident to at least `k-2` triangles.\n\nK-Truss is not implemented for directed graphs and multigraphs.\n\n```js\nimport kTruss from 'graphology-cores/kTruss';\n\n// Return the k-truss of the graph with k = 4\nconst truss = kTruss(graph, 4);\n```\n\n_Arguments_\n\n- **graph** _Graph_: target graph.\n- **k** _number_: k value to use.\n\n### onionLayers\n\nComputes the onion decomposition of a given graph. Onion layers can't be calculated if the graph is directed.\n\n> Multi-scale structure and topological anomaly detection via a new network statistic: The onion decomposition L. Hébert-Dufresne, J. A. Grochow, and A. Allard Scientific Reports 6, 31708 (2016) [http://doi.org/10.1038/srep31708](http://doi.org/10.1038/srep31708)\n\n```js\nimport onionLayers from 'graphology-cores/onionLayers';\n\n// Return the onion layers for each node\nconst onion = onionLayers(graph);\n\n// Assign to each node its onion layer\nonionLayers.assign(graph);\n\n// Assign with a custom attribute label\nonionLayers.assign(graph, 'onion');\n```\n\n_Arguments_\n\n- **graph** _Graph_: target graph.\n- **nodeOnionLayerAttribute** _?string_ : the name of the attribute to use if onion layers are assigned to the nodes.\n","readmeFilename":"README.md"}