{"id":37085088,"url":"https://github.com/jg-you/dyvider","last_synced_at":"2026-01-14T10:27:38.778Z","repository":{"id":65498841,"uuid":"588769835","full_name":"jg-you/dyvider","owner":"jg-you","description":"Dynamic programming algorithms for exact linear clustering in networks.","archived":false,"fork":false,"pushed_at":"2023-07-04T13:09:36.000Z","size":263,"stargazers_count":16,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-30T15:24:22.851Z","etag":null,"topics":["clustering","graph-algorithms","machine-learning","network-embedding"],"latest_commit_sha":null,"homepage":"","language":"Python","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/jg-you.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,"governance":null}},"created_at":"2023-01-14T00:26:28.000Z","updated_at":"2025-04-16T06:07:05.000Z","dependencies_parsed_at":"2023-12-09T20:46:36.413Z","dependency_job_id":null,"html_url":"https://github.com/jg-you/dyvider","commit_stats":{"total_commits":11,"total_committers":2,"mean_commits":5.5,"dds":0.09090909090909094,"last_synced_commit":"0e8a42e8dca8629235577202d9172f5bb616aa98"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jg-you/dyvider","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jg-you%2Fdyvider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jg-you%2Fdyvider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jg-you%2Fdyvider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jg-you%2Fdyvider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jg-you","download_url":"https://codeload.github.com/jg-you/dyvider/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jg-you%2Fdyvider/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28417192,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:25:19.714Z","status":"ssl_error","status_checked_at":"2026-01-14T10:22:49.371Z","response_time":107,"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":["clustering","graph-algorithms","machine-learning","network-embedding"],"created_at":"2026-01-14T10:27:37.992Z","updated_at":"2026-01-14T10:27:38.765Z","avatar_url":"https://github.com/jg-you.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dyvider\n\n**dyvider** is a small package implementing dynamic programming algorithms for exact linear clustering in networks.\nIts algorithms process networks whose nodes have positions in one dimension, and return their optimal partition.\n\nThe theory and experiments exploring this code can be found in the paper [\\\"Exact and rapid linear clustering of networks with dynamic programming\\\"](https://arxiv.org/abs/2301.10403), by [Alice Patania](https://alpatania.github.io/), [Antoine Allard](https://antoineallard.github.io/) and [Jean-Gabriel Young](https://jg-you.github.io/).\n\n\n![](repo_img.png)\n\n\n## Dependencies\n\nThe only necessary dependency are [`networkx`](https://networkx.org/) and `numpy`.\n\n## Installation\n\nTo install the latest version of dyvider, run the following command:\n```sh\npip install dyvider\n```\n\nTo install this package locally:\n* Clone this repository\n* Navigate to the folder on your local machine\n* Run the following command:\n```sh\npip install -e .\n```\n\n## Quick tour\n\nThe following minimal example first assigns scores to nodes with a one-dimensional spectral embedding and then retrieves an optimal linear clustering from this embedding using `dyvider`.\n\n```python\nimport networkx as nx\nimport dyvider as dy\nimport numpy as np\n\n# create a graph\ng = nx.stochastic_block_model([10, 10], [[0.5, 0.05], [0.05, 0.5]], seed=42)\n\n# generate a 1-d embedding with the leading eigenvector of the modularity matrix\neigenvals, eigvenvecs = np.linalg.eig(nx.linalg.adjacency_matrix(g).todense())\nscore = {v: float(eigvenvecs[v, 0]) for v in g.nodes()}\n\n# set the node positions\nnx.set_node_attributes(g, score, 'score')\n\n# run dyvider\ng = dy.utilities.preprocess(g)\nobjective_function = dy.objectives.Modularity()\nsolution, Q = dy.algorithms.run(g, objective_function)\n\nprint(solution)\n```\n\nThe expected output is:\n\n```python\n\u003e\u003e\u003e [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]] \n```\n\nOur [tutorial](tutorial.ipynb) goes into more detail and demonstrates all the API calls.\n\n\n## Paper\n\nIf you use this code, please consider citing:\n\n\"[*Exact and rapid linear clustering of networks with dynamic programming*](https://arxiv.org/abs/2301.10403)\"\u003cbr/\u003e\n[Alice Patania](https://alpatania.github.io/), [Antoine Allard](https://antoineallard.github.io/) and [Jean-Gabriel Young](https://jg-you.github.io/). \u003cbr/\u003e\narXiv:2301.10403 \u003cbr/\u003e\n\n\n## Author information\n\nCode by [Jean-Gabriel Young](https://jg-you.github.io). Don't hesitate to get in touch at \u003cjean-gabriel.young@uvm.edu\u003e, or via the [issues](https://github.com/jg-you/dyvider/issues)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjg-you%2Fdyvider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjg-you%2Fdyvider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjg-you%2Fdyvider/lists"}