{"id":13856940,"url":"https://github.com/Graphegon/pygraphblas","last_synced_at":"2025-07-13T19:33:23.406Z","repository":{"id":39332991,"uuid":"192621931","full_name":"Graphegon/pygraphblas","owner":"Graphegon","description":"GraphBLAS for Python","archived":false,"fork":false,"pushed_at":"2024-01-16T14:06:20.000Z","size":13391,"stargazers_count":343,"open_issues_count":15,"forks_count":27,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-11-14T13:57:21.088Z","etag":null,"topics":["graph-algorithms","graph-analysis","graphblas","graphs","ipynb","linear-algebra","matrix","python","semirings","suitesparse"],"latest_commit_sha":null,"homepage":"https://graphegon.github.io/pygraphblas/pygraphblas/index.html","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Graphegon.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-18T22:44:36.000Z","updated_at":"2024-09-13T14:15:28.000Z","dependencies_parsed_at":"2024-06-18T18:12:28.040Z","dependency_job_id":"cdde6233-303a-4498-8b75-bfead6f47dcb","html_url":"https://github.com/Graphegon/pygraphblas","commit_stats":{"total_commits":606,"total_committers":7,"mean_commits":86.57142857142857,"dds":0.09735973597359737,"last_synced_commit":"2d893016299767ce9c0c41b5be4aab7fc14315a5"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Graphegon%2Fpygraphblas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Graphegon%2Fpygraphblas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Graphegon%2Fpygraphblas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Graphegon%2Fpygraphblas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Graphegon","download_url":"https://codeload.github.com/Graphegon/pygraphblas/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225710336,"owners_count":17512005,"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":["graph-algorithms","graph-analysis","graphblas","graphs","ipynb","linear-algebra","matrix","python","semirings","suitesparse"],"created_at":"2024-08-05T03:01:19.699Z","updated_at":"2024-11-22T14:31:23.673Z","avatar_url":"https://github.com/Graphegon.png","language":"Python","readme":"![Tests](https://github.com/Graphegon/pygraphblas/workflows/Tests/badge.svg)\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Graphegon/pygraphblas/v4.0.3?filepath=pygraphblas%2Fdemo%2FIntroduction-to-GraphBLAS-with-Python.ipynb)\n\u003cbr /\u003e\n# pygraphblas\n\npygraphblas is a Python wrapper around the\n[GraphBLAS](http://graphblas.org) API.\n\n## [Click here for API Documentation](https://graphegon.github.io/pygraphblas/pygraphblas/index.html)\n\n## Installation\n\npygraphblas requires the\n[SuiteSparse:GraphBLAS](http://faculty.cse.tamu.edu/davis/GraphBLAS.html)\nlibrary.  The easiest way currently to install pygraphblas on Linux is\nto use pip:\n\n    pip install pygraphblas\n\nThis is currently only supported on Linux but Windows and MacOS binary\npackages are currently a work in progress.\n\nTo install from source, first install SuiteSparse, then run:\n\n    python setup.py install\n  \nThere are two ways to download precompiled binaries of pygraphblas\nwith SuiteSparse included.  One way is to use `pip install\npygraphblas` on an Intel Linux machine.  This will download a package\ncompatible with most modern linux distributions.  This also works in a\nDocker container on Mac.\n\nThere are also pre-build docker images based on Ubuntu 20.04 that have\na pre-compiled SuiteSparse and pygraphblas installed.  These come in\ntwo flavors `minimal` which is the Ipython interpreter-only, and\n`notebook` which comes with a complete Jupyter Notebook server.  These\ncontainers also work on Mac.\n\nAn installation script for Ubuntu 18.04 is provided in the\n`install-ubuntu.sh` file.\n\nNOTE: DO NOT USE THESE PRE-COMPILED BINARIES FOR BENCHMARKING\nSUITESPARSE.  These binaries are not guaranteed to be idealy compiled\nfor your environment.\n\n## Docker \n\npygraphblas is distributed as two different docker images on [Docker\nHub](https://cloud.docker.com/repository/docker/pygraphblas/pygraphblas/general)\n.  The \"minimal\" image, containing only the library and\n[ipython](https://ipython.org/) and can be run with the command:\n\n    docker run --rm -it graphblas/pygraphblas-minimal ipython\n\nYou can run a \"full\" [Jupyter notebook](https://jupyter.org/) server\nwith docker and try the example Notebooks use the command:\n\n    docker run --rm -it -p 8888:8888 graphblas/pygraphblas-notebook\n\nOpen up the URL printed on your terminal screen to see the demo\nNotebook folder, including:\n\n - [Introduction to GraphBLAS with Python](./demo/Introduction-to-GraphBLAS-with-Python.ipynb)\n - [PageRank](./demo/PageRank.ipynb)\n - [Betweeness Centrality](./demo/BetweenessCentrality.ipynb)\n - [Triangle Centrality](./demo/TriangleCentrality.ipynb)\n - [Gallery of Centrality](./demo/Centrality.ipynb)\n - [K-Truss Subgraphs](./demo/K-Truss.ipynb)\n - [Triangle Counting](./demo/Triangle-Counting.ipynb)\n - [Louvain Community Detection](./demo/Louvain.ipynb)\n - [RadiX-Net Topologies](./demo/RadiX-Net-with-pygraphblas.ipynb)\n - [User Defined Types](./demo/User-Defined-Types.ipynb)\n - [Log Semiring Type](./demo/Log-Semiring.ipynb)\n\n# Tests\n\nTo run the tests checkout pygraphblas and use:\n\n    $ ./test.sh\n\n# Summary\n\npygraphblas is a python extension that bridges [The GraphBLAS\nAPI](http://graphblas.org) with the [Python](https://python.org)\nprogramming language.  It uses the\n[CFFI](https://cffi.readthedocs.io/en/latest/) library to wrap the low\nlevel GraphBLAS API and provides high level Matrix and Vector Python\ntypes that make GraphBLAS simple and easy.\n\nGraphBLAS is a sparse linear algebra API optimized for processing\ngraphs encoded as sparse matrices and vectors.  In addition to common\nreal/integer matrix algebra operations, GraphBLAS supports over a\nthousand different [Semiring](https://en.wikipedia.org/wiki/Semiring)\nalgebra operations, that can be used as basic building blocks to\nimplement a wide variety of graph algorithms. See\n[Applications](https://en.wikipedia.org/wiki/Semiring#Applications)\nfrom Wikipedia for some specific examples.\n\npygraphblas leverages the expertise in the field of sparse matrix\nprogramming by [The GraphBLAS Forum](http://graphblas.org) and uses\nthe\n[SuiteSparse:GraphBLAS](http://faculty.cse.tamu.edu/davis/GraphBLAS.html)\nAPI implementation. SuiteSparse:GraphBLAS is brought to us by the work\nof [Dr. Tim Davis](http://faculty.cse.tamu.edu/davis/welcome.html),\nprofessor in the Department of Computer Science and Engineering at\nTexas A\u0026M University.  [News and\ninformation](http://faculty.cse.tamu.edu/davis/news.html) can provide\nyou with a lot more background information, in addition to the\nreferences below.\n\nWhile it is my goal to make it so that pygraphblas works with any\nGraphBLAS implementation, it currently only works with SuiteSparse.\nSuiteSparse is currently the only realistically usable GraphBLAS\nimplementation, and additionally it provides several \"extension\"\nfeatures and pre-packaged objects that are very useful for\npygraphblas.  If there is a GraphBLAS implementation you would like to\nsee support for in pygraphblas, please consider creating an issue for\nit for discussion and/or sending me a pull request.\n\n# Introduction to Graphs and Matrices\n\nGraphBLAS uses matrices and Linear Algebra to represent graphs, as\ndescribed [in this mathmatical introduction to\nGraphBLAS](http://www.mit.edu/~kepner/GraphBLAS/GraphBLAS-Math-release.pdf)\nby [Dr. Jeremy Kepner](http://www.mit.edu/~kepner/) head and founder\nof [MIT Lincoln Laboratory Supercomputing\nCenter](http://news.mit.edu/2016/lincoln-laboratory-establishes-supercomputing-center-0511).\n\nThere are two useful matrix representations of graphs: [Adjacency\nMatrices](https://en.wikipedia.org/wiki/Adjacency_matrix) and\n[Incidence Matrices](https://en.wikipedia.org/wiki/Incidence_matrix).\nFor this introduction we will focus on the adjacency type as they are\nsimpler, but the same ideas apply to both, both are suported by\nGraphBLAS and pygraphblas, and it is easy to switch back and forth\nbetween them.\n\n![An example graph and adjacency matrix](./docs/imgs/AdjacencyMatrixBFS.png)\n\nOn the left is a graph, and on the right, the adjacency matrix that\nrepresents it. The matrix has a row and column for every node in the\ngraph.  If there is an edge going from node A to B, then there will be\na value present in the intersection of As row with Bs column.  How it\ndiffers from many other matrix representations is that the matrix is\nsparse, nothing is stored in computer memory where there are unused\nelements.\n\nSparsity is important because one practical problem with\nmatrix-encoding graphs is that most real-world graphs tend to be\nsparse, as above, only 7 of 36 possible elements have a value. Those\nthat have values tend to be scattered randomly across the matrix\n(for \"typical\" graphs), so dense linear algebra libraries like BLAS or\nnumpy do not encode or operate on them efficiently, as the relevant\ndata is mostly empty memory with actual data elements spaced far\napart.  This wastes memory and CPU resources, and defeats CPU caching\nmechanisms.\n\nFor example, suppose a fictional social network has 1 billion users,\nand each user has about 100 friends, which means there are about 100\nbillion (1e+11) connections in the graph.  A dense matrix large enough\nto hold this graph would need (1 billion)^2 or\n(1,000,000,000,000,000,000), a \"quintillion\" elements, but only 1e+11\nof them would have meaningful values, leaving only 0.0000001th of the\nmatrix being utilized.\n\nBy using a sparse matrix instead of dense, only the elements used are\nactually stored in memory. The parts of the matrix with no value are\n*interpreted*, but not necessarily stored, as an identity value, which\nmay or may not be the actual number zero, but possibly other values\nlike positive or negative infinity depending on the particular\nsemiring operations applied to the matrix.\n\nSemirings encapsulate different algebraic operations and identities\nthat can be used to multiply matrices and vectors.  Anyone who has\nmultiplied matrices has used at least one Semiring before, typically\nreferred to as \"plus_times\".  This is the common operation of\nmultiplying two matrices containing real numbers, the corresponding row\nand column entries are multipled and the results are summed for the\nfinal value.\n\n## Code of Conduct\n\nEveryone interacting in the pygraphblas project's codebases, issue\ntrackers, chat rooms, and mailing lists is expected to follow the [PSF\nCode of Conduct](https://www.python.org/psf/conduct/).\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGraphegon%2Fpygraphblas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGraphegon%2Fpygraphblas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGraphegon%2Fpygraphblas/lists"}