1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900
|
//------------------------------------------------------------------------------
// LAGraphX.h: include file for LAGraph experimental code
//------------------------------------------------------------------------------
// LAGraph, (c) 2019-2023 by The LAGraph Contributors, All Rights Reserved.
// SPDX-License-Identifier: BSD-2-Clause
//
// For additional details (including references to third party source code and
// other files) see the LICENSE file or contact permission@sei.cmu.edu. See
// Contributors.txt for a full list of contributors. Created, in part, with
// funding and support from the U.S. Government (see Acknowledgments.txt file).
// DM22-0790
//------------------------------------------------------------------------------
#ifndef LAGRAPHX_H
#define LAGRAPHX_H
#include <GraphBLAS.h>
#include <LAGraph.h>
#if ( _MSC_VER && !__INTEL_COMPILER && LGX_DLL )
#ifdef LGX_LIBRARY
// compiling LAGraph itself, exporting symbols to user apps
#define LAGRAPHX_PUBLIC __declspec ( dllexport )
#else
// compiling the user application, importing symbols from LAGraph
#define LAGRAPHX_PUBLIC __declspec ( dllimport )
#endif
#else
// for other compilers
#define LAGRAPHX_PUBLIC
#endif
//==============================================================================
// for C++ applications:
//==============================================================================
#if defined ( __cplusplus )
extern "C"
{
#endif
//==============================================================================
// Experimental methods: in experimental/algorithm and experimental/utility
//==============================================================================
// Do not rely on these in production. These methods are still under
// development, and is intended only for illustration or testing, not
// benchmarking. Do not use for benchmarking without asking the authors.
//------------------------------------------------------------------------------
// LAGraph_Random_*: Random number generator
//------------------------------------------------------------------------------
LAGRAPHX_PUBLIC
int LAGraph_Random_Init
(
char *msg
) ;
LAGRAPHX_PUBLIC
int LAGraph_Random_Finalize
(
char *msg
) ;
#if defined ( COVERAGE )
// for testing only
LAGRAPHX_PUBLIC extern bool random_hack ;
#endif
LAGRAPHX_PUBLIC
int LAGraph_Random_Seed // construct a random seed vector
(
// input/output
GrB_Vector Seed, // vector of random number seeds, normally GrB_UINT64
// input
uint64_t seed, // scalar input seed
char *msg
) ;
LAGRAPHX_PUBLIC
int LAGraph_Random_Next // advance to next random vector
(
// input/output
GrB_Vector Seed,
char *msg
) ;
LAGRAPHX_PUBLIC
GrB_Info LAGraph_Random_Matrix // random matrix of any built-in type
(
// output
GrB_Matrix *A, // A is constructed on output
// input
GrB_Type type, // type of matrix to construct
GrB_Index nrows, // # of rows of A
GrB_Index ncols, // # of columns of A
double density, // density: build a sparse matrix with
// density*nrows*cols values if not INFINITY;
// build a dense matrix if INFINITY.
uint64_t seed, // random number seed
char *msg
) ;
//****************************************************************************
// binary file I/O
//****************************************************************************
// The LAGraph *.lagraph file consists of an ASCII JSON header, followed by
// one or more serialized "blobs" created by GrB_Matrix_serialize (or
// GxB_Matrix_serialize if using SuiteSparse:GraphBLAS). The file can only be
// read back into LAGraph when using the same GraphBLAS library used to create
// it.
// To create a binary file containing one or more GrB_Matrix objects, the user
// application must first open the file f, create the ascii JSON header with
// LAGraph_SWrite_Header*, and then write one or more binary serialized
// GrB_Matrix blobs from using LAGraph_SWrite_Matrix.
// Example:
/*
// serialize the matrices A (of type GrB_FP64) and B (of type GrB_BOOL)
void *Ablob, *Bblob ;
GrB_Index Ablob_size, Bblob_size ;
GxB_Matrix_serialize (&Ablob, &Ablob_size, A, NULL) ;
GxB_Matrix_serialize (&Bblob, &Bblob_size, B, NULL) ;
// open the file and write the JSON header
FILE *f = fopen ("mymatrices.lagraph", "w") ;
LAGraph_SWrite_HeaderStart (f, "mystuff", msg) ;
LAGraph_SWrite_HeaderItem (f, LAGraph_matrix_kind, "A", "double", 0,
Ablob_size, msg) ;
LAGraph_SWrite_HeaderItem (f, LAGraph_matrix_kind, "B", "bool", 0,
Bblob_size, msg) ;
LAGraph_SWrite_HeaderEnd (f, msg) ;
// write the matrices in binary
LAGraph_SWrite_Item (f, Ablob, Ablob_size, msg) ;
LAGraph_SWrite_Item (f, Bblob, Bblob_size, msg) ;
fclose (f) ;
*/
typedef enum
{
LAGraph_unknown_kind = -1, // unknown kind
LAGraph_matrix_kind = 0, // a serialized GrB_Matrix
LAGraph_vector_kind = 1, // a serialized GrB_Vector (SS:GrB only)
LAGraph_text_kind = 2, // text (char *), possibly compressed
}
LAGraph_Contents_kind ;
typedef struct
{
// serialized matrix/vector, or pointer to text, and its size
void *blob ;
size_t blob_size ;
// kind of item: matrix, vector, text, or unknown
LAGraph_Contents_kind kind ;
// if kind is text: compression used
// -1: none, 0: default for library, 1000: LZ4, 200x: LZ4HC:x
int compression ;
// name of the object
char name [LAGRAPH_MAX_NAME_LEN+4] ;
// if kind is matrix or vector: type name
char type_name [LAGRAPH_MAX_NAME_LEN+4] ;
}
LAGraph_Contents ;
LAGRAPHX_PUBLIC
int LAGraph_SWrite_HeaderStart // write the first part of the JSON header
(
FILE *f, // file to write to
const char *name, // name of this collection of matrices
char *msg
) ;
LAGRAPHX_PUBLIC
int LAGraph_SWrite_HeaderItem // write a single item to the JSON header
(
// inputs:
FILE *f, // file to write to
LAGraph_Contents_kind kind, // matrix, vector, or text
const char *name, // name of the matrix/vector/text; matrices from
// sparse.tamu.edu use the form "Group/Name"
const char *type, // name of type of the matrix/vector
int compression, // text compression method
GrB_Index blob_size, // exact size of serialized blob for this item
char *msg
) ;
LAGRAPHX_PUBLIC
int LAGraph_SWrite_HeaderItem // write a single item to the JSON header
(
// inputs:
FILE *f, // file to write to
LAGraph_Contents_kind kind, // matrix, vector, or text
const char *name, // name of the matrix/vector/text; matrices from
// sparse.tamu.edu use the form "Group/Name"
const char *type, // name of type of the matrix/vector
// todo: text not yet supported by LAGraph_SWrithe_HeaderItem
int compression, // text compression method
GrB_Index blob_size, // exact size of serialized blob for this item
char *msg
) ;
LAGRAPHX_PUBLIC
int LAGraph_SWrite_HeaderEnd // write the end of the JSON header
(
FILE *f, // file to write to
char *msg
) ;
LAGRAPHX_PUBLIC
int LAGraph_SWrite_Item // write the serialized blob of a matrix/vector/text
(
// input:
FILE *f, // file to write to
const void *blob, // serialized blob from G*B_Matrix_serialize
GrB_Index blob_size, // exact size of the serialized blob
char *msg
) ;
LAGRAPHX_PUBLIC
int LAGraph_SRead // read a set of matrices from a *.lagraph file
(
FILE *f, // file to read from
// output
char **collection, // name of collection (allocated string)
LAGraph_Contents **Contents, // array contents of contents
GrB_Index *ncontents, // # of items in the Contents array
char *msg
) ;
LAGRAPHX_PUBLIC
void LAGraph_SFreeContents // free the Contents returned by LAGraph_SRead
(
// input/output
LAGraph_Contents **Contents, // array of size ncontents
GrB_Index ncontents
) ;
LAGRAPHX_PUBLIC
int LAGraph_SSaveSet // save a set of matrices from a *.lagraph file
(
// inputs:
char *filename, // name of file to write to
GrB_Matrix *Set, // array of GrB_Matrix of size nmatrices
GrB_Index nmatrices, // # of matrices to write to *.lagraph file
// todo: handle vectors and text in LAGraph_SSaveSet
char *collection, // name of this collection of matrices
char *msg
) ;
int LAGraph_SLoadSet // load a set of matrices from a *.lagraph file
(
// input:
char *filename, // name of file to read from
// outputs:
GrB_Matrix **Set_handle, // array of GrB_Matrix of size nmatrices
GrB_Index *nmatrices_handle, // # of matrices loaded from *.lagraph file
// todo: handle vectors and text in LAGraph_SLoadSet
// GrB_Vector **Set_handle, // array of GrB_Vector of size nvector
// GrB_Index **nvectors_handle, // # of vectors loaded from *.lagraph file
// char **Text_handle, // array of pointers to (char *) strings
// GrB_Index **ntext_handle, // # of texts loaded from *.lagraph file
char **collection_handle, // name of this collection of matrices
char *msg
) ;
LAGRAPHX_PUBLIC
void LAGraph_SFreeSet // free a set of matrices
(
// input/output
GrB_Matrix **Set_handle, // array of GrB_Matrix of size nmatrices
GrB_Index nmatrices // # of matrices in the set
) ;
//****************************************************************************
// Algorithms
//****************************************************************************
//****************************************************************************
/**
* Given a symmetric graph A with no-self edges, compute all k-trusses of A.
*
* @param[out] Cset size n, output k-truss subgraphs.
* @param[out] kmax smallest k where k-truss is empty
* @param[out] ntris Array of size n (on input), ntris [k] is num triangles in k-truss
* @param[out] nedges Array of size n (on input), nedges [k] is num edges in k-truss
* @param[out] nstepss Array of size n (on input), nstepss [k] is num steps for k-truss
* @param[in] G input graph, A, not modified. Must be undirected
* or directed with symmetric structure, no self edges.
* @param[in,out] msg any error messages.
*
* @retval GrB_SUCCESS if completed successfully (equal or not)
* @retval GrB_NULL_POINTER if kmax, ntris, nedges, nsteps is NULL
*/
LAGRAPHX_PUBLIC
int LAGraph_AllKTruss // compute all k-trusses of a graph
(
// outputs
GrB_Matrix *Cset, // size n, output k-truss subgraphs
int64_t *kmax, // smallest k where k-truss is empty
int64_t *ntris, // size max(n,4), ntris [k] is #triangles in k-truss
int64_t *nedges, // size max(n,4), nedges [k] is #edges in k-truss
int64_t *nstepss, // size max(n,4), nstepss [k] is #steps for k-truss
// input
LAGraph_Graph G, // input graph
char *msg
) ;
//****************************************************************************
/**
* Given an undirected graph G with no-self edges, LAGraph_KTruss finds the
* k-truss subgraph of G.
*
* @param[out] C k-truss subgraph, of type GrB_UINT32
* @param[in] G input graph, not modified
* @param[in] k the truss to find
* @param[in,out] msg any error messages.
*
* @retval GrB_SUCCESS if completed successfully (equal or not)
* @retval GrB_NULL_POINTER if C or C_type is NULL
* @return Any GraphBLAS errors that may have been encountered
*/
LAGRAPHX_PUBLIC
int LAGraph_KTruss // compute the k-truss of a graph
(
// outputs:
GrB_Matrix *C, // output k-truss subgraph, C
// inputs:
LAGraph_Graph G, // input graph
uint32_t k, // find the k-truss, where k >= 3
char *msg
) ;
//****************************************************************************
// Connected components
//****************************************************************************
/**
* Determine connected components in an undirected graph.
*
* @param[out] result array of component identifiers for each vertex (allocated
* by the algorithm, ownership returned to caller).
* @param[in] A the graph (symmetric)
* @param[in] sanitize If true, test to ensure A is symmetric
* @param[in,out] msg any error messages.
*
* @retval GrB_SUCCESS if completed successfully
* @retval GrB_NULL_POINTER if result is NULL
*/
LAGRAPHX_PUBLIC
int LAGraph_cc_lacc (
GrB_Vector *result,
GrB_Matrix A,
bool sanitize,
char *msg
) ;
//****************************************************************************
// Bellman Ford variants
//****************************************************************************
/**
* Bellman-Ford single source shortest paths, returning just the shortest path
* lengths.
*
* @param[out] pd_output the pointer to the vector of distance (created internally)
* @param[in] A matrix for the graph
* @param[in] s index of the source
*
* @retval GrB_SUCCESS if completed successfully
* @retval GrB_NULL_POINTER If pd_output or A is NULL
* @retval GrB_INVALID_VALUE if A is not square, s is not a valid vertex index
* @retval GrB_NO_VALUE if A has a negative weight cycle
*/
LAGRAPHX_PUBLIC
GrB_Info LAGraph_BF_basic
(
GrB_Vector *pd_output,
const GrB_Matrix A,
const GrB_Index s
) ;
/**
* Bellman-Ford single source shortest paths, returning just the shortest path
* lengths.
*
* @param[out] pd_output the pointer to the vector of distance (created internally)
* @param[in] A matrix for the graph (optional-ish)
* @param[in] AT transpose of A (optional-ish)
* @param[in] s index of the source
*
* @retval GrB_SUCCESS if completed successfully
* @retval GrB_NULL_POINTER If pd_output is NULL or both A and AT are NULL
* @retval GrB_INVALID_VALUE if A is not square, s is not a valid vertex index
* @retval GrB_NO_VALUE if A has a negative weight cycle
*
*/
LAGRAPHX_PUBLIC
GrB_Info LAGraph_BF_basic_pushpull
(
GrB_Vector *pd_output,
const GrB_Matrix A,
const GrB_Matrix AT,
const GrB_Index s
) ;
/**
* Bellman-Ford single source shortest paths, returning just the shortest path
* lengths.
*
* @param[out] pd_output the pointer to the vector of distance (created internally)
* @param[in] AT transposed adjacency matrix for the graph
* @param[in] s index of the source
*
* @retval GrB_SUCCESS if completed successfully
* @retval GrB_NULL_POINTER If pd_output or AT is NULL
* @retval GrB_INVALID_VALUE if A is not square, s is not a valid vertex index
* @retval GrB_NO_VALUE if A has a negative weight cycle
*
*/
LAGRAPHX_PUBLIC
GrB_Info LAGraph_BF_basic_mxv
(
GrB_Vector *pd_output, //the pointer to the vector of distance
const GrB_Matrix AT, //transposed adjacency matrix for the graph
const GrB_Index s //given index of the source
) ;
/**
* Bellman-Ford single source shortest paths, returning both the path lengths
* and the shortest-path tree.
*
* @param[out] pd_output the pointer to the vector of distance (created internally)
* @param[out] ppi_output the pointer to the vector of parent (created internally)
* @param[out] ph_output the pointer to the vector of hops (created internally)
* @param[in] A adjacency matrix for the graph
* @param[in] s index of the source
*
* @retval GrB_SUCCESS if completed successfully
* @retval GrB_NULL_POINTER If pd_output, ppi_output, ph_output, or A is NULL
* @retval GrB_INVALID_VALUE if A is not square, s is not a valid vertex index
* @retval GrB_OUT_OF_MEMORY if allocation fails
* @retval GrB_NO_VALUE if A has a negative weight cycle
*
*/
LAGRAPHX_PUBLIC
GrB_Info LAGraph_BF_full
(
GrB_Vector *pd_output,
GrB_Vector *ppi_output,
GrB_Vector *ph_output,
const GrB_Matrix A,
const GrB_Index s
) ;
/**
* Bellman-Ford single source shortest paths, returning both the path lengths
* and the shortest-path tree.
*
* @param[out] pd_output the pointer to the vector of distance (created internally)
* @param[out] ppi_output the pointer to the vector of parent (created internally)
* @param[out] ph_output the pointer to the vector of hops (created internally)
* @param[in] A adjacency matrix for the graph
* @param[in] s index of the source
*
* @retval GrB_SUCCESS if completed successfully
* @retval GrB_NULL_POINTER If pd_output, ppi_output, ph_output, or A is NULL
* @retval GrB_INVALID_VALUE if A is not square, s is not a valid vertex index
* @retval GrB_OUT_OF_MEMORY if allocation fails
* @retval GrB_NO_VALUE if A has a negative weight cycle
*
*/
LAGRAPHX_PUBLIC
GrB_Info LAGraph_BF_full1
(
GrB_Vector *pd_output,
GrB_Vector *ppi_output,
GrB_Vector *ph_output,
const GrB_Matrix A,
const GrB_Index s
) ;
/**
* Bellman-Ford single source shortest paths, returning both the path lengths
* and the shortest-path tree.
*
* @param[out] pd_output the pointer to the vector of distance (created internally)
* @param[out] ppi_output the pointer to the vector of parent (created internally)
* @param[out] ph_output the pointer to the vector of hops (created internally)
* @param[in] A adjacency matrix for the graph
* @param[in] s index of the source
*
* @retval GrB_SUCCESS if completed successfully
* @retval GrB_NULL_POINTER If pd_output, ppi_output, ph_output, or A is NULL
* @retval GrB_INVALID_VALUE if A is not square, s is not a valid vertex index
* @retval GrB_OUT_OF_MEMORY if allocation fails
* @retval GrB_NO_VALUE if A has a negative weight cycle
*
*/
LAGRAPHX_PUBLIC
GrB_Info LAGraph_BF_full1a
(
GrB_Vector *pd_output,
GrB_Vector *ppi_output,
GrB_Vector *ph_output,
const GrB_Matrix A,
const GrB_Index s
) ;
/**
* Bellman-Ford single source shortest paths, returning both the path lengths
* and the shortest-path tree.
*
* @param[out] pd_output the pointer to the vector of distance (created internally)
* @param[out] ppi_output the pointer to the vector of parent (created internally)
* @param[out] ph_output the pointer to the vector of hops (created internally)
* @param[in] A adjacency matrix for the graph
* @param[in] s index of the source
*
* @retval GrB_SUCCESS if completed successfully
* @retval GrB_NULL_POINTER If pd_output, ppi_output, ph_output, or A is NULL
* @retval GrB_INVALID_VALUE if A is not square, s is not a valid vertex index
* @retval GrB_OUT_OF_MEMORY if allocation fails
* @retval GrB_NO_VALUE if A has a negative weight cycle
*
*/
LAGRAPHX_PUBLIC
GrB_Info LAGraph_BF_full2
(
GrB_Vector *pd_output, //the pointer to the vector of distance
GrB_Vector *ppi_output, //the pointer to the vector of parent
GrB_Vector *ph_output, //the pointer to the vector of hops
const GrB_Matrix A, //matrix for the graph
const GrB_Index s //given index of the source
) ;
/**
* Bellman-Ford single source shortest paths, returning both the path lengths
* and the shortest-path tree.
*
* @param[out] pd_output the pointer to the vector of distance (created internally)
* @param[out] ppi_output the pointer to the vector of parent (created internally)
* @param[out] ph_output the pointer to the vector of hops (created internally)
* @param[in] AT transpose of the adjacency matrix for the graph
* @param[in] s index of the source
*
* @retval GrB_SUCCESS if completed successfully
* @retval GrB_NULL_POINTER If pd_output, ppi_output, ph_output, or AT is NULL
* @retval GrB_INVALID_VALUE if A is not square, s is not a valid vertex index
* @retval GrB_OUT_OF_MEMORY if allocation fails
* @retval GrB_NO_VALUE if A has a negative weight cycle
*
*/
LAGRAPHX_PUBLIC
GrB_Info LAGraph_BF_full_mxv
(
GrB_Vector *pd_output,
GrB_Vector *ppi_output,
GrB_Vector *ph_output,
const GrB_Matrix AT,
const GrB_Index s
) ;
/**
* Bellman-Ford single source shortest paths, returning both the path lengths
* and the shortest-path tree (integer weights).
*
* @param[out] pd pointer to distance vector d, d(k) = shortest distance
* between s and k if k is reachable from s
* @param[out] ppi pointer to parent index vector pi, pi(k) = parent of
* node k in the shortest path tree
* @param[in] s index of the source
* @param[in] n number of nodes
* @param[in] nz number of edges
* @param[in] Ilist row index vector (size n)
* @param[in] J column index vector (size nz)
* @param[in] W weight vector (size nz), W(i) = weight of edge
* (Ilist(i),J(i))
*
* @retval GrB_SUCCESS if completed successfully
* @retval GrB_NULL_POINTER If pd, ppi, Ilist, J, or W is NULL
* @retval GrB_INVALID_VALUE if s is not a valid vertex index
* @retval GrB_OUT_OF_MEMORY if allocation fails.
* @retval GrB_NO_VALUE if A has a negative weight cycle
*
*/
LAGRAPHX_PUBLIC
GrB_Info LAGraph_BF_pure_c
(
int32_t **pd,
int64_t **ppi,
const int64_t s,
const int64_t n,
const int64_t nz,
const int64_t *Ilist,
const int64_t *J,
const int32_t *W
) ;
/**
* Bellman-Ford single source shortest paths, returning both the path lengths
* and the shortest-path tree (double weights).
*
* @param[out] pd pointer to distance vector d, d(k) = shortest distance
* between s and k if k is reachable from s
* @param[out] ppi pointer to parent index vector pi, pi(k) = parent of
* node k in the shortest path tree
* @param[in] s index of the source
* @param[in] n number of nodes
* @param[in] nz number of edges
* @param[in] Ilist row index vector (size n)
* @param[in] J column index vector (size nz)
* @param[in] W weight vector (size nz), W(i) = weight of edge
* (Ilist(i),J(i))
*
* @retval GrB_SUCCESS if completed successfully
* @retval GrB_NULL_POINTER If pd, ppi, Ilist, J, or W is NULL
* @retval GrB_INVALID_VALUE if s is not a valid vertex index
* @retval GrB_OUT_OF_MEMORY if allocation fails.
* @retval GrB_NO_VALUE if A has a negative weight cycle
*
*/
LAGRAPHX_PUBLIC
GrB_Info LAGraph_BF_pure_c_double
(
double **pd,
int64_t **ppi,
const int64_t s,
const int64_t n,
const int64_t nz,
const int64_t *Ilist,
const int64_t *J,
const double *W
) ;
//****************************************************************************
/**
* Community detection using label propagation algorithm
*
* @param[out] CDLP_handle community vector
* @param[in] A adjacency matrix for the graph
* @param[in] symmetric denote whether the matrix is symmetric
* @param[in] sanitize if true, verify that A is binary
* @param[in] itermax max number of iterations (0 computes nothing)
* @param[out] t array of two doubles allocated by caller:
* [0]=sanitize time, [1]=cdlp time in seconds
* @param[in,out] msg any error messages.
*
* @retval GrB_SUCCESS if completed successfully
* @retval GrB_NULL_POINTER If t or CDLP_handle is NULL
* @retval GrB_INVALID_OBJECT If A is not stored in CSR format
* @retval GrB_OUT_OF_MEMORY if allocation fails.
* @retval GrB_NO_VALUE if A has a negative weight cycle
*/
LAGRAPHX_PUBLIC
int LAGraph_cdlp
(
GrB_Vector *CDLP_handle,
const GrB_Matrix A,
bool symmetric,
bool sanitize,
int itermax,
double *t,
char *msg
) ;
//****************************************************************************
/**
* Sparse deep neural network inference. Performs ReLU inference using input
* feature vectors Y0.
*
* @param[out] Yhandle Y, created on output
* @param[in] W W [0..nlayers-1], each nneurons-by-nneurons
* @param[in] Bias Bias [0..nlayers-1], diagonal nneurons-by-nneurons
* @param[in] nlayers number of layers
* @param[in] Y0 input features: nfeatures-by-nneurons
*
* @retval GrB_SUCCESS if completed successfully
* @retval GrB_NOT_IMPLEMENTED vanilla version has not been implemented yet
* @retval GrB_NULL_POINTER If Yhandle, W, Bias, or Y0 is NULL
* @retval GrB_DOMAIN_MISMATCH if type of Y0 is not FP32 or FP64, or the types of
* W or Bias arent the same as Y0
*/
LAGRAPHX_PUBLIC
GrB_Info LAGraph_dnn
(
// output
GrB_Matrix *Yhandle,
// input: not modified
GrB_Matrix *W,
GrB_Matrix *Bias,
int nlayers,
GrB_Matrix Y0
) ;
//****************************************************************************
/**
* Compute all-pairs shortest paths using Floyd-Warshall method
*
* @param[in] G input graph, with edge weights
* @param[out] D output graph, created on output
* @param[out] D_type type of scalar stored in D (see source for explanation)
*
* @retval GrB_SUCCESS if completed successfully
* @retval GrB_NOT_IMPLEMENTED vanilla version has not been implemented yet
* @retval GrB_NULL_POINTER If D or D_type is NULL
* @retval GrB_INVALID_VALUE If G is not square
*/
LAGRAPHX_PUBLIC
GrB_Info LAGraph_FW
(
const GrB_Matrix G,
GrB_Matrix *D,
GrB_Type *D_type
) ;
//****************************************************************************
/**
* Compute the local clustering coefficient for all nodes in a graph.
*
* @param[out] LCC_handle output vector holding coefficients
* @param[in] A adjacency matrix for the graph
* @param[in] symmetric denote whether the matrix is symmetric
* @param[in] sanitize if true, verify that A is binary
* @param[out] t array of two doubles
* [0]=sanitize time, [1]=lcc time in seconds
* @param[in,out] msg any error messages.
*
* @retval GrB_SUCCESS if completed successfully
* @retval GrB_NOT_IMPLEMENTED vanilla version has not been implemented yet
* @retval GrB_NULL_POINTER If LCC_handle or LCC_type is NULL
* @retval GrB_INVALID_VALUE If A is not stored in CSR format
*/
LAGRAPHX_PUBLIC
int LAGraph_lcc // compute lcc for all nodes in A
(
GrB_Vector *LCC_handle, // output vector
const GrB_Matrix A, // input matrix
bool symmetric, // if true, the matrix is symmetric
bool sanitize, // if true, ensure A is binary
double t [2], // t [0] = sanitize time, t [1] = lcc time,
// in seconds
char *msg
) ;
//****************************************************************************
LAGRAPHX_PUBLIC
int LAGraph_msf
(
GrB_Matrix *result, // output: an unsymmetrical matrix, the spanning forest
GrB_Matrix A, // input matrix
bool sanitize, // if true, ensure A is symmetric
char *msg
) ;
//****************************************************************************
LAGRAPHX_PUBLIC
int LAGraph_scc (
GrB_Vector *result, // output: array of component identifiers
GrB_Matrix A, // input matrix
char *msg
) ;
//****************************************************************************
LAGRAPHX_PUBLIC
int LAGraph_VertexCentrality_Triangle // vertex triangle-centrality
(
// outputs:
GrB_Vector *centrality, // centrality(i): triangle centrality of i
uint64_t *ntriangles, // # of triangles in the graph
// inputs:
int method, // 0, 1, 2, or 3
LAGraph_Graph G, // input graph
char *msg
) ;
//****************************************************************************
LAGRAPHX_PUBLIC
int LAGraph_MaximalIndependentSet // maximal independent set
(
// outputs:
GrB_Vector *mis, // mis(i) = true if i is in the set
// inputs:
LAGraph_Graph G, // input graph
uint64_t seed, // random number seed
GrB_Vector ignore_node, // if NULL, no nodes are ignored. Otherwise
// ignore_node(i) = true if node i is to be
// ignored, and not treated as a candidate
// added to maximal independent set.
char *msg
) ;
LAGRAPHX_PUBLIC
int LG_CC_FastSV5 // SuiteSparse:GraphBLAS method, with GxB extensions
(
// output
GrB_Vector *component, // output: array of component identifiers
// inputs
LAGraph_Graph G, // input graph, modified then restored
char *msg
) ;
//------------------------------------------------------------------------------
// kcore algorithms
//------------------------------------------------------------------------------
LAGRAPHX_PUBLIC
int LAGraph_KCore_All
(
// outputs:
GrB_Vector *decomp, // kcore decomposition
uint64_t *kmax,
// inputs:
LAGraph_Graph G, // input graph
char *msg
) ;
LAGRAPHX_PUBLIC
int LAGraph_KCore
(
// outputs:
GrB_Vector *decomp, // kcore decomposition
// inputs:
LAGraph_Graph G, // input graph
uint64_t k, //k level to compare to
char *msg
) ;
LAGRAPHX_PUBLIC
int LAGraph_KCore_Decompose
(
// outputs:
GrB_Matrix *D, // kcore decomposition
// inputs:
LAGraph_Graph G, // input graph
GrB_Vector decomp, // input decomposition matrix
uint64_t k,
char *msg
) ;
//------------------------------------------------------------------------------
// counting graphlets
//------------------------------------------------------------------------------
LAGRAPHX_PUBLIC
int LAGraph_FastGraphletTransform
(
// outputs:
GrB_Matrix *F_net, // 16-by-n matrix of graphlet counts
// inputs:
LAGraph_Graph G,
bool compute_d_15, // probably this makes most sense
char *msg
) ;
LAGRAPHX_PUBLIC
int LAGraph_SquareClustering
(
// outputs:
GrB_Vector *square_clustering,
// inputs:
LAGraph_Graph G,
char *msg
) ;
//------------------------------------------------------------------------------
// a simple example of an algorithm
//------------------------------------------------------------------------------
LAGRAPHX_PUBLIC
int LAGraph_HelloWorld // a simple algorithm, just for illustration
(
// output
GrB_Matrix *Yhandle, // Y, created on output
// input: not modified
LAGraph_Graph G,
char *msg
) ;
#if defined ( __cplusplus )
}
#endif
#endif
|