{"id":13637163,"url":"https://github.com/neo4j-labs/graph","last_synced_at":"2025-04-19T08:33:54.581Z","repository":{"id":42485331,"uuid":"376120692","full_name":"neo4j-labs/graph","owner":"neo4j-labs","description":"A library for high-performant graph algorithms.","archived":false,"fork":false,"pushed_at":"2023-11-22T17:19:34.000Z","size":861,"stargazers_count":384,"open_issues_count":6,"forks_count":20,"subscribers_count":15,"default_branch":"main","last_synced_at":"2024-10-31T21:12:47.233Z","etag":null,"topics":["algorithms","csr","data-structures","graph","graph-algorithms","hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/neo4j-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"roadmap":null,"authors":null}},"created_at":"2021-06-11T19:11:53.000Z","updated_at":"2024-10-23T16:57:51.000Z","dependencies_parsed_at":"2023-09-24T18:10:23.477Z","dependency_job_id":"d0059a51-53fc-4fdb-970d-8294550b8e75","html_url":"https://github.com/neo4j-labs/graph","commit_stats":{"total_commits":524,"total_committers":9,"mean_commits":58.22222222222222,"dds":"0.46564885496183206","last_synced_commit":"9bffe05806ccb14ed6a2ddac53b7dd8b227e822f"},"previous_names":["s1ck/graph"],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neo4j-labs%2Fgraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neo4j-labs%2Fgraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neo4j-labs%2Fgraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neo4j-labs%2Fgraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neo4j-labs","download_url":"https://codeload.github.com/neo4j-labs/graph/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223795267,"owners_count":17204137,"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":["algorithms","csr","data-structures","graph","graph-algorithms","hacktoberfest"],"created_at":"2024-08-02T00:01:11.612Z","updated_at":"2024-11-09T06:31:10.720Z","avatar_url":"https://github.com/neo4j-labs.png","language":"Rust","funding_links":[],"categories":["Libraries","data-structures"],"sub_categories":["Graph algorithms"],"readme":"# graph \u0026emsp; [![GitHub Actions workflow status]][actions] [![Latest version on crates.io]][crates.io] [![Latest version on PyPI]][pypi.org] [![License: MIT]][license]\n\n[GitHub Actions workflow status]: https://img.shields.io/github/actions/workflow/status/neo4j-labs/graph/rust.yml?branch=main\u0026label=CI\u0026style=flat-square\n[actions]: https://github.com/neo4j-labs/graph/actions/workflows/rust.yml?query=branch%3Amain\n[Latest version on crates.io]: https://img.shields.io/crates/v/graph?style=flat-square\n[crates.io]: https://crates.io/crates/graph/\n[Latest version on PyPI]: https://img.shields.io/pypi/v/graph-mate?style=flat-square\n[pypi.org]: https://pypi.org/project/graph-mate/\n[License: MIT]: https://img.shields.io/crates/l/graph?style=flat-square\n[license]: https://choosealicense.com/licenses/mit/\n\n\nA library that provides a collection of high-performant graph algorithms.\nThis crate builds on top of the [graph_builder](https://docs.rs/graph_builder/latest/)\ncrate, which can be used as a building block for custom graph algorithms.\n\n`graph_builder` provides implementations for directed and undirected graphs.\nGraphs can be created programatically or read from custom input formats in a\ntype-safe way. The library uses [rayon](https://github.com/rayon-rs/rayon)\nto parallelize all steps during graph creation. The implementation uses a\nCompressed-Sparse-Row (CSR) data structure which is tailored for fast and\n concurrent access to the graph topology.\n\n`graph` provides graph algorithms which take graphs created using `graph_builder`\nas input. The algorithm implementations are designed to run efficiently on\nlarge-scale graphs with billions of nodes and edges.\n\n**Note**: The development is mainly driven by\n[Neo4j](https://github.com/neo4j/neo4j) developers. However, the library is\n__not__ an official product of Neo4j.\n\n## What is a graph?\n\nA graph consists of nodes and edges where edges connect exactly two nodes. A\ngraph can be either directed, i.e., an edge has a source and a target node\nor undirected where there is no such distinction.\n\nIn a directed graph, each node `u` has outgoing and incoming neighbors. An\noutgoing neighbor of node `u` is any node `v` for which an edge `(u, v)`\nexists. An incoming neighbor of node `u` is any node `v` for which an edge\n`(v, u)` exists.\n\nIn an undirected graph there is no distinction between source and target\nnode. A neighbor of node `u` is any node `v` for which either an edge `(u,\nv)` or `(v, u)` exists.\n\n## How to use graph?\n\nThe library provides a builder that can be used to construct a graph from a\ngiven list of edges.\n\nFor example, to create a directed graph that uses `usize` as node\nidentifier, one can use the builder like so:\n\n```rust\nuse graph::prelude::*;\n\nlet graph: DirectedCsrGraph\u003cusize\u003e = GraphBuilder::new()\n    .csr_layout(CsrLayout::Sorted)\n    .edges(vec![(0, 1), (0, 2), (1, 2), (1, 3), (2, 3)])\n    .build();\n\nassert_eq!(graph.node_count(), 4);\nassert_eq!(graph.edge_count(), 5);\n\nassert_eq!(graph.out_degree(1), 2);\nassert_eq!(graph.in_degree(1), 1);\n\nassert_eq!(graph.out_neighbors(1).as_slice(), \u0026[2, 3]);\nassert_eq!(graph.in_neighbors(1).as_slice(), \u0026[0]);\n```\n\nTo build an undirected graph using `u32` as node identifer, we only need to\nchange the expected types:\n\n```rust\nuse graph::prelude::*;\n\nlet graph: UndirectedCsrGraph\u003cu32\u003e = GraphBuilder::new()\n    .csr_layout(CsrLayout::Sorted)\n    .edges(vec![(0, 1), (0, 2), (1, 2), (1, 3), (2, 3)])\n    .build();\n\nassert_eq!(graph.node_count(), 4);\nassert_eq!(graph.edge_count(), 5);\n\nassert_eq!(graph.degree(1), 3);\n\nassert_eq!(graph.neighbors(1).as_slice(), \u0026[0, 2, 3]);\n```\n\nCheck out the [graph_builder](https://docs.rs/graph_builder/latest/) crate for\nfor more examples on how to build graphs from various input formats.\n\n## How to run algorithms\n\nIn the following we will demonstrate running [Page Rank](https://en.wikipedia.org/wiki/PageRank),\na graph algorithm to determine the importance of nodes in a graph based on the\nnumber and quality of their incoming edges.\n\nPage Rank requires a directed graph and returns the rank value for each node.\n\n```rust\nuse graph::prelude::*;\n\n// https://en.wikipedia.org/wiki/PageRank#/media/File:PageRanks-Example.svg\nlet graph: DirectedCsrGraph\u003cusize\u003e = GraphBuilder::new()\n    .edges(vec![\n           (1,2), // B-\u003eC\n           (2,1), // C-\u003eB\n           (4,0), // D-\u003eA\n           (4,1), // D-\u003eB\n           (5,4), // E-\u003eD\n           (5,1), // E-\u003eB\n           (5,6), // E-\u003eF\n           (6,1), // F-\u003eB\n           (6,5), // F-\u003eE\n           (7,1), // G-\u003eB\n           (7,5), // F-\u003eE\n           (8,1), // G-\u003eB\n           (8,5), // G-\u003eE\n           (9,1), // H-\u003eB\n           (9,5), // H-\u003eE\n           (10,1), // I-\u003eB\n           (10,5), // I-\u003eE\n           (11,5), // J-\u003eB\n           (12,5), // K-\u003eB\n    ])\n    .build();\n\nlet (ranks, iterations, _) = page_rank(\u0026graph, PageRankConfig::new(10, 1E-4, 0.85));\n\nassert_eq!(iterations, 10);\n\nlet expected = vec![\n    0.024064068,\n    0.3145448,\n    0.27890152,\n    0.01153846,\n    0.029471997,\n    0.06329483,\n    0.029471997,\n    0.01153846,\n    0.01153846,\n    0.01153846,\n    0.01153846,\n    0.01153846,\n    0.01153846,\n];\n\nassert_eq!(ranks, expected);\n```\n\nLicense: MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneo4j-labs%2Fgraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneo4j-labs%2Fgraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneo4j-labs%2Fgraph/lists"}