LCOV - code coverage report
Current view: top level - src/utility - LAGraph_DeleteSelfEdges.c (source / functions) Hit Total Coverage
Test: LAGraph code coverage report. Commit id: 3b461aa. Current time (UTC): 2024-01-25T16:04:32Z Lines: 10 10 100.0 %
Date: 2024-01-25 16:05:28 Functions: 1 1 100.0 %

          Line data    Source code
       1             : //------------------------------------------------------------------------------
       2             : // LAGraph_DeleteSelfEdges: removes the diagonal entries from G->A
       3             : //------------------------------------------------------------------------------
       4             : 
       5             : // LAGraph, (c) 2019-2022 by The LAGraph Contributors, All Rights Reserved.
       6             : // SPDX-License-Identifier: BSD-2-Clause
       7             : //
       8             : // For additional details (including references to third party source code and
       9             : // other files) see the LICENSE file or contact permission@sei.cmu.edu. See
      10             : // Contributors.txt for a full list of contributors. Created, in part, with
      11             : // funding and support from the U.S. Government (see Acknowledgments.txt file).
      12             : // DM22-0790
      13             : 
      14             : // Contributed by Timothy A. Davis, Texas A&M University
      15             : 
      16             : //------------------------------------------------------------------------------
      17             : 
      18             : #include "LG_internal.h"
      19             : 
      20          45 : int LAGraph_DeleteSelfEdges
      21             : (
      22             :     // input/output:
      23             :     LAGraph_Graph G,    // diagonal entries removed, most cached properties cleared
      24             :     char *msg
      25             : )
      26             : {
      27             : 
      28             :     //--------------------------------------------------------------------------
      29             :     // clear msg and check G
      30             :     //--------------------------------------------------------------------------
      31             : 
      32          45 :     LG_CLEAR_MSG_AND_BASIC_ASSERT (G, msg) ;
      33          45 :     if (G->nself_edges == 0)
      34             :     {
      35             :         // nothing to do
      36           9 :         return (GrB_SUCCESS) ;
      37             :     }
      38             : 
      39             :     //--------------------------------------------------------------------------
      40             :     // delete all cached properties not affected by the removal of the diagonal
      41             :     //--------------------------------------------------------------------------
      42             : 
      43          36 :     LAGraph_Boolean is_symmetric_structure = G->is_symmetric_structure ;
      44          36 :     LG_TRY (LAGraph_DeleteCached (G, msg)) ;
      45          36 :     G->is_symmetric_structure = is_symmetric_structure ;
      46             : 
      47             :     //--------------------------------------------------------------------------
      48             :     // remove diagonal entries
      49             :     //--------------------------------------------------------------------------
      50             : 
      51          36 :     GRB_TRY (GrB_select (G->A, NULL, NULL, GrB_OFFDIAG, G->A, 0, NULL)) ;
      52             : 
      53             :     //--------------------------------------------------------------------------
      54             :     // free workspace, G->nself_edges now known to be zero
      55             :     //--------------------------------------------------------------------------
      56             : 
      57          36 :     G->nself_edges = 0 ;
      58          36 :     return (GrB_SUCCESS) ;
      59             : }

Generated by: LCOV version 1.14