python-graphblas
graphblas-algorithms
Python

Graph algorithms written in GraphBLAS

Last updated May 15, 2026
95
Stars
6
Forks
20
Issues
0
Stars/day
Attention Score
28
Language breakdown
No language data available.
โ–ธ Files click to expand
README

GraphBLAS Algorithms
conda-forge pypi PyPI - Python Version License
Tests Coverage DOI Discord

graphblas-algorithms is a collection of GraphBLAS algorithms written using python-graphblas. It may be used directly or as an experimental backend to NetworkX.

Why use GraphBLAS Algorithms? Because it is fast, flexible, and familiar by using the NetworkX API.

Are we missing any algorithms that you want? Please let us know!
GraphBLAS vs NetworkX
GraphBLAS vs igraph

Installation

conda install -c conda-forge graphblas-algorithms
pip install graphblas-algorithms

Basic Usage

First, create a GraphBLAS Matrix.

import graphblas as gb

M = gb.Matrix.from_coo( [0, 0, 1, 2, 2, 3], [1, 3, 0, 0, 1, 2], [1., 2., 3., 4., 5., 6.], nrows=4, ncols=4, dtype='float32' )

Next wrap the Matrix as ga.Graph.

import graphblas_algorithms as ga

G = ga.Graph(M)

Finally call an algorithm.

hubs, authorities = ga.hits(G)

When the result is a value per node, a gb.Vector will be returned. In the case of HITS, two Vectors are returned representing the hubs and authorities values.

Algorithms whose result is a subgraph will return ga.Graph.

Plugin for NetworkX

Dispatching to plugins is a new feature in Networkx 3.0. When both networkx and graphblas-algorithms are installed in an environment, calls to NetworkX algorithms can be dispatched to the equivalent version in graphblas-algorithms.

Dispatch Example

import networkx as nx
import graphblas_algorithms as ga

Generate a random graph (5000 nodes, 1000000 edges)

G = nx.erdosrenyigraph(5000, 0.08)

Explicitly convert to ga.Graph

G2 = ga.Graph.from_networkx(G)

Pass G2 to NetworkX's k_truss

T5 = nx.k_truss(G2, 5)

G2 is not a nx.Graph, but it does have an attribute networkx_plugin = "graphblas". This tells NetworkX to dispatch the k_truss call to graphblas-algorithms. This link connection exists because graphblas-algorithms registers itself as a "networkx.plugin" entry point.

The result T5 is a ga.Graph representing the 5-truss structure of the original graph. To convert to a NetworkX Graph, use:

T5.to_networkx()

Note that even with the conversions to and from ga.Graph, this example still runs 10x faster than using the native NetworkX k-truss implementation. Speed improvements scale with graph size, so larger graphs will see an even larger speed-up relative to NetworkX.

Plugin Algorithms

The following NetworkX algorithms have been implemented by graphblas-algorithms and can be used following the dispatch pattern shown above.

[//]: # (Begin auto-generated code)

graphblas_algorithms.nxapi
โ”œโ”€โ”€ boundary
โ”‚   โ”œโ”€โ”€ edge_boundary
โ”‚   โ””โ”€โ”€ node_boundary
โ”œโ”€โ”€ centrality
โ”‚   โ”œโ”€โ”€ degree_alg
โ”‚   โ”‚   โ”œโ”€โ”€ degree_centrality
โ”‚   โ”‚   โ”œโ”€โ”€ indegreecentrality
โ”‚   โ”‚   โ””โ”€โ”€ outdegreecentrality
โ”‚   โ”œโ”€โ”€ eigenvector
โ”‚   โ”‚   โ””โ”€โ”€ eigenvector_centrality
โ”‚   โ””โ”€โ”€ katz
โ”‚       โ””โ”€โ”€ katz_centrality
โ”œโ”€โ”€ cluster
โ”‚   โ”œโ”€โ”€ average_clustering
โ”‚   โ”œโ”€โ”€ clustering
โ”‚   โ”œโ”€โ”€ generalized_degree
โ”‚   โ”œโ”€โ”€ square_clustering
โ”‚   โ”œโ”€โ”€ transitivity
โ”‚   โ””โ”€โ”€ triangles
โ”œโ”€โ”€ community
โ”‚   โ””โ”€โ”€ quality
โ”‚       โ”œโ”€โ”€ intercommunityedges
โ”‚       โ””โ”€โ”€ intracommunityedges
โ”œโ”€โ”€ components
โ”‚   โ”œโ”€โ”€ connected
โ”‚   โ”‚   โ”œโ”€โ”€ is_connected
โ”‚   โ”‚   โ””โ”€โ”€ nodeconnectedcomponent
โ”‚   โ””โ”€โ”€ weakly_connected
โ”‚       โ””โ”€โ”€ isweaklyconnected
โ”œโ”€โ”€ core
โ”‚   โ””โ”€โ”€ k_truss
โ”œโ”€โ”€ cuts
โ”‚   โ”œโ”€โ”€ boundary_expansion
โ”‚   โ”œโ”€โ”€ conductance
โ”‚   โ”œโ”€โ”€ cut_size
โ”‚   โ”œโ”€โ”€ edge_expansion
โ”‚   โ”œโ”€โ”€ mixing_expansion
โ”‚   โ”œโ”€โ”€ node_expansion
โ”‚   โ”œโ”€โ”€ normalizedcutsize
โ”‚   โ””โ”€โ”€ volume
โ”œโ”€โ”€ dag
โ”‚   โ”œโ”€โ”€ ancestors
โ”‚   โ””โ”€โ”€ descendants
โ”œโ”€โ”€ dominating
โ”‚   โ””โ”€โ”€ isdominatingset
โ”œโ”€โ”€ efficiency_measures
โ”‚   โ””โ”€โ”€ efficiency
โ”œโ”€โ”€ generators
โ”‚   โ””โ”€โ”€ ego
โ”‚       โ””โ”€โ”€ ego_graph
โ”œโ”€โ”€ isolate
โ”‚   โ”œโ”€โ”€ is_isolate
โ”‚   โ”œโ”€โ”€ isolates
โ”‚   โ””โ”€โ”€ numberofisolates
โ”œโ”€โ”€ isomorphism
โ”‚   โ””โ”€โ”€ isomorph
โ”‚       โ”œโ”€โ”€ fastcouldbe_isomorphic
โ”‚       โ””โ”€โ”€ fastercouldbe_isomorphic
โ”œโ”€โ”€ linalg
โ”‚   โ”œโ”€โ”€ bethehessianmatrix
โ”‚   โ”‚   โ””โ”€โ”€ bethehessianmatrix
โ”‚   โ”œโ”€โ”€ graphmatrix
โ”‚   โ”‚   โ””โ”€โ”€ adjacency_matrix
โ”‚   โ”œโ”€โ”€ laplacianmatrix
โ”‚   โ”‚   โ”œโ”€โ”€ laplacian_matrix
โ”‚   โ”‚   โ””โ”€โ”€ normalizedlaplacianmatrix
โ”‚   โ””โ”€โ”€ modularitymatrix
โ”‚       โ”œโ”€โ”€ directedmodularitymatrix
โ”‚       โ””โ”€โ”€ modularity_matrix
โ”œโ”€โ”€ link_analysis
โ”‚   โ”œโ”€โ”€ hits_alg
โ”‚   โ”‚   โ””โ”€โ”€ hits
โ”‚   โ””โ”€โ”€ pagerank_alg
โ”‚       โ”œโ”€โ”€ google_matrix
โ”‚       โ””โ”€โ”€ pagerank
โ”œโ”€โ”€ lowestcommonancestors
โ”‚   โ””โ”€โ”€ lowestcommonancestor
โ”œโ”€โ”€ operators
โ”‚   โ”œโ”€โ”€ binary
โ”‚   โ”‚   โ”œโ”€โ”€ compose
โ”‚   โ”‚   โ”œโ”€โ”€ difference
โ”‚   โ”‚   โ”œโ”€โ”€ disjoint_union
โ”‚   โ”‚   โ”œโ”€โ”€ full_join
โ”‚   โ”‚   โ”œโ”€โ”€ intersection
โ”‚   โ”‚   โ”œโ”€โ”€ symmetric_difference
โ”‚   โ”‚   โ””โ”€โ”€ union
โ”‚   โ””โ”€โ”€ unary
โ”‚       โ”œโ”€โ”€ complement
โ”‚       โ””โ”€โ”€ reverse
โ”œโ”€โ”€ reciprocity
โ”‚   โ”œโ”€โ”€ overall_reciprocity
โ”‚   โ””โ”€โ”€ reciprocity
โ”œโ”€โ”€ regular
โ”‚   โ”œโ”€โ”€ iskregular
โ”‚   โ””โ”€โ”€ is_regular
โ”œโ”€โ”€ shortest_paths
โ”‚   โ”œโ”€โ”€ dense
โ”‚   โ”‚   โ”œโ”€โ”€ floyd_warshall
โ”‚   โ”‚   โ”œโ”€โ”€ floydwarshallnumpy
โ”‚   โ”‚   โ””โ”€โ”€ floydwarshallpredecessoranddistance
โ”‚   โ”œโ”€โ”€ generic
โ”‚   โ”‚   โ””โ”€โ”€ has_path
โ”‚   โ”œโ”€โ”€ unweighted
โ”‚   โ”‚   โ”œโ”€โ”€ allpairsshortestpathlength
โ”‚   โ”‚   โ”œโ”€โ”€ singlesourceshortestpathlength
โ”‚   โ”‚   โ””โ”€โ”€ singletargetshortestpathlength
โ”‚   โ””โ”€โ”€ weighted
โ”‚       โ”œโ”€โ”€ allpairsbellmanfordpath_length
โ”‚       โ”œโ”€โ”€ bellmanfordpath
โ”‚       โ”œโ”€โ”€ bellmanfordpath_length
โ”‚       โ”œโ”€โ”€ negativeedgecycle
โ”‚       โ””โ”€โ”€ singlesourcebellmanfordpath_length
โ”œโ”€โ”€ simple_paths
โ”‚   โ””โ”€โ”€ issimplepath
โ”œโ”€โ”€ smetric
โ”‚   โ””โ”€โ”€ s_metric
โ”œโ”€โ”€ structuralholes
โ”‚   โ””โ”€โ”€ mutual_weight
โ”œโ”€โ”€ tournament
โ”‚   โ”œโ”€โ”€ is_tournament
โ”‚   โ”œโ”€โ”€ score_sequence
โ”‚   โ””โ”€โ”€ tournament_matrix
โ”œโ”€โ”€ traversal
โ”‚   โ””โ”€โ”€ breadthfirstsearch
โ”‚       โ”œโ”€โ”€ bfs_layers
โ”‚       โ””โ”€โ”€ descendantsatdistance
โ””โ”€โ”€ triads
    โ””โ”€โ”€ is_triad

[//]: # (End auto-generated code)

ยฉ 2026 GitRepoTrend ยท python-graphblas/graphblas-algorithms ยท Updated daily from GitHub