GraphBLAS
   HOME

TheInfoList



OR:

GraphBLAS () is an
API An application programming interface (API) is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how to build ...
specification A specification often refers to a set of documented requirements to be satisfied by a material, design, product, or service. A specification is often a type of technical standard. There are different types of technical or engineering specificati ...
that defines standard building blocks for graph algorithms in the language of
linear algebra Linear algebra is the branch of mathematics concerning linear equations such as :a_1x_1+\cdots +a_nx_n=b, linear maps such as :(x_1, \ldots, x_n) \mapsto a_1x_1+\cdots +a_nx_n, and their representations in vector spaces and through matrix (mathemat ...
. GraphBLAS is built upon the notion that a
sparse matrix In numerical analysis and scientific computing, a sparse matrix or sparse array is a matrix in which most of the elements are zero. There is no strict definition regarding the proportion of zero-value elements for a matrix to qualify as sparse ...
can be used to represent graphs as either an
adjacency matrix In graph theory and computer science, an adjacency matrix is a square matrix used to represent a finite graph (discrete mathematics), graph. The elements of the matrix (mathematics), matrix indicate whether pairs of Vertex (graph theory), vertices ...
or an
incidence matrix In mathematics, an incidence matrix is a logical matrix that shows the relationship between two classes of objects, usually called an incidence relation. If the first class is ''X'' and the second is ''Y'', the matrix has one row for each element o ...
. The GraphBLAS specification describes how
graph operations In the mathematical field of graph theory, graph operations are operations which produce new graphs from initial ones. They include both unary (one input) and binary (two input) operations. Unary operations Unary operations create a new gra ...
(e.g. traversing and transforming graphs) can be efficiently implemented via linear algebraic methods (e.g.
matrix multiplication In mathematics, specifically in linear algebra, matrix multiplication is a binary operation that produces a matrix (mathematics), matrix from two matrices. For matrix multiplication, the number of columns in the first matrix must be equal to the n ...
) over different
semiring In abstract algebra, a semiring is an algebraic structure. Semirings are a generalization of rings, dropping the requirement that each element must have an additive inverse. At the same time, semirings are a generalization of bounded distribu ...
s. The development of GraphBLAS and its various implementations is an ongoing community effort, including representatives from industry, academia, and government research labs.


Background

Graph algorithms have long taken advantage of the idea that a graph can be represented as a
matrix Matrix (: matrices or matrixes) or MATRIX may refer to: Science and mathematics * Matrix (mathematics), a rectangular array of numbers, symbols or expressions * Matrix (logic), part of a formula in prenex normal form * Matrix (biology), the m ...
, and graph operations can be performed as
linear transformations In mathematics, and more specifically in linear algebra, a linear map (also called a linear mapping, linear transformation, vector space homomorphism, or in some contexts linear function) is a mapping V \to W between two vector spaces that pr ...
and other linear algebraic operations on sparse matrices. For example, matrix-vector multiplication can be used to perform a step in a
breadth-first search Breadth-first search (BFS) is an algorithm for searching a tree data structure for a node that satisfies a given property. It starts at the tree root and explores all nodes at the present depth prior to moving on to the nodes at the next dept ...
. The GraphBLAS specification (and the various
libraries A library is a collection of Book, books, and possibly other Document, materials and Media (communication), media, that is accessible for use by its members and members of allied institutions. Libraries provide physical (hard copies) or electron ...
that implement it) provides
data structures In computer science, a data structure is a data organization and storage format that is usually chosen for efficient access to data. More precisely, a data structure is a collection of data values, the relationships among them, and the functi ...
and functions to compute these linear algebraic operations. In particular, GraphBLAS specifies ''sparse'' matrix objects which map well to graphs where vertices are likely connected to relatively few neighbors (i.e. the degree of a vertex is significantly smaller than the total number of vertices in the graph). The specification also allows for the use of different semirings to accomplish operations in a variety of mathematical contexts. Originally motivated by the need for standardization in graph analytics, similar to its namesake BLAS, the GraphBLAS standard has also begun to interest people outside the graph community, including researchers in machine learning, and bioinformatics. GraphBLAS implementations have also been used in high-performance graph database applications such as RedisGraph.


Specification

The GraphBLAS specification has been in development since 2013, and has reached version 2.1.0 as of December 2023. While formally a specification for the
C programming language C (''pronounced'' '' – like the letter c'') is a general-purpose programming language. It was created in the 1970s by Dennis Ritchie and remains very widely used and influential. By design, C's features cleanly reflect the capabilities of ...
, a variety of programming languages have been used to develop implementations in the spirit of GraphBLAS, including C++,
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
, and Nvidia
CUDA In computing, CUDA (Compute Unified Device Architecture) is a proprietary parallel computing platform and application programming interface (API) that allows software to use certain types of graphics processing units (GPUs) for accelerated gene ...
.


Compliant implementations and language bindings

There are currently two fully-compliant reference implementations of the GraphBLAS specification. Bindings assuming a compliant specification exist for the Python,
MATLAB MATLAB (an abbreviation of "MATrix LABoratory") is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementat ...
, and Julia programming languages.


Linear algebraic foundations

The mathematical foundations of GraphBLAS are based in linear algebra and the duality between matrices and graphs.For additional mathematical background, see Each graph operation in GraphBLAS operates on a
semiring In abstract algebra, a semiring is an algebraic structure. Semirings are a generalization of rings, dropping the requirement that each element must have an additive inverse. At the same time, semirings are a generalization of bounded distribu ...
, which is made up of the following elements: * A scalar
addition Addition (usually signified by the Plus and minus signs#Plus sign, plus symbol, +) is one of the four basic Operation (mathematics), operations of arithmetic, the other three being subtraction, multiplication, and Division (mathematics), divis ...
operator (\oplus) * A scalar
multiplication Multiplication is one of the four elementary mathematical operations of arithmetic, with the other ones being addition, subtraction, and division (mathematics), division. The result of a multiplication operation is called a ''Product (mathem ...
operator (\otimes) * A
set Set, The Set, SET or SETS may refer to: Science, technology, and mathematics Mathematics *Set (mathematics), a collection of elements *Category of sets, the category whose objects and morphisms are sets and total functions, respectively Electro ...
(or domain) Note that the
zero element In mathematics, a zero element is one of several generalizations of the number zero to other algebraic structures. These alternate meanings may or may not reduce to the same thing, depending on the context. Additive identities An ''additive ide ...
(i.e. the element that represents the absence of an
edge Edge or EDGE may refer to: Technology Computing * Edge computing, a network load-balancing system * Edge device, an entry point to a computer network * Adobe Edge, a graphical development application * Microsoft Edge, a web browser developed by ...
in the graph) can also be reinterpreted. For example, the following algebras can be implemented in GraphBLAS: All the examples above satisfy the following two conditions in their respective domains: *
Additive identity In mathematics, the additive identity of a set that is equipped with the operation of addition is an element which, when added to any element in the set, yields . One of the most familiar additive identities is the number 0 from elementary ma ...
, a \oplus 0 = a * Multiplicative annihilation, a \otimes 0 = 0 For instance, a user can specify the min-plus algebra over the domain of double-precision floating point numbers with GrB_Semiring_new(&min_plus_semiring, GrB_MIN_FP64, GrB_PLUS_FP64).


Functionality

While the GraphBLAS specification generally allows significant flexibility in implementation, some functionality and implementation details are explicitly described: * GraphBLAS objects, including matrices and vectors, are opaque data structures. * Non-blocking execution mode, which permits lazy or
asynchronous Asynchrony is any dynamic far from synchronization. If and as parts of an asynchronous system become more synchronized, those parts or even the whole system can be said to be in sync. Asynchrony or asynchronous may refer to: Electronics and com ...
evaluation of certain operations. * Masked assignment, denoted A\langle M \rangle = B, which assigns elements of matrix B to matrix A only in positions where the mask matrix M is non-zero. The GraphBLAS specification also prescribes that library implementations be thread-safe.


Example code

The following is a GraphBLAS 2.1-compliant example of a
breadth-first search Breadth-first search (BFS) is an algorithm for searching a tree data structure for a node that satisfies a given property. It starts at the tree root and explores all nodes at the present depth prior to moving on to the nodes at the next dept ...
in the
C programming language C (''pronounced'' '' – like the letter c'') is a general-purpose programming language. It was created in the 1970s by Dennis Ritchie and remains very widely used and influential. By design, C's features cleanly reflect the capabilities of ...
. #include #include #include #include #include "GraphBLAS.h" /* * Given a boolean n x n adjacency matrix A and a source vertex s, performs a BFS traversal * of the graph and sets v to the level in which vertex i is visited (v

1). * If i is not reachable from s, then v = 0 does not have a stored element. * Vector v should be uninitialized on input. */ GrB_Info BFS(GrB_Vector *v, GrB_Matrix A, GrB_Index s)


See also

* Basic Linear Algebra Subprograms (BLAS) * LEMON Graph Library


References

{{reflist


External links


GraphBLAS Forum
Numerical linear algebra Numerical software Graph description languages