Skip to content

Commit a4246ee

Browse files
author
Will Kimmerer
committed
some docs changes, fix ComplexF64
1 parent 2057316 commit a4246ee

File tree

1 file changed

+34
-17
lines changed

1 file changed

+34
-17
lines changed

docs/src/index.md

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SuiteSparseGraphBLAS.jl
22

33
SuiteSparseGraphBLAS.jl is a package for sparse linear algebra on arbitrary semirings, with a particular focus on graph computations.
4-
It aims to provide a Julian wrapper over Tim Davis' SuiteSparse reference implementation of the GraphBLAS C specification.
4+
It aims to provide a Julian wrapper over Tim Davis' SuiteSparse:GraphBLAS reference implementation of the GraphBLAS C specification.
55

66
# Installation
77

@@ -21,49 +21,66 @@ Pkg.add("SuiteSparseGraphBLAS")
2121
The SuiteSparse:GraphBLAS binary is installed automatically as `SSGraphBLAS_jll`.
2222

2323
Then in the REPL or script `using SuiteSparseGraphBLAS` will import the package.
24+
2425
# Introduction
2526

2627
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.
2930

3031
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.
3132

3233
![BFS and Adjacency Matrix](./assets/AdjacencyBFS.png)
3334

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-
3835
## GBArrays
3936

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.
4141

4242
```@setup intro
4343
using SuiteSparseGraphBLAS
4444
using SparseArrays
4545
```
4646

4747
```@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)
4953
50-
GBMatrix{ComplexF64}(1000, 1000)
54+
A[1,5] === nothing
5155
```
5256

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.
5563

5664
!!! 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))`.
6176

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.
6378

6479
```@repl intro
80+
#GBMatrix(I::Vector{<:Integer}, J::Vector{<:Integer}, V::Vector{T})
6581
A = GBMatrix([1,1,2,2,3,4,4,5,6,7,7,7], [2,4,5,7,6,1,3,6,3,3,4,5], [1:12...])
6682
83+
#GBVector(I::Vector{<:Integer}, V::Vector{T})
6784
v = GBVector([4], [10])
6885
```
6986
## GraphBLAS Operations

0 commit comments

Comments
 (0)