MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / Graph_DeleteNodes

Function Graph_DeleteNodes

src/graph/graph_delete_nodes.c:30–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28// this seperation to two phases avoids multiple flushes of labels-matrix
29
30void Graph_DeleteNodes
31(
32 Graph *g, // graph to delete nodes from
33 Node *nodes, // nodes to delete
34 uint64_t count // number of nodes
35) {
36 // assumption, nodes are detached
37 // there are no incoming nor outgoing edges leading to / from nodes
38 ASSERT(g != NULL);
39 ASSERT(count > 0);
40 ASSERT(nodes != NULL);
41
42 // set matrix sync policy to NOP
43 MATRIX_POLICY policy = Graph_GetMatrixPolicy(g);
44 Graph_SetMatrixPolicy(g, SYNC_POLICY_NOP);
45
46#if RG_DEBUG
47 Edge *es = array_new(Edge, 0);
48 for(uint i = 0; i < count; i++) {
49 Node *n = nodes + i;
50 // validate assumption
51 Graph_GetNodeEdges(g, n, GRAPH_EDGE_DIR_BOTH, GRAPH_NO_RELATION, &es);
52 ASSERT(array_len(es) == 0);
53 }
54 array_free(es);
55#endif
56
57 //--------------------------------------------------------------------------
58 // update label matrices
59 //--------------------------------------------------------------------------
60
61 GrB_Index j; // iterated entry col idx
62 GrB_Scalar s; // empty scalar
63 GrB_Matrix M; // delta M
64 GrB_Matrix DP; // delta plus
65 GrB_Matrix DM; // delta minus
66 GrB_Info info; // GraphBLAS return code
67 GrB_Index nrows; // lbls row count
68 GrB_Index ncols; // lbls col count
69 GrB_Matrix lbls_mask; // lbls mask
70 RG_MatrixTupleIter it; // matrix iterator
71
72 // create empty scalar
73 GrB_Scalar_new(&s, GrB_BOOL);
74
75 // get labels matrix
76 RG_Matrix lbls = Graph_GetNodeLabelMatrix(g);
77
78 // create lbls mask
79 info = RG_Matrix_nrows(&nrows, lbls);
80 ASSERT(info == GrB_SUCCESS);
81 info = RG_Matrix_ncols(&ncols, lbls);
82 ASSERT(info == GrB_SUCCESS);
83 info = GrB_Matrix_new(&lbls_mask, GrB_BOOL, nrows, ncols);
84 ASSERT(info == GrB_SUCCESS);
85
86 // attach iterator to lbls matrix
87 RG_MatrixTupleIter_attach(&it, lbls);

Callers 3

DeleteNodesFunction · 0.85
test_removeNodesFunction · 0.85

Calls 15

Graph_GetMatrixPolicyFunction · 0.85
Graph_SetMatrixPolicyFunction · 0.85
Graph_GetNodeEdgesFunction · 0.85
array_lenFunction · 0.85
array_freeFunction · 0.85
GrB_Scalar_newFunction · 0.85
Graph_GetNodeLabelMatrixFunction · 0.85
RG_Matrix_nrowsFunction · 0.85
RG_Matrix_ncolsFunction · 0.85
GrB_Matrix_newFunction · 0.85

Tested by 1

test_removeNodesFunction · 0.68