You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SuiteSparse:GraphBLAS binary is installed automatically as `SSGraphBLAS_jll`.
22
22
23
23
Then in the REPL or script `using SuiteSparseGraphBLAS` will import the package.
24
+
24
25
# Introduction
25
26
26
27
GraphBLAS harnesses the well-understood duality between graphs and matrices.
27
-
Specifically a graph can be represented by its[adjacency matrix](https://en.wikipedia.org/wiki/Adjacency_matrix),[incidence matrix](https://en.wikipedia.org/wiki/Incidence_matrix), or one of the many variations on those formats.
28
-
With this matrix representation in hand we have a method to operate on the graph using linear algebra operations on the matrix.
28
+
Specifically a graph can be represented by the[adjacency matrix](https://en.wikipedia.org/wiki/Adjacency_matrix) and/or[incidence matrix](https://en.wikipedia.org/wiki/Incidence_matrix), or one of the many variations on those formats.
29
+
With this matrix representation in hand we have a method to operate on the graph with linear algebra.
29
30
30
31
Below is an example of the adjacency matrix of a directed graph, and finding the neighbors of a single vertex using basic matrix-vector multiplication on the arithemtic semiring.
31
32
32
33

33
34
34
-
# GraphBLAS Concepts
35
-
36
-
The three primary components of GraphBLAS are: matrices, operators, and operations. Operators include monoids, binary operators, and semirings. Operations include the typical linear algebraic operations like matrix multiplication as well as indexing operations.
37
-
38
35
## GBArrays
39
36
40
-
SuiteSparseGraphBLAS.jl provides `GBVector` and `GBMatrix` array types which are subtypes of `SparseArrays.AbstractSparseVector` and `SparseArrays.AbstractSparseMatrix` respectively.
37
+
The core SuiteSparseGraphBLAS.jl array types are `GBVector` and `GBMatrix` which are subtypes `SparseArrays.AbstractSparseVector` and `SparseArrays.AbstractSparseMatrix` respectively.
38
+
39
+
!!! note "GBArray"
40
+
These docs will often refer to the `GBArray` type, which is the union of `GBVector`, `GBMatrix` and their lazy Transpose objects.
41
41
42
42
```@setup intro
43
43
using SuiteSparseGraphBLAS
44
44
using SparseArrays
45
45
```
46
46
47
47
```@repl intro
48
-
GBVector{Float64}(13)
48
+
# create a size 13 empty sparse vector with Float64 elements.
49
+
v = GBVector{Float64}(13)
50
+
51
+
# create a 1000 x 1000 empty sparse matrix with ComplexF64 elements.
52
+
A = GBMatrix{ComplexF64}(1000, 1000)
49
53
50
-
GBMatrix{ComplexF64}(1000, 1000)
54
+
A[1,5] === nothing
51
55
```
52
56
53
-
GraphBLAS array types are opaque to the user in order to allow the library author to choose the best storage format.
54
-
SuiteSparse:GraphBLAS takes advantage of this by storing matrices in one of four formats: dense, bitmap, sparse-compressed, or hypersparse-compressed; and in either row or column major orientation.
57
+
Here we can already see several differences compared to `SparseArrays.SparseMatrixCSC`.
58
+
59
+
The first is that `A` is stored in `hypersparse` format, and by row.
60
+
61
+
`GBArrays` are (technically) opaque to the user in order to allow the library author to choose the best storage format.\
62
+
GraphBLAS takes advantage of this by storing matrices in one of four formats: `dense`, `bitmap`, `sparse-compressed`, or `hypersparse-compressed`; and in either `row` or `column` major orientation.
55
63
56
64
!!! warning "Default Orientation"
57
-
The default orientation of a `GBMatrix` is by-row, the opposite of Julia arrays, for greater speed
58
-
in certain operations. However, a `GBMatrix` constructed from a `SparseMatrixCSC` or
59
-
`Matrix` will be stored by-column. The orientation of a `GBMatrix` can be modified using
60
-
`gbset(A, :format, :byrow)` or `gbset(A, :format, :bycol)`.
65
+
The default orientation of a `GBMatrix` is by-row, the opposite of Julia arrays. However, a `GBMatrix` constructed from a `SparseMatrixCSC` or
66
+
`Matrix` will be stored by-column.\
67
+
The orientation of a `GBMatrix` can be modified using
68
+
`gbset(A, :format, :byrow)` or `gbset(A, :format, :bycol)`, and queried by `gbget(A, :format)`
69
+
70
+
Information about storage formats, orientation, conversion, construction and more can be found in [Arrays](@ref).
71
+
72
+
The second difference is that a `GBArray` doesn't assume the fill-in value of a sparse array.\
73
+
Since `A[1,5]` isn't stored in the matrix (it's been "compressed" out), we return `nothing`.\
74
+
75
+
This matches the GraphBLAS spec, where `NO_VALUE` is returned, rather than `zero(eltype(A))`.
61
76
62
-
The matrix and vector in the graphic above can be constructed as follows:
77
+
An empty matrix and vector won't do us much good, so let's see how to construct the matrix and vector from the graphic above. Both `A` and `v` below are constructed from coordinate format or COO.
0 commit comments