GraphBLAS / graphblas-api-c

Other
7 stars 3 forks source link

MIN_ONEB semiring #76

Open eriknw opened 1 year ago

eriknw commented 1 year ago

A common use case for the ANY monoid (see #21) is in the ANY_PAIR semiring that is currently in SuiteSparse:GraphBLAS. The PAIR operator is called ONEB in the C spec, and, mathematically, ~FIRST_ONEB~ MIN_ONEB is the same as ANY_ONEB. So, the simplest way to support most use cases for the ANY monoid is to add the ~FIRST_ONEB~ MIN_ONEB semiring to the C spec (possibly in 2.1).

DrTimothyAldenDavis commented 1 year ago

Using FIRST as a monoid would break GraphBLAS badly. MIN_ONEB would be better and has the same effect.

eriknw commented 1 year ago

bwahaha, yes, my bad. MIN_ONEB

DrTimothyAldenDavis commented 1 year ago

Internally, if I see a MIN_ONEB semiring (or many many other cases), I convert it into my ANY_PAIR_ISO semiring. That semiring is purely symbolic, and there are many semirings that map directly to it.

See https://github.com/DrTimothyAldenDavis/GraphBLAS/blob/stable/Source/GB_iso_AxB.c . For any GrB_mxm operation where I can tell that C is iso, I call my ANY_PAIR_ISO method, and compute the single iso value of C in GB_iso_AxB.c.

TIMES_PAIR_INT32 for example, does the same thing. C(i,j) = 1 in this case.

DrTimothyAldenDavis commented 1 year ago

The one thing that ANY provides that MIN cannot, is its use in the BFS where I can get different results, non-deterministically, but where all results are acceptable. In this case, ANY is much faster than MIN.