Graph algorithms written in GraphBLAS
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!

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)