
GraphBLAS – Graph algorithms in the language of linear algebra - johlo
http://graphblas.org/
======
szarnyasg
I have created a tutorial slideshow on the theory of GraphBLAS with lots of
examples and step-by-step illustrations:
[http://mit.bme.hu/~szarnyas/grb/graphblas-
introduction.pdf](http://mit.bme.hu/~szarnyas/grb/graphblas-introduction.pdf)

A shorter version of this tutorial was recorded at FOSDEM earlier this year:
[https://fosdem.org/2020/schedule/event/graphblas/](https://fosdem.org/2020/schedule/event/graphblas/)

More papers/tutorials/libraries are listed at
[https://github.com/GraphBLAS/GraphBLAS-
Pointers](https://github.com/GraphBLAS/GraphBLAS-Pointers).

~~~
ngcc_hk
Thanks and great

------
FabHK
This interview with Tim Davis has a bit of background information.

[https://www.acm.org/articles/people-of-acm/2019/tim-
davis](https://www.acm.org/articles/people-of-acm/2019/tim-davis)

> I picked Gaussian elimination. "That will be quick," I thought. Not! I got
> started on matrices in 1985 and I'm not done with Gaussian elimination yet.

> GraphBLAS is a community effort, including industry, academics, and
> government labs, that is working to design a library that can implement
> graph algorithms based on sparse linear algebra over semirings. There are
> lots of great graph libraries out there that don't exploit the linear
> algebraic abstraction, but most of what they do can be viewed as matrix
> operations on adjacency matrices. GraphBLAS makes the connection to linear
> algebra explicit.

> GraphBLAS gives the graph algorithm developer the power and abstraction of
> linear algebra, with all its advantages (associative and distributive laws,
> AB=(B'A')', and so on). One level of breadth-first search, for example, is a
> single sparse matrix-times-sparse vector multiply, with no loss of
> asymptotic efficiency. Google's entire PageRank computation can be done with
> a handful of iterations around a single call to GraphBLAS, using what I call
> the "PageRank semiring."

~~~
chrisaycock
>> _Google 's entire PageRank computation can be done with a handful of
iterations around a single call to GraphBLAS, using what I call the "PageRank
semiring."_

The author has an example of PageRank in C:

[https://github.com/DrTimothyAldenDavis/GraphBLAS/blob/stable...](https://github.com/DrTimothyAldenDavis/GraphBLAS/blob/stable/Demo/Source/dpagerank.c)

I assume his "single call" statement refers to the MATLAB version:

[https://github.com/DrTimothyAldenDavis/GraphBLAS/blob/stable...](https://github.com/DrTimothyAldenDavis/GraphBLAS/blob/stable/Demo/MATLAB/dpagerank.m)

    
    
        for i = 1:20
            r = ((c*r) * C) + a * sum (r) ;
        end
    

The MATLAB interface uses overloaded operators and methods on a GraphBLAS
matrix object.

~~~
DocSparse
I was referring to the PageRank_semiring in
[https://github.com/DrTimothyAldenDavis/GraphBLAS/blob/5e569f...](https://github.com/DrTimothyAldenDavis/GraphBLAS/blob/5e569f2fcb0597b4ad3c60fca1a4ff8e938fd111/Demo/Source/dpagerank2.c#L348)
. I wasn't counting the test for the termination condition -- in the statement
in my interview, I assumed the # of iterations could just be given. I would
guess that's the case for the Google PageRank computation, since the graph
doesn't change so much each month when they compute it, they probably know how
many iterations they need.

------
chrisaycock
RedisGraph uses GraphBLAS:

[https://github.com/RedisGraph/RedisGraph/](https://github.com/RedisGraph/RedisGraph/)

Their paper claims that computing with adjacency (sparse) matrices is more
performant than alternatives:

[https://arxiv.org/pdf/1905.01294.pdf](https://arxiv.org/pdf/1905.01294.pdf)

They compile queries written in Cypher (Neo4j's language) to operations in
linear algebra. An example query is:

    
    
        MATCH (n:actor{name:"Nicolas Cage"})-[:act]->(m:movie)<-[:act]-(a:actor) RETURN a.name, m.title

~~~
waffle_ss
Note that the Cypher support is incomplete, and missing features like multiple
labels.

[https://oss.redislabs.com/redisgraph/cypher_support/](https://oss.redislabs.com/redisgraph/cypher_support/)

------
codecoinbot
Shameless self promotion, I started a rust wrapper as my first project for
GraphBLAS

[https://github.com/fabianmurariu/rustgraphblas](https://github.com/fabianmurariu/rustgraphblas)

and a JNI wrapper

[https://github.com/fabianmurariu/graphblas-java-
native](https://github.com/fabianmurariu/graphblas-java-native)

They are not 100% complete, the JNI one is not published yet and only works on
linux

------
nimish
Is there a treatment of graph algorithms in linear algebra from the basics
anywhere?

~~~
michelpp
pygraphblas author here, here is a good notebook introduction to the very
basics of GraphBLAS with Python. The concepts carry naturally to the C API as
well:

[https://github.com/michelp/pygraphblas/blob/master/pygraphbl...](https://github.com/michelp/pygraphblas/blob/master/pygraphblas/demo/Introduction-
to-GraphBLAS-with-Python.ipynb)

I also made a quick introduction video for a paper submission you can see
here:

[https://www.youtube.com/watch?v=JUbXW_f03W0](https://www.youtube.com/watch?v=JUbXW_f03W0)

~~~
boothby
I'm a graph theorist, and I spend a lot of time on various optimization
problems (matchings, packings, coverings, Steiner trees, etc) doing VLSI.
AFAICT, it seems like GraphBLAS is geared for information processing about
data stored in a graph representation, and doesn't approach the problems I
need. Am I wrong?

Right now, the graphs I'm interested in are reasonably small (tens of
thousands of edges), and my oldschool approaches are good enough, but if my
employer's products continue their grow trajectory, we'll need to leverage
GPUs and TPUs if at all possible. Should I be learning about GraphBLAS?

~~~
bubblethink
GraphBLAS is meant to solve graph problems (i.e., generally the sort of ones
you are interested in, but more emphasis on parallel ones). Perhaps graph
analytics may be closer to what it does right now rather than graph theory. At
the very basic level, it exploits the matrix graph duality and casts graph
problems as matrix problems. For eg., BFS and SSSP are sparse matrix vector
multiplications over a suitably defined semiring. The benefit of this is that
you can use high performance matrix libraries. The downside is that not
everything can be done this way. At least not easily. You may find the book by
Kepner and Gilbert useful. Also look at cugraph and gunrock for GPU based
graph frameworks.

~~~
boothby
Time to hit the books, I guess. Thanks!

------
amelius
There is also a Python wrapper:

[https://github.com/michelp/pygraphblas](https://github.com/michelp/pygraphblas)

------
mark_l_watson
Sounds like a good idea with an added benefit that there are BLAS interfaces
for many programming languages.

------
ablmf
Can you guys give some real world examples of what graphs algorithms people
are actually using in applications?

~~~
a_bonobo
A lot of bioinformatics (my field) uses graph algorithms. DNA sequencing
machines don't give you entire genomes, they give you pieces. Re-assembling
the genome from those pieces is a prime graph algorithm target.

For example, Canu, one of the more popular current assemblers for PacBio and
MinION data, uses a best overlap graph
[https://genome.cshlp.org/content/27/5/722.long](https://genome.cshlp.org/content/27/5/722.long)

------
ajflores1604
For those like me who prefer watching talks, Tim Davis presented for Redis a
year or two ago.

[https://youtu.be/xnez6tloNSQ](https://youtu.be/xnez6tloNSQ)

------
chrisseaton
Is there a short example somewhere of what it looks like in practice?

~~~
ctchocula
There's an example here showing you don't need to write a shortest path
algorithm in terms of nodes and edges:
[https://github.com/gunrock/graphblast#usage](https://github.com/gunrock/graphblast#usage)

~~~
bubblethink
graphblas is nice in theory, but actual high performance code tends to be
quite messy and not always easily encapsulated by graphblas. For example, if
you want to store predecessors in SSSP, the semiring becomes quite involved,
and not easily transferable to GPUs etc. And there are other other
optimizations (direction optimizing BFS, delta stepping SSSP etc.) that are
not really a part of the algorithmic specification which also break the
encapsulation.

~~~
DocSparse
Give us time; we're still in the beginning stages of writing algorithms that
use it. If you dig through LAGraph, you'll find lots of messy prototypes, as
we experiment on various methods. Those are drafts, not polished results. Our
most recent methods are polished, extremely simple, yet very fast:

[https://github.com/GraphBLAS/LAGraph/blob/master/Source/Algo...](https://github.com/GraphBLAS/LAGraph/blob/master/Source/Algorithm/LAGraph_bc_batch4.c)

[https://github.com/GraphBLAS/LAGraph/blob/master/Source/Algo...](https://github.com/GraphBLAS/LAGraph/blob/master/Source/Algorithm/LAGraph_dnn.c)

[https://github.com/GraphBLAS/LAGraph/blob/master/Source/Algo...](https://github.com/GraphBLAS/LAGraph/blob/master/Source/Algorithm/LAGraph_tricount.c)
(that one has 6 algorithms inside)

[https://github.com/GraphBLAS/LAGraph/blob/master/Source/Algo...](https://github.com/GraphBLAS/LAGraph/blob/master/Source/Algorithm/LAGraph_pagerank3f.c)

We're working on the GPU version, and all the built-in semirings very work
nicely on the GPU. For user-defined semirings, we will need the user operators
defined as strings containing C code. Then they can all be done on the GPU
too.

------
wrnr
Is their a similar connection from algebra to hyper-graph (semantic graphs)?

~~~
michelpp
Hypergraphs can be represented with Incidence Matrices

[https://en.wikipedia.org/wiki/Incidence_matrix](https://en.wikipedia.org/wiki/Incidence_matrix)

the same algebra applies and GraphBLAS works well with them!

~~~
wrnr
Thanks, I get it, instead of using only 0 and 1, use the index to indicate
which property, and the index is also a node in the graph.

------
noobermin
The reference is written in C apparently...

